🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@opentelemetry/instrumentation-undici

Package Overview
Dependencies
Maintainers
3
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/instrumentation-undici

OpenTelemetry instrumentation for `undici` http client and Node.js fetch()

0.13.1
latest
npm
Version published
Weekly downloads
4.4M
4.93%
Maintainers
3
Weekly downloads
 
Created

What is @opentelemetry/instrumentation-undici?

@opentelemetry/instrumentation-undici is an npm package that provides automatic instrumentation for the undici HTTP client library using OpenTelemetry. This allows developers to collect and export telemetry data such as traces and metrics from their undici-based HTTP requests, which can be used for monitoring and observability purposes.

What are @opentelemetry/instrumentation-undici's main functionalities?

Automatic Instrumentation

This feature allows you to automatically instrument undici HTTP client requests. By registering the UndiciInstrumentation with the OpenTelemetry tracer provider, all HTTP requests made using undici will be traced and the telemetry data will be collected.

const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { UndiciInstrumentation } = require('@opentelemetry/instrumentation-undici');

const provider = new NodeTracerProvider();
provider.register();

registerInstrumentations({
  instrumentations: [
    new UndiciInstrumentation(),
  ],
  tracerProvider: provider,
});

Custom Attributes

This feature allows you to add custom attributes to the spans created for undici HTTP requests. By providing a requestHook function, you can modify the span and add any custom attributes you need for better observability.

const { UndiciInstrumentation } = require('@opentelemetry/instrumentation-undici');

const undiciInstrumentation = new UndiciInstrumentation({
  requestHook: (span, request) => {
    span.setAttribute('custom-attribute', 'value');
  },
});

Other packages similar to @opentelemetry/instrumentation-undici

Keywords

opentelemetry

FAQs

Package last updated on 12 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts