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

@platformatic/instrumentation-light-my-request

v1.0.4

Published

OpenTelemetry instrumentation for light-my-request (Fastify inject)

Downloads

7

Readme

@platformatic/instrumentation-light-my-request

OpenTelemetry instrumentation for light-my-request, which instruments Fastify's inject() method for testing and internal request handling.

Installation

npm install @platformatic/instrumentation-light-my-request

Usage

This instrumentation automatically patches light-my-request to create OpenTelemetry spans for injected requests. This is useful because fastify.inject() bypasses HTTP entirely, so standard HTTP instrumentation doesn't capture these operations.

With NodeSDK

import { NodeSDK } from '@opentelemetry/sdk-node'
import { LightMyRequestInstrumentation } from '@platformatic/instrumentation-light-my-request'

const sdk = new NodeSDK({
  instrumentations: [
    new LightMyRequestInstrumentation()
  ]
})

sdk.start()

With registerInstrumentations

import { registerInstrumentations } from '@opentelemetry/instrumentation'
import { LightMyRequestInstrumentation } from '@platformatic/instrumentation-light-my-request'

registerInstrumentations({
  instrumentations: [
    new LightMyRequestInstrumentation()
  ]
})

Features

  • Automatic span creation: Creates SERVER spans for each inject() call
  • Context propagation: Extracts trace context from injected headers
  • Error tracking: Records exceptions and sets appropriate span status
  • Promise and callback support: Works with both callback and promise-based inject calls
  • Provider-agnostic: Uses this.tracer getter, works with any TracerProvider

Span Attributes

This instrumentation follows OpenTelemetry semantic conventions and sets the following attributes:

Required Attributes

  • http.request.method: HTTP method (GET, POST, etc.)
  • url.path: Path portion of the URL (without query string)
  • url.scheme: URL scheme (defaults to "http")

Recommended Attributes

  • url.full: Full URL of the request
  • server.address: Server hostname (extracted from Host header)
  • server.port: Server port (extracted from Host header)
  • client.address: Client IP address (from remoteAddress option)
  • user_agent.original: User-Agent header value
  • network.protocol.version: HTTP protocol version (if available)

Conditionally Required Attributes

  • http.response.status_code: HTTP status code (set when response is received)
  • url.query: Query string portion of the URL (set when query parameters are present)
  • error.type: Error type/name for exceptions, or HTTP status code for 4xx/5xx responses

Why This Instrumentation?

Fastify's inject() method is used for:

  • Testing Fastify applications
  • Internal request routing (e.g., in Platformatic's thread-interceptor)
  • Simulating HTTP requests without network overhead

Since these requests bypass HTTP, standard HTTP instrumentation doesn't see them. This instrumentation fills that gap by patching light-my-request directly.

Compatibility

  • light-my-request: >=4.0.0
  • Node.js: >=20.0.0
  • @opentelemetry/api: ^1.0.0
  • Works with any OpenTelemetry-compatible TracerProvider

License

Apache-2.0