Skip to content

Instantly share code, notes, and snippets.

@badri
Created May 14, 2025 06:32
Show Gist options
  • Save badri/c98645757f72fdd2455df13c2bdb7d0a to your computer and use it in GitHub Desktop.
Save badri/c98645757f72fdd2455df13c2bdb7d0a to your computer and use it in GitHub Desktop.
Grafana cloud OTLP
// tracing.js
const { NodeSDK } = require('@opentelemetry/sdk-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
// Replace these with your actual values
const otlpEndpoint = 'https://otlp-gateway-prod-us-central-0.grafana.net/otlp';
const instanceId = 'YOUR_INSTANCE_ID';
const apiToken = 'YOUR_API_TOKEN';
const traceExporter = new OTLPTraceExporter({
url: otlpEndpoint,
headers: {
'Authorization': 'Basic ' + Buffer.from(`${instanceId}:${apiToken}`).toString('base64'),
},
});
const sdk = new NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
});
sdk.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment