Traces Explorer Quick Start

Minimal OTLP/HTTP examples for exporting traces to Statsig's Traces Explorer across popular languages.

Send traces to Statsig's Traces Explorer by exporting your spans over OTLP/HTTP. TypeScript and Node apps can post directly to Statsig's API; for every other language, you route spans through an OpenTelemetry Collector and configure the Collector to forward the spans to Statsig.

To set up Logs and Metrics as well, go to Getting Started for more in-depth OpenTelemetry Collector setup instructions.

Use the OTLP/HTTP traces endpoint to forward spans into Traces Explorer. Authenticate using your Server Secret key in the header:

  • Endpoint: https://api.statsig.com/otlp/v1/traces
  • Header: statsig-api-key: <your Server SDK Secret key>

Statsig supports direct to API for TypeScript/Node only. For all other languages, send traces to your OpenTelemetry Collector and configure it to forward to Statsig over OTLP/HTTP.

For non-TypeScript apps, point your Collector (for example, http://localhost:4318/v1/traces) to Statsig by configuring the Collector to forward traffic to Statsig:

yaml
receivers:
  otlp:
    protocols:
      http:

exporters:
  otlphttp:
    endpoint: https://api.statsig.com/otlp
    encoding:  json
    headers:
      statsig-api-key: ${env:STATSIG_SERVER_SDK_SECRET}

service:
  pipelines:
    traces:
      receivers: [otlp]
      exporters: [otlphttp]
bash
npm install @opentelemetry/sdk-node @opentelemetry/sdk-trace-node @opentelemetry/sdk-trace-base @opentelemetry/exporter-trace-otlp-http @opentelemetry/resources @opentelemetry/semantic-conventions @opentelemetry/api
js
// trace.js
const { NodeSDK } = require('@opentelemetry/sdk-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
const { BatchSpanProcessor } = require('@opentelemetry/sdk-trace-base');
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { trace } = require('@opentelemetry/api');

const sdk = new NodeSDK({
  resource: new Resource({
    [SemanticResourceAttributes.SERVICE_NAME]: 'trace-sample-node',
  }),
  spanProcessor: new BatchSpanProcessor(
    new OTLPTraceExporter({
      url: 'https://api.statsig.com/otlp/v1/traces',
      headers: { 'statsig-api-key': process.env.STATSIG_SERVER_SDK_SECRET || '' },
    }),
  ),
});

sdk.start().then(() => {
  const tracer = trace.getTracer('example');
  const span = tracer.startSpan('do-work');
  span.setAttribute('example', true);
  span.end();

  setTimeout(() => sdk.shutdown(), 1000);
});
For collector installation and configuration, go to Open Telemetry Logs and Metrics. For full Logs and Metrics setup, go to Getting Started.

Was this helpful?