0.1.10 • Published 1 year ago

@jambonz/tracing v0.1.10

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

jambonz/tracing

Centralised opentelemetry for tracing Jambonz apps

Getting Started

Create a new JambonzTracer instance

 const {tracer} = new JambonzTracer({
  enabled: true,
  version: "1.0.0",
  serviceName: 'my-jambonz-app',
  jaegerEndpoint: 'http://127.0.0.0:14268/api/traces',
  logLevel: 'info'
});

JambonzTracer Configuration

Configuration is provided via environment variables:

variablemeaningrequired?
enabledenable otel tracingno
versionapp version, usually taken from package.jsonyes
namename of otel serviceyes
jaegerEndpointurl for JaegerExporterno
zipkinEndpointurl for ZipkinExporterno
collectorEndpointurl for OTLPTraceExporterno
logLevelwarn,info,debug or traceno

Create a RootSpan

   const rootSpan = new RootSpan('incoming-call', traceId, spanId, {'callerName': 'smithy'}, tracer, logger);
   //or 
   const rootSpan = RootSpan.createFromSIPHeaders('incoming-call', sipRequest, tracer, logger);
variablemeaningrequired?
namename of current spanyes
traceIdA valid trace identifier is a 16-byte array with at least one non-zero byte. Or a UUID v4 equivalent. Leave null to generate new root traceIdno
spanIdA valid trace identifier is a 8-byte array with at least one non-zero byteno
attributesmap of attributes to assign to spanno
tracerthe tracer instanceyes
loggerloggerno

Create and nest ChildSpan's

    const childSpan = rootSpan.startChildSpan('doSomeWork', {'key': '1234'});
    const childSpan2 = childSpan.startChildSpan('subWork', {'key': '2468'});
variablemeaningrequired?
callTypename of current spanyes
attributesmap of attributes to assign to spanyes

Setting Attributes

    childSpan.setAttributes({'anotherKey': "5678"})

Ending a span

    childSpan.end(); 
    //or
    childSpan.endWithError('An error ocurred');