@zerosuxx/opentelemetry-nestjs
Version:
OpenTelemetry module for Nestjs with auto instrumentation and resource detection. Initially forked from https://github.com/overbit/opentelemetry-nestjs.git
20 lines (16 loc) • 485 B
text/typescript
import { context, trace, Span } from '@opentelemetry/api';
import { Injectable } from '@nestjs/common';
import { Constants } from '../Constants';
()
export class TraceService {
public getTracer() {
return trace.getTracer(Constants.TRACER_NAME);
}
public getSpan(): Span {
return trace.getSpan(context.active());
}
public startSpan(name: string): Span {
const tracer = trace.getTracer(Constants.TRACER_NAME);
return tracer.startSpan(name);
}
}