/* tracing.ts */// Import dependenciesimport{getNodeAutoInstrumentations}from"@opentelemetry/auto-instrumentations-node";importopentelemetryfrom"@opentelemetry/api";import{Resource}from"@opentelemetry/resources";import{SemanticResourceAttributes}from"@opentelemetry/semantic-conventions";import{NodeTracerProvider}from"@opentelemetry/sdk-trace-node";import{registerInstrumentations}from"@opentelemetry/instrumentation";import{ConsoleSpanExporter,BatchSpanProcessor}from"@opentelemetry/sdk-trace-base";// This registers all instrumentation packagesregisterInstrumentations({instrumentations:[getNodeAutoInstrumentations()],});constresource=Resource.default().merge(newResource({[SemanticResourceAttributes.SERVICE_NAME]:"service-name-here",[SemanticResourceAttributes.SERVICE_VERSION]:"0.1.0",}));constprovider=newNodeTracerProvider({resource:resource,});constexporter=newConsoleSpanExporter();constprocessor=newBatchSpanProcessor(exporter);provider.addSpanProcessor(processor);provider.register();
/* tracing.js */// Require dependenciesconst{getNodeAutoInstrumentations}=require("@opentelemetry/auto-instrumentations-node");constopentelemetry=require("@opentelemetry/api");const{Resource}=require("@opentelemetry/resources");const{SemanticResourceAttributes}=require("@opentelemetry/semantic-conventions");const{NodeTracerProvider}=require("@opentelemetry/sdk-trace-node");const{registerInstrumentations}=require("@opentelemetry/instrumentation");const{ConsoleSpanExporter,BatchSpanProcessor}=require("@opentelemetry/sdk-trace-base");// This registers all instrumentation packagesregisterInstrumentations({instrumentations:[getNodeAutoInstrumentations()],});constresource=Resource.default().merge(newResource({[SemanticResourceAttributes.SERVICE_NAME]:"service-name-here",[SemanticResourceAttributes.SERVICE_VERSION]:"0.1.0",}));constprovider=newNodeTracerProvider({resource:resource,});constexporter=newConsoleSpanExporter();constprocessor=newBatchSpanProcessor(exporter);provider.addSpanProcessor(processor);provider.register();
/* tracing.ts */// Import dependenciesimport{HttpInstrumentation}from"@opentelemetry/instrumentation-http";import{ExpressInstrumentation}from"@opentelemetry/instrumentation-express";importopentelemetryfrom"@opentelemetry/api";import{Resource}from"@opentelemetry/resources";import{SemanticResourceAttributes}from"@opentelemetry/semantic-conventions";import{NodeTracerProvider}from"@opentelemetry/sdk-trace-node";import{registerInstrumentations}from"@opentelemetry/instrumentation";import{ConsoleSpanExporter,BatchSpanProcessor}from"@opentelemetry/sdk-trace-base";// This registers all instrumentation packagesregisterInstrumentations({instrumentations:[// Express instrumentation expects HTTP layer to be instrumentednewHttpInstrumentation(),newExpressInstrumentation(),],});constresource=Resource.default().merge(newResource({[SemanticResourceAttributes.SERVICE_NAME]:"service-name-here",[SemanticResourceAttributes.SERVICE_VERSION]:"0.1.0",}));constprovider=newNodeTracerProvider({resource:resource,});constexporter=newConsoleSpanExporter();constprocessor=newBatchSpanProcessor(exporter);provider.addSpanProcessor(processor);provider.register();
/* tracing.js */// Require dependenciesconst{HttpInstrumentation}=require("@opentelemetry/instrumentation-http");const{ExpressInstrumentation}=require("@opentelemetry/instrumentation-express");constopentelemetry=require("@opentelemetry/api");const{Resource}=require("@opentelemetry/resources");const{SemanticResourceAttributes}=require("@opentelemetry/semantic-conventions");const{NodeTracerProvider}=require("@opentelemetry/sdk-trace-node");const{registerInstrumentations}=require("@opentelemetry/instrumentation");const{ConsoleSpanExporter,BatchSpanProcessor}=require("@opentelemetry/sdk-trace-base");// This registers all instrumentation packagesregisterInstrumentations({instrumentations:[// Express instrumentation expects HTTP layer to be instrumentednewHttpInstrumentation(),newExpressInstrumentation(),],});constresource=Resource.default().merge(newResource({[SemanticResourceAttributes.SERVICE_NAME]:"service-name-here",[SemanticResourceAttributes.SERVICE_VERSION]:"0.1.0",}));constprovider=newNodeTracerProvider({resource:resource,});constexporter=newConsoleSpanExporter();constprocessor=newBatchSpanProcessor(exporter);provider.addSpanProcessor(processor);provider.register();