Skip to content

Conversation

@eduardoboucas
Copy link
Member

This is a bundle of changes to the netlify/otel package to make it more flexible in different environments:

  1. Breaking: We stop looking for the x-nf-enable-tracing header and returning a no-op when it's present. I believe this should be a concern of the consumer, because we might want to use tracing in a context where HTTP headers don't even make sense.

  2. Introduce spanProcessors property: We currently expose an extraSpanProcessors property which lets consumers add span processors on top of the default one (which outputs a JSON with the system log prefix). In some contexts, we might want to skip system logs entirely and just have a custom span processor in place. This is not currently possible. So I've introduced a new spanProcessors property which is similar to extraSpanProcessors except it does not include the base processor. I'm not in love with this approach, but couldn't find a better one. I'm open to suggestions.

  3. Export several OpenTelemetry types: When building a custom exporter, it's useful to be able to import things like SimpleSpanProcessor from this module as opposed to having to install @opentelemetry/sdk-trace-node in the consumer and ensure the version matches the one from @netlify/otel.

@eduardoboucas eduardoboucas requested a review from a team as a code owner September 23, 2025 08:53
@eduardoboucas eduardoboucas enabled auto-merge (squash) September 23, 2025 10:11
@eduardoboucas eduardoboucas requested a review from pieh September 23, 2025 10:15
Copy link
Contributor

@pieh pieh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, left some NIT comments for you to consider, but I'm also fine with things as-is

'netlify.site.name': options.siteName,
})

const spanProcessors = await Promise.all(options.spanProcessors ?? [await getBaseSpanProcessor()])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not requesting a change here, but just noting that we could skip default fallback and always demand consumer to configure things explicitly which might make it easier to understand what is being configured when checking consumers and not need to be aware there that this is a default.

Will leave decision up to you on this.

})
}

export const getBaseSpanProcessor = async (): Promise<SpanProcessor> => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is "base span processor" because of "legacy" behavior, but given the whole changes here are because some usage won't rely on it - then this no longer is a "base" one? Maybe naming could be more explicit about application of it - like getSystemLogJsonSpanProcessor or something like that.

Not a blocker, will leave decision up to you on this.

@eduardoboucas eduardoboucas merged commit 039f955 into main Sep 23, 2025
22 of 24 checks passed
@eduardoboucas eduardoboucas deleted the feat/otel-changes branch September 23, 2025 10:19
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.

3 participants