Skip to content

Add @netlify/otel affordances #363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 24, 2025
Merged

Add @netlify/otel affordances #363

merged 8 commits into from
Jul 24, 2025

Conversation

chee
Copy link
Contributor

@chee chee commented Jul 18, 2025

instrumentations and spanProcessors

Hooks into the initialization, to be able to set the instrumentations and span processors that will be used by the tracer. I expect to write our own instrumentations that will be exported as extra entrypoints from this package, and for consuming applications to be able to pick and choose their faves.

I've added extraSpanProcessers to make it easier to pop a local trace exporter to otel-desktop-viewer or the like when debugging in repos that depend on @netlify/otel.

withActiveSpan(getTracer(), name, (span?) => {}) convenience function

A more ergonomic API than having to repeat yourself, writing the function in one place and then conditionally calling it inside or outside a loop depending on if you got a tracer. The callback gets Span|undefined as its arg so you can know if you're running in a trace.

I expect this to a temporary measure, that will be less necessary when we can load OpenTelemetry all the time and swap out for the NoopSpanProcessor when the header is absent.

@chee chee changed the title Allow consumer to specify instrumentations and span processors Add default http, fetch and undici instrumentations Jul 18, 2025
@chee chee force-pushed the otelmewhatyouwant branch from 2fa2eee to dbc5809 Compare July 18, 2025 11:35
Some default instrumentations are included:
- https://www.npmjs.com/package/@opentelemetry/instrumentation-http
- https://www.npmjs.com/package/@opentelemetry/instrumentation-fetch
- https://www.npmjs.com/package/@opentelemetry/instrumentation-undici

The http and undici instrumentations are in devDependencies because their
packages include non-esm code that made the serverless-functions-api repo
cry when i tried to use them there. lmk if there's a better way to go about
this
@chee chee force-pushed the otelmewhatyouwant branch from dbc5809 to c18a983 Compare July 18, 2025 11:44
@chee chee changed the title Add default http, fetch and undici instrumentations Add default http, net, fetch and undici instrumentations Jul 18, 2025
@chee chee changed the title Add default http, net, fetch and undici instrumentations Add @netlify/otel affordances Jul 18, 2025
@chee chee marked this pull request as ready for review July 22, 2025 12:27
@chee chee requested a review from a team as a code owner July 22, 2025 12:27
@chee chee marked this pull request as draft July 22, 2025 12:27
@chee chee marked this pull request as ready for review July 22, 2025 12:31
@chee chee force-pushed the otelmewhatyouwant branch from 9510070 to 974b534 Compare July 22, 2025 12:34
@chee chee marked this pull request as draft July 22, 2025 12:34
@chee chee marked this pull request as ready for review July 23, 2025 18:05
@chee chee enabled auto-merge (squash) July 24, 2025 13:14
@chee chee merged commit 50fae00 into main Jul 24, 2025
17 checks passed
@chee chee deleted the otelmewhatyouwant branch July 24, 2025 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants