Slackbot
09/27/2021, 3:13 PMDevi varalakshmi
09/27/2021, 3:14 PMPranay
Devi varalakshmi
09/28/2021, 12:33 PMPranay
Pranay
Pranay
Itzik Lavon
09/29/2021, 3:25 AMconst client = require('prom-client');
const url = require('url');
var express = require('express');
const process = require('process');
const opentelemetry = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector-grpc');
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
var app = express();
var port = 3000;
// var clean = require('xss-clean/lib/xss').clean;
var bodyParser = require('body-parser');
// <---- open telementary
// configure the SDK to export telemetry data to the console
// enable all auto-instrumentations from the meta package
const collectorOptions = {
// url is optional and can be omitted - default is <grpc://localhost:4317>
url: process.env.NODE_OTEL_COLLECTOR_GRPC,
};
const traceExporter = new CollectorTraceExporter(collectorOptions);
const sdk = new opentelemetry.NodeSDK({
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'prerouter',
}),
traceExporter,
instrumentations: [getNodeAutoInstrumentations()]
});
// initialize the SDK and register with the OpenTelemetry API
// this enables the API to record telemetry
sdk.start()
.then(() => console.log('Tracing initialized'))
.catch((error) => console.log('Error initializing tracing', error));
// gracefully shut down the SDK on process exit
process.on('SIGTERM', () => {
sdk.shutdown()
.then(() => console.log('Tracing terminated'))
.catch((error) => console.log('Error terminating tracing', error))
.finally(() => process.exit(0));
});
use your own service name and collector uriDevi varalakshmi
09/29/2021, 4:39 AMSigNoz is an open-source APM. It helps developers monitor their applications & troubleshoot problems, an open-source alternative to DataDog, NewRelic, etc.
Powered by