mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
* initial adds for otel tracing * initial basic testing * basic tracing for incoming calls * linting * add traceId to the webhook params * trace webhook calls * tracing: add new commands as tags when receiving async commands over websocket * tracing new commands * add summary for config verb * trace async commands * bugfix: undefined ref * tracing: give time for final webhooks before closing root span * tracing bugfix: span for background gather was not ended * tracing - minor tag changes * tracing - add span atttribute for reason call ended * trace call status webhooks, add app version to trace output * config: add support for automatically re-enabling * env var to customize service name in tracing UI * config: change to use 'sticky' attribute to re-enable bargein automatically * fix warnings * when adulting create a new root span * when background gather triggers bargein via vad clear queue of tasks * additional trace attributes for dial and refer * fix dial tracing * add better summary for dial * fix prev commit * add exponential backoff to WsRequestor reconnection logic * add calling number to log metadata, as this will be frequently the key data given for troubleshooting * add accountSid to log metadata * make handshake timeout for ws connections configurable with default 1.5 secs * rename env var * fix bug prev checkin * logging fixes * consistent env naming
62 lines
2.4 KiB
JavaScript
62 lines
2.4 KiB
JavaScript
const opentelemetry = require('@opentelemetry/api');
|
|
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
|
|
const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
|
|
const { Resource } = require('@opentelemetry/resources');
|
|
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
|
|
const { BatchSpanProcessor } = require('@opentelemetry/sdk-trace-base');
|
|
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
|
|
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
|
|
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector');
|
|
//const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http');
|
|
//const { ExpressInstrumentation } = require('@opentelemetry/instrumentation-express');
|
|
//const { PinoInstrumentation } = require('@opentelemetry/instrumentation-pino');
|
|
|
|
module.exports = (serviceName) => {
|
|
if (process.env.JAMBONES_OTEL_ENABLED) {
|
|
const {version} = require('./package.json');
|
|
const provider = new NodeTracerProvider({
|
|
resource: new Resource({
|
|
[SemanticResourceAttributes.SERVICE_NAME]: serviceName,
|
|
[SemanticResourceAttributes.SERVICE_VERSION]: version,
|
|
}),
|
|
});
|
|
|
|
let exporter;
|
|
if (process.env.OTEL_EXPORTER_JAEGER_AGENT_HOST) {
|
|
exporter = new JaegerExporter();
|
|
}
|
|
else if (process.env.OTEL_EXPORTER_ZIPKIN_URL) {
|
|
exporter = new ZipkinExporter({url:process.env.OTEL_EXPORTER_ZIPKIN_URL});
|
|
}
|
|
else {
|
|
exporter = new CollectorTraceExporter({
|
|
url: process.OTEL_EXPORTER_COLLECTOR_URL
|
|
});
|
|
}
|
|
|
|
provider.addSpanProcessor(new BatchSpanProcessor(exporter, {
|
|
// The maximum queue size. After the size is reached spans are dropped.
|
|
maxQueueSize: 100,
|
|
// The maximum batch size of every export. It must be smaller or equal to maxQueueSize.
|
|
maxExportBatchSize: 10,
|
|
// The interval between two consecutive exports
|
|
scheduledDelayMillis: 500,
|
|
// How long the export can run before it is cancelled
|
|
exportTimeoutMillis: 30000,
|
|
}));
|
|
|
|
// Initialize the OpenTelemetry APIs to use the NodeTracerProvider bindings
|
|
provider.register();
|
|
registerInstrumentations({
|
|
instrumentations: [
|
|
//new HttpInstrumentation(),
|
|
//new ExpressInstrumentation(),
|
|
//new PinoInstrumentation()
|
|
],
|
|
});
|
|
}
|
|
|
|
return opentelemetry.trace.getTracer(serviceName);
|
|
};
|
|
|