1.0.2-develop-383 • Published 7 months ago

@bluealba-public/opentelemetry-tracer-nestjs v1.0.2-develop-383

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

OpenTelemetry Tracer for NestJS

Overview

OpenTelemetry Tracer for NestJS integrates robust tracing into your NestJS applications. Built on top of OpenTelemetry, it offers auto-instrumentation and allows custom configuration to monitor performance and troubleshoot issues in your NestJS services.

Installation

Install the package from npm:

npm install @bluealba-public/opentelemetry-tracer-nestjs

Usage

Import the module and initialize tracing in your NestJS application. Add the tracer module to your root module:

import { Module } from '@nestjs/common';
import { OpenTelemetryModule } from '@bluealba-public/opentelemetry-tracer-nestjs';

@Module({
  imports: [
    // ...existing modules...
    OpenTelemetryModule.forRoot({
      tracing: {
        global: true,
        enabled: !!process.env.TRACE_URL,
        url: process.env.TRACE_URL,
        serviceName: 'your-nest-service',
      },
    }),
  ],
  // ...existing providers and controllers...
})
export class AppModule {}

Configuration

Configure your tracer with the following options:

  • enabled: Toggle tracing on or off.
  • url: Specify the OTLP trace exporter endpoint.
  • serviceName: Name your service for trace identification.
  • logger: (Optional) Custom logger for additional logging.
  • global: (Optional) Globally activate the tracking module.
  • instrumentations: (Optional) List of instrumentations to enable.