Skip to content

fix(opentelemetry): recreate tracer object after plugin metadata changed#13618

Open
shreemaan-abhishek wants to merge 1 commit into
apache:masterfrom
shreemaan-abhishek:fix/opentelemetry-recreate-tracer-on-metadata-change
Open

fix(opentelemetry): recreate tracer object after plugin metadata changed#13618
shreemaan-abhishek wants to merge 1 commit into
apache:masterfrom
shreemaan-abhishek:fix/opentelemetry-recreate-tracer-on-metadata-change

Conversation

@shreemaan-abhishek

Copy link
Copy Markdown
Contributor

Description

The opentelemetry plugin caches the tracer object per route via core.lrucache.plugin_ctx, but passed nil as the cache version key in _M.rewrite. The tracer bakes in everything sourced from plugin_metadata (collector address, request_timeout/request_headers, trace_id_source, sampler, and resource attributes). With a nil version key the cache entry is never invalidated, so after an operator updates the opentelemetry plugin_metadata at runtime (e.g. points to a new OTLP collector or flips trace_id_source), the worker keeps serving the stale cached tracer. Spans keep going to the old endpoint until the per-conf cache entry is evicted or the worker recycles.

This passes metadata.modifiedIndex as the lrucache version key so the tracer is rebuilt whenever the plugin_metadata changes. api_ctx.conf_version (the existing version) only tracks the route/service, not plugin_metadata, so a metadata-only change does not invalidate the entry on its own.

Fixes the stale-tracer behavior on plugin_metadata change.

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change (N/A, behavior-internal)
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant