Skip to content

[OTLP/Prometheus] Fix resource caching during metric exporter startup - #7984

Merged
Kielek merged 3 commits into
open-telemetry:mainfrom
Kielek:codex/fix-ant-2026-fm1o0gub
Oct 20, 2026
Merged

Kielek merged 3 commits into
open-telemetry:mainfrom
Kielek:codex/fix-ant-2026-fm1o0gub

Conversation

@Kielek

@Kielek Kielek commented Oct 20, 2026

Copy link
Copy Markdown
Member

This fix addresses a ANT-2026-FM1O0GUB finding from Anthropic's OSS Scanner.
Project enrollment: anthropics/oss-scanner#117.

Changes

An HttpListener scrape during MeterProvider construction could permanently
remove target_info and configured resource constant labels from later
responses. A periodic OTLP metric collection during construction could likewise
permanently omit resource attributes from later exports.

Cache exporter resources and Prometheus resource constant labels only after
the provider is attached. Add deterministic regression coverage for a scrape
inside a resource detector and for actual OTLP payloads after an early collection,
including a control without the early collection. No public API changes.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, successful build/tests, etc.)
  • Tests added/updated
  • CHANGELOG.md file(s) updated for non-trivial changes
  • Changes in public API reviewed (if applicable)
  • AI usage disclosure:
    • No AI used
    • AI-assisted
    • Bulk AI-generated
  • I have the experience and knowledge necessary to understand, review, and validate all content in this PR1

Note

This PR description was generated with OpenAI Codex.

Footnotes

  1. Yes, I can answer maintainer questions about the content of this PR without using AI. ↩

Defer caching exporter resources and Prometheus constant labels until the
MeterProvider is attached, preserving resource metadata after early collections.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-FM1O0GUB.
@github-actions github-actions Bot added pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package pkg:OpenTelemetry.Exporter.Prometheus.HttpListener Issues related to OpenTelemetry.Exporter.Prometheus.HttpListener NuGet package labels Oct 20, 2026
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Merged · refreshed 2026-10-20 07:40 UTC

Status above doesn't look right?
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.21%. Comparing base (4540417) to head (0b0481d).
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #7984   +/-   ##
=======================================
  Coverage   90.21%   90.21%           
=======================================
  Files         366      366           
  Lines       21496    21500    +4     
  Branches     3949     3951    +2     
=======================================
+ Hits        19392    19396    +4     
  Misses       1526     1526           
  Partials      578      578           
Flag Coverage Δ
unittests-Project-Experimental 90.22% <100.00%> (-0.03%) ⬇️
unittests-Project-Stable 90.25% <100.00%> (+0.01%) ⬆️
unittests-UnstableCoreLibraries-Experimental 42.09% <100.00%> (+0.22%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...porter.OpenTelemetryProtocol/OtlpMetricExporter.cs 93.75% <100.00%> (+0.20%) ⬆️
...ner/Internal/Shared/PrometheusCollectionManager.cs 85.77% <100.00%> (ø)
...HttpListener/Internal/Shared/PrometheusExporter.cs 100.00% <100.00%> (ø)

@github-actions github-actions Bot added the pkg:OpenTelemetry.Exporter.Prometheus.AspNetCore Issues related to OpenTelemetry.Exporter.Prometheus.AspNetCore NuGet package label Oct 20, 2026
@Kielek Kielek changed the title Fix resource caching during metric exporter startup [OTLP/Prometheus] Fix resource caching during metric exporter startup Oct 20, 2026
@Kielek
Kielek marked this pull request as ready for review October 20, 2026 06:42
@Kielek
Kielek requested a review from a team as a code owner October 20, 2026 06:42
Use the existing Verify convention for the HttpListener startup regression,
preserving the complete expected scrape output in a verified snapshot.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-FM1O0GUB.
This was referenced Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package pkg:OpenTelemetry.Exporter.Prometheus.AspNetCore Issues related to OpenTelemetry.Exporter.Prometheus.AspNetCore NuGet package pkg:OpenTelemetry.Exporter.Prometheus.HttpListener Issues related to OpenTelemetry.Exporter.Prometheus.HttpListener NuGet package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants