Created
May 14, 2025 06:32
-
-
Save badri/c98645757f72fdd2455df13c2bdb7d0a to your computer and use it in GitHub Desktop.
Grafana cloud OTLP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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