- Collector Sidecar — an OTel Agent runs alongside your app, handles OAuth2 automatically, and forwards traces to the gateway.
- Direct from Application — your application code manages OAuth2 tokens and sends traces to the gateway without a sidecar.
Prerequisites
API Credentials
Create API credentials from the Unomiq Management API or the Unomiq Dashboard. The credentials must have thewrite:traces permission.
This will give you an API key (Client ID) and secret (Client Secret).
Configuration
Set the following environment variables:| Variable | Description |
|---|---|
OAUTH_CLIENT_ID | API Key from the Unomiq Management API / dashboard |
OAUTH_CLIENT_SECRET | API Secret from the Unomiq Management API / dashboard |
OAUTH_TOKEN_URL | https://oauth-api.unomiq.com/token |
OAUTH_SCOPES | Set to write:traces |
OTEL_EXPORTER_OTLP_ENDPOINT | https://gateway-api.unomiq.com |
Approach 1: OTel Collector Sidecar
In this approach, your application sends telemetry to a local OTel Collector over an unauthenticated connection. The collector handles OAuth2 token acquisition and renewal, then forwards the authenticated telemetry to the gateway.Collector Configuration
The collector uses theoauth2clientauthextension from the OpenTelemetry Collector Contrib distribution.
Create an otel-collector-config.yaml:
- The
oauth2clientextension acquires a token using the client credentials grant and automatically refreshes it before expiry. - The
otlphttpexporter references the extension viaauth.authenticator, so every outgoing request includes theAuthorization: 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 theoauth2clientauthextension. 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):OTEL_EXPORTER_OTLP_ENDPOINT environment variable to http://localhost:4318 (or the collector’s hostname in Docker/Kubernetes).
Approach 2: Direct Authentication 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:Step 2: Configure the Tracer
Wire the token manager into the OTLP exporter:Step 3: Use the Tracer
opentelemetry-instrumentation-flask) after calling configure_tracing().
Required Dependencies
Choosing Between the Two Approaches
| Collector Sidecar | Direct from Application | |
|---|---|---|
| Auth handling | Collector manages tokens | Application manages tokens |
| Code changes | None (env vars only) | Token manager + exporter setup |
| Infrastructure | Requires running a collector | No extra infrastructure |
| Language support | Any (language-agnostic) | Requires per-language implementation |
| Best for | Docker, Kubernetes | Serverless (Cloud Run, Lambda) |
| Token refresh | Handled by collector | Handled by background thread |
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
OAUTH_CLIENT_ID,OAUTH_CLIENT_SECRET, andOAUTH_TOKEN_URLare correct. - Check that the scopes match what the gateway expects.
- Ensure the token endpoint is reachable from your environment.
- Confirm
OTEL_EXPORTER_OTLP_ENDPOINTis 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).
- The sidecar collector and the Python token manager both 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 thedebug exporter to your collector pipeline for verbose output: