- Kubernetes/OpenTelemetry Collector: scrape logs and metrics from your cluster and export to Statsig. See Open Telemetry Logs and Metrics for a more complete guide.
- Applications: export traces, metrics, and logs directly from your app over OTLP/HTTP to Statsig or to your collector. See the quick starts below.
Endpoint & Auth
- Endpoint:
https://api.statsig.com/otlp - Auth header:
statsig-api-key: <your Server SDK Secret key>
Application Telemetry quick starts
- Node.js
- Next.js
- Other Languages/Frameworks
Install dependencies:Initialize OpenTelemetry (e.g., To set up application logs with OTel, you can use the pino or winston bridges. The example below using pino with
pino auto instrumentation.Install the pino instrumentation:The Statsig SDK also supports forwarding logs to Log Explorer; see the alternative logging example below.Run your service:make sure that you require or import Tip: you can configure exporters via env instead of code:
instrumentation.js):instrumentation.js before any other application code to ensure instrumentation is set up correctly.OTEL_EXPORTER_OTLP_ENDPOINT=https://api.statsig.com/otlpOTEL_EXPORTER_OTLP_HEADERS=statsig-api-key=${STATSIG_SERVER_SDK_SECRET}OTEL_EXPORTER_OTLP_PROTOCOL=http/json
Collector quick starts
Running a Collector is optional but recommended for production workloads. Use the OpenTelemetry Collector as a gateway to receive OTLP from your applications and forward to Statsig. This is useful if you want to centralize telemetry collection, add advanced sampling methods like tail-based sampling, or scrape logs/metrics from hosts or Kubernetes.- Kubernetes (Helm)
- Docker (Compose)
- Other
Create a minimal Install the Collector with Helm:Provide the Statsig key as an environment variable to the Collector pods (for example via a Secret and envFrom). Your applications then send OTLP to the in-cluster Collector endpoint (for example
values.yaml for the OpenTelemetry Collector that forwards all signals (traces, metrics, logs) to Statsig:values.yaml
http://otel-gateway-collector.otel.svc.cluster.local:4318).For a production setup that also scrapes Kubernetes logs/metrics, see the full guide: Open Telemetry Logs and Metrics.Version requirementThe
encoding: json option in the OTLP HTTP exporter requires Collector v0.95.0 or newer. If you pin the image via Helm values, set image.tag: "0.95.0" (or newer).Common Collector Configs (K8s & Docker)
The following examples show popular receivers/processors you can enable in your Collector and still export to Statsig via the sameotlphttp exporter.
Note: These components live in the contrib distribution. Use an image that includes them:
- Docker:
otel/opentelemetry-collector-contribor newer - Helm: set
image.repository: otel/opentelemetry-collector-contrib(and a compatibleimage.tag)
values.yaml
A. File logs (filelog receiver)
Reads and parses logs from files on disk. Useful for hosts, containers, or Kubernetes nodes. Minimal example:/var/log/pods and /var/lib/docker/containers) into the Collector DaemonSet and set include to those paths.
B. EC2 resource detection (resourcedetection processor)
Automatically adds AWS EC2 metadata (cloud provider, region/zone, instance id) to your telemetry.169.254.169.254 and IMDSv2 where required.
C. Docker container metrics (docker_stats receiver)
Emits container CPU, memory, network, and block IO metrics by querying the Docker daemon.- Linux only (not supported on darwin/windows).
- Mount the Docker socket into the Collector container:
/var/run/docker.sock.
Resources
- OpenTelemetry Collector: https://opentelemetry.io/docs/collector/
- Kubernetes Collector components: https://opentelemetry.io/docs/platforms/kubernetes/collector/components/
- Helm chart: https://github.com/open-telemetry/opentelemetry-helm-charts
- Collector configuration reference: https://opentelemetry.io/docs/collector/configuration
- OTLP protocol specification: https://opentelemetry.io/docs/specs/otlp/
- Filelog receiver (contrib): https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/filelogreceiver
- Resource detection processor (contrib): https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/resourcedetectionprocessor
- Docker stats receiver (contrib): https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/dockerstatsreceiver
- Collector contrib distribution: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib