npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@fredko/nestjs-opentelemetry-tracing

v0.1.1

Published

A NestJS package for tracing services.

Readme

@fredko/nestjs-opentelemetry-tracing

A NestJS package for tracing services.

Description

@fredko/nestjs-opentelemetry-tracing is a NestJS module that provides OpenTelemetry tracing capabilities for your application. It allows you to easily trace the execution of your controllers and providers, giving you insights into the performance and behavior of your application.

Note: This package requires an existing OpenTelemetry instrumentation setup. Ensure that your application is configured with OpenTelemetry before integrating this module.

Installation

npm install @fredko/nestjs-opentelemetry-tracing @nestjs/common @nestjs/core @nestjs/microservices @opentelemetry/api

Usage

Basic Usage

  1. Import OtelNestTracingModule into your root module:
import { Module } from '@nestjs/common';
import { OtelNestTracingModule } from '@fredko/nestjs-opentelemetry-tracing';

@Module({
    imports: [
        OtelNestTracingModule.forRoot({
            // Optional configuration options
        }),
    ],
})
export class AppModule {}
  1. The module will automatically instrument your controllers and providers for tracing.

Configuration Options

The forRoot method accepts the following configuration options:

  • dirInclusionPatterns: An array of regular expressions to filter which directories to include for tracing.
  • dirExcludePatterns: An array of regular expressions to filter which directories to exclude from tracing.
  • classNameIncludePatterns: An array of regular expressions to filter which class names to include for tracing.
  • classNameExcludePatterns: An array of regular expressions to filter which class names to exclude from tracing.
  • methodNameIncludePatterns: An array of regular expressions to filter which method names to include for tracing.
  • methodNameExcludePatterns: An array of regular expressions to filter which method names to exclude from tracing.

These options allow you to fine-tune which parts of your application are traced. For example, you can include only certain directories or exclude specific classes or methods from being traced.

Example:

OtelNestTracingModule.forRoot({
  dirInclusionPatterns: [/src/],
  dirExcludePatterns: [/node_modules/],
  classNameIncludePatterns: [/Service$/],
  classNameExcludePatterns: [/TestService$/],
  methodNameIncludePatterns: [/.*Async$/],
  methodNameExcludePatterns: [/^_/],
}),

How Tracing Works

The tracing manager uses the provided patterns to determine which classes and methods should be instrumented. It checks both the class name and the file path to decide if a class is traceable. Similarly, it checks method names to decide if a method should be traced. The logic is implemented in the isTraceableClass and isTraceableMethod methods.

  • isTraceableClass: Determines if a class should be traced based on its name and file path. A class is traceable if:

    • It matches at least one pattern in classNameIncludePatterns (or if this list is empty, all classes are included by default).
    • It does not match any pattern in classNameExcludePatterns.
    • Its file path matches at least one pattern in dirInclusionPatterns (or if this list is empty, all directories are included by default).
    • Its file path does not match any pattern in dirExcludePatterns.
  • isTraceableMethod: Determines if a method should be traced based on its name. A method is traceable if:

    • It matches at least one pattern in methodNameIncludePatterns (or if this list is empty, all methods are included by default).
    • It does not match any pattern in methodNameExcludePatterns.

Example

Consider the following configuration:

OtelNestTracingModule.forRoot({
    classNameIncludePatterns: [/Service$/],
    classNameExcludePatterns: [/TestService$/],
    dirInclusionPatterns: [/src/],
    dirExcludePatterns: [/Repository/],
    methodNameIncludePatterns: [/.*Async$/],
    methodNameExcludePatterns: [/^_/],
});
  • A class named UserService located in src/services will be traced because it ends with Service and is in the src directory.
  • A class named TestService will not be traced because it matches the classNameExcludePatterns.
  • A method named fetchDataAsync will be traced because it ends with Async.
  • A method named _privateMethod will not be traced because it starts with _.

Compiler Plugin

To use dirInclusionPatterns and dirExcludePatterns, you must configure the compiler plugin. This package includes a compiler plugin that can be used to automatically add tracing to your controllers and providers during compilation. To use the plugin, add it to your nest-cli.json file:

{
    "compilerOptions": {
        "plugins": ["@fredko/nestjs-opentelemetry-tracing/plugin"]
    }
}

License

MIT