Created
August 8, 2022 20:04
-
-
Save jpkrohling/8ed1b03080b52aa46fce3498b5483217 to your computer and use it in GitHub Desktop.
Using OTLP gRPC for nodejs with Grafana Cloud Traces
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 grpc = require('@grpc/grpc-js'); | |
// Require dependencies | |
const opentelemetry = require("@opentelemetry/sdk-node"); | |
const { getNodeAutoInstrumentations } = require("@opentelemetry/auto-instrumentations-node"); | |
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-grpc'); | |
const metadata = new grpc.Metadata(); | |
// after "Basic", comes the output of: | |
// echo -n username:password | base64 -w 0 | |
metadata.set('authorization', 'Basic MTIzNDU6dGhla2V5'); | |
const exporter = new OTLPTraceExporter({ | |
url: 'tempo-us-central1.grafana.net:443', | |
credentials: grpc.credentials.createSsl(), | |
metadata, | |
}); | |
const sdk = new opentelemetry.NodeSDK({ | |
traceExporter: exporter, | |
instrumentations: [getNodeAutoInstrumentations()] | |
}); | |
sdk.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use this tutorial, but instead of the tracing.js they provide, use the one from the Gist:
https://opentelemetry.io/docs/instrumentation/js/getting-started/nodejs/