Skip to content

Return noop TracerProvider when no trace processors are defined#15186

Merged
codeboten merged 13 commits into
open-telemetry:mainfrom
hxiao87:noop-trace
May 7, 2026
Merged

Return noop TracerProvider when no trace processors are defined#15186
codeboten merged 13 commits into
open-telemetry:mainfrom
hxiao87:noop-trace

Conversation

@hxiao87

@hxiao87 hxiao87 commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Description

Returns noop TracerProvider when no processors are defined such that this scenarios is treats the same as when LevelNone is set.

Link to tracking issue

Fixes #15135

Testing

  • Updated existing tests in trace_test.go to make sure there's no behavior change
  • Added TestCreateTracerProvider_NoProcessors to verify that the default config (level=Basic,
    no processors) returns a noop provider

Documentation

Didn't find any relevant doc that needs update.

@codecov

codecov Bot commented Apr 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.23%. Comparing base (5a2da78) to head (97f9c64).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15186   +/-   ##
=======================================
  Coverage   91.23%   91.23%           
=======================================
  Files         701      701           
  Lines       45838    45838           
=======================================
  Hits        41822    41822           
  Misses       2816     2816           
  Partials     1200     1200           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hxiao87 hxiao87 changed the title Noop trace by default Return noop TracerProvider when no trace processors are defined Apr 27, 2026
@hxiao87
hxiao87 marked this pull request as ready for review April 27, 2026 21:55
@hxiao87
hxiao87 requested a review from a team as a code owner April 27, 2026 21:55
@hxiao87
hxiao87 requested a review from axw April 27, 2026 21:55
@axw
axw marked this pull request as draft April 28, 2026 04:47
@axw

axw commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

@hxiao87 thanks for the PR. Tests are failing - please fix those and mark this ready for review when you have everything passing.

@hxiao87

hxiao87 commented Apr 29, 2026

Copy link
Copy Markdown
Contributor Author

@hxiao87 thanks for the PR. Tests are failing - please fix those and mark this ready for review when you have everything passing.

Hi Andrew, thanks for reviewing! I have run the tests locally and confirmed they'd pass. Looks like an approval is needed to kick off the CI, so I'll just open the PR again. While addressing the CI failures from the MissingResource test, I figuredcreateTracerProvider (and similarly createMeterProvider) would also panic if called with MigratedFromV02 = true and a similar test setup. I guess in practice this shouldn't happen since the factory always provides a Logger, but let me know if you feel like a guard could be beneficial and I can make a follow-up change.

@hxiao87
hxiao87 marked this pull request as ready for review April 29, 2026 02:26
@axw

axw commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

I figured createTracerProvider (and similarly createMeterProvider) would also panic if called with MigratedFromV02 = true and a similar test setup. I guess in practice this shouldn't happen since the factory always provides a Logger, but let me know if you feel like a guard could be beneficial and I can make a follow-up change.

Yeah that won't happen in practice, a logger will always be provided in a real collector. We could make the test more realistic by passing in a logger (probably a no-op logger), but your change is fine for now.

@codspeed-hq

codspeed-hq Bot commented Apr 29, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 7 untouched benchmarks
⏩ 76 skipped benchmarks1


Comparing hxiao87:noop-trace (97f9c64) with main (5a2da78)

Open in CodSpeed

Footnotes

  1. 76 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@axw

axw commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

The spell-check failure doesn't appear to be related to this branch. Should be good to merge

@axw axw added the ready-to-merge Code review completed; ready to merge by maintainers label Apr 29, 2026
Comment thread .chloggen/noop-trace-no-processors.yaml Outdated
return nil, err
}

if cfg.Traces.Level == configtelemetry.LevelNone || len(cfg.Traces.Processors) == 0 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a reason to move this if-clause after createFixedResourceConfig()? cfg.Traces.Level and cfg.Traces.Processors shouldn't be changed by createFixedResourceConfig() - are they?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, createFixedResourceConfig doesn't modify those fields. With the existing order, this test panics as it passes an empty TracerSettings{} (w/ nil Logger) with no processors - thus moving the resource validation to the front.

Co-authored-by: Florian Lehner <florianl@users.noreply.github.com>
@mx-psi
mx-psi requested a review from florianl April 30, 2026 11:00
@mx-psi mx-psi removed the ready-to-merge Code review completed; ready to merge by maintainers label Apr 30, 2026
@codeboten
codeboten enabled auto-merge May 6, 2026 16:32
@songy23 songy23 added the ready-to-merge Code review completed; ready to merge by maintainers label May 7, 2026
@codeboten
codeboten added this pull request to the merge queue May 7, 2026
Merged via the queue into open-telemetry:main with commit 8a98677 May 7, 2026
68 of 72 checks passed
@otelbot

otelbot Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution @hxiao87! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

swiatekm pushed a commit to swiatekm/opentelemetry-collector that referenced this pull request May 15, 2026
…-telemetry#15186)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Returns noop TracerProvider when no processors are defined such that
this scenarios is treats the same as when `LevelNone` is set.

<!-- Issue number if applicable -->
#### Link to tracking issue
Fixes open-telemetry#15135

<!--Describe what testing was performed and which tests were added.-->
#### Testing
- Updated existing tests in `trace_test.go` to make sure there's no
behavior change
- Added `TestCreateTracerProvider_NoProcessors` to verify that the
default config (level=Basic,
  no processors) returns a noop provider

<!--Describe the documentation added.-->
#### Documentation
Didn't find any relevant doc that needs update.
<!--Please delete paragraphs that you did not use before submitting.-->

---------

Co-authored-by: Florian Lehner <florianl@users.noreply.github.com>
Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Code review completed; ready to merge by maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[service/telemetry/otelconftelemetry] traces should be no-op by default

6 participants