exporter/otlploghttp: guard observ metrics with Enabled checks#7813
Conversation
|
Hey, I wante to ask you check this but what if something changes in between time start (sorry i was wrong i was using your code as refrence to understand what the changes were ) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7813 +/- ##
=======================================
- Coverage 81.7% 81.6% -0.1%
=======================================
Files 304 304
Lines 23265 23277 +12
=======================================
+ Hits 19013 19016 +3
- Misses 3861 3862 +1
- Partials 391 399 +8
🚀 New features to boost your workflow:
|
|
Could you add tests? |
|
Hi. I can add tests. Do you expect separate cases (drop inflight/exported/duration, plus “all dropped”), or is one view-based test enough to show that when an instrument is disabled we skip it and ExportLogs().End() still records the remaining metrics? |
|
I think one test with subtests for each metric would be good. |
|
Don't trust what the LLM says. Your test needs to fail before your changes, and pass after. |
…ents are not called.
|
How would this be tested? Enabled is a performance improvement to avoid computing attributes when we know in advance the metric will be dropped. Using enabled or not shouldn't be a behavioral change, right? |
|
Might be able to demonstrate it with a benchmark when a no-op meterprovider is used? |
|
I added a unit test because another reviewer asked for tests. it basically just verifies we don’t call Add/Record when an instrument reports Enabled(ctx)==false. If you’d prefer, I can drop the unit test and add a benchmark instead since this is mainly a perf improvement. What would you rather have? |
|
Nice. I didn't think of that, and that works for me. |
|
Awesome, thanks! I’ll fix the remaining lint issues and update the PR. |
This PR updates the OTLP HTTP log exporter observability instrumentation to check instrument Enabled(ctx) before building options/attributes and recording measurements.
Behavior is unchanged when metrics are enabled; this reduces overhead when exporter self-metrics are disabled/no-op.
Part of the work tracked in #7800.