Skip to main content
This guide describes how to send OpenTelemetry traces to the Unomiq OTel Gateway API.

Prerequisites

API Credentials

Create API credentials from the Unomiq Dashboard. The credentials must have the write:traces permission. This will give you an API key (Client ID) and secret (Client Secret).

With unomiq-sdk

The unomiq-sdk Python package handles OAuth2-authenticated OTLP export and unit attribute attachment. It can be used on its own (direct export) or alongside an OTel Collector sidecar.

Configuration

Set the following environment variables for your application: The SDK uses these credentials internally to acquire and refresh OAuth2 tokens and export traces to the Unomiq Gateway.

Direct Export (No Sidecar)

In this approach, unomiq-sdk handles everything: it creates a TracerProvider, configures an OAuth2-authenticated OTLP exporter, and attaches unit attributes to spans.
This is useful for serverless environments (Cloud Run, Lambda) or when you want fewer infrastructure components.
With this setup, the SDK reads UNOMIQ_CLIENT_ID and UNOMIQ_CLIENT_SECRET from the environment, creates an authenticated OTLP exporter, and sets up the global TracerProvider. No additional exporter or provider configuration is needed. For frameworks like Flask or Django, you can use OpenTelemetry instrumentor libraries after calling Unomiq.init():

With OTel Collector Sidecar

You can also use unomiq-sdk alongside a Collector sidecar. In this case, the sidecar handles OAuth and export, while unomiq-sdk only handles unit attribute attachment.
Since auth and export are handled by the collector, the SDK only needs resolve_unit / resolve_parent_unit. No app_name or resource_attributes are required. Point your application’s OTLP exporter at the local collector:
See the OTel Collector Sidecar section below for the collector configuration.

Without unomiq-sdk

If you are not using unomiq-sdk, you can send traces by managing the OAuth2 flow and OTLP export yourself. There are two approaches:
  1. Collector Sidecar — an OTel Collector runs alongside your app, handles OAuth2, and forwards traces to the gateway.
  2. Direct from Application — your application code manages OAuth2 tokens and sends traces to the gateway.
Both approaches use the OAuth2 client credentials grant type, with automatic refresh token support when available.

Configuration

Set the following environment variables:

Direct from Application (Python)

In this approach, your application manages OAuth2 tokens and sends authenticated traces directly to the gateway. No sidecar is needed.

Step 1: OAuth2 Token Manager

Create a token manager that handles the client credentials flow and automatic refresh. If the token endpoint returns a refresh_token, subsequent renewals use the lighter refresh_token grant instead of re-sending client credentials:

Step 2: Configure the Tracer

Wire the token manager into the OTLP exporter:

Step 3: Use the Tracer

For frameworks like Flask or Django, you can also use the OpenTelemetry instrumentor libraries (e.g., opentelemetry-instrumentation-flask) after calling configure_tracing().

Required Dependencies


OTel Collector Sidecar Configuration

This section applies to both the unomiq-sdk sidecar approach and the without-SDK sidecar approach. In both cases, the collector handles OAuth2 token acquisition and forwards authenticated traces to the gateway.
The collector uses the oauth2clientauthextension from the OpenTelemetry Collector Contrib distribution.

Environment Variables

Set the following environment variables for the collector (not the application):

Collector Config

Create an otel-collector-config.yaml:
Key points:
  • The oauth2client extension acquires a token using the client credentials grant and automatically refreshes it before expiry.
  • The otlphttp exporter references the extension via auth.authenticator, so every outgoing request includes the Authorization: Bearer <token> header.
  • The receiver listens on standard OTLP ports (4317 for gRPC, 4318 for HTTP) without requiring any authentication from your application.

Running the Collector

Use the contrib distribution of the collector, which includes the oauth2clientauthextension. The core distribution does not include it. Docker Compose example:

Configuring Your Application

Point your application’s OTLP exporter at the local collector. No authentication configuration is needed in the application itself. Python (automatic instrumentation):
Python (SDK):
Any language: Set the OTEL_EXPORTER_OTLP_ENDPOINT environment variable to http://localhost:4318 (or the collector’s hostname in Docker/Kubernetes).

Choosing an Approach


Monitoring Sent Traces

Once your traces are flowing to the gateway, you can monitor them in two ways:
  • API — Use the Get Live Traces endpoint to programmatically retrieve and inspect incoming traces in real time.
  • Dashboard — View and explore traces visually from the Unomiq Dashboard.

Troubleshooting

Common Issues

401 Unauthorized from the gateway
  • Verify that your client ID and secret are correct (UNOMIQ_CLIENT_ID / UNOMIQ_CLIENT_SECRET).
  • Check that the scopes match what the gateway expects (write:traces).
  • Ensure the token endpoint is reachable from your environment.
No traces appearing at the gateway
  • Confirm the OTLP endpoint is set to the correct gateway URL.
  • For the sidecar approach, check collector logs for export errors.
  • For direct export, enable debug logging: logging.getLogger('opentelemetry').setLevel(logging.DEBUG).
Token refresh failures
  • The sidecar collector and the unomiq-sdk / Python token manager all refresh tokens automatically before expiry. Check logs for errors from the token endpoint.
  • Ensure your OAuth2 client has not been revoked or rate-limited.

Viewing Collector Logs (Sidecar Approach)

Add the debug exporter to your collector pipeline for verbose output: