Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gas-buddy/opentelemetry-instrumentation-fetch-node
OpenTelemetry Node 18+ native fetch automatic instrumentation package
https://github.com/gas-buddy/opentelemetry-instrumentation-fetch-node
Last synced: 3 months ago
JSON representation
OpenTelemetry Node 18+ native fetch automatic instrumentation package
- Host: GitHub
- URL: https://github.com/gas-buddy/opentelemetry-instrumentation-fetch-node
- Owner: gas-buddy
- License: mit
- Created: 2022-10-20T01:46:18.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-30T13:26:21.000Z (4 months ago)
- Last Synced: 2024-07-30T14:32:36.520Z (4 months ago)
- Language: TypeScript
- Size: 1.34 MB
- Stars: 15
- Watchers: 3
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# opentelemetry-instrumentation-fetch-node
[![TypeScript](https://badges.frapsoft.com/typescript/code/typescript.png?v=101)](https://github.com/ellerbrock/typescript-badges/)
![main CI](https://github.com/gas-buddy/opentelemetry-instrumentation-fetch-node/actions/workflows/nodejs.yml/badge.svg)
[![npm version](https://badge.fury.io/js/@gasbuddy%2Fopentelemetry-instrumentation-fetch-node.svg)](https://badge.fury.io/js/opentelemetry-instrumentation-fetch-node)
OpenTelemetry Node 18+ native fetch automatic instrumentation package.
Existing instrumentation packages (like [@opentelemetry/instrumentation-http](https://www.npmjs.com/package/@opentelemetry/instrumentation-http)) do not work with Node 18+ native fetch, which is based on the [undici module](https://undici.nodejs.org/#/) but packaged in a "strange" way (some sort of internal bundle that I don't really understand). This module uses the new Node diagnostics channel to instrument native fetch.
Note that due to the fact that fetch is lazy loaded in Node, this module will kick off a "phony" fetch
to an unparseable URL (blank string) to get the library to load so we don't miss any events (because the
diagnostics channel would not yet exist).See the tests for an example setup - note the onRequest event that allows you to add outbound headers or
span attributes or what have you.