Skip to content

Conversation

Horiodino
Copy link

Summary

This PR adds self-observability metrics to the stdoutlog exporter

These metrics are enabled when the environment variable OTEL_GO_X_SELF_OBSERVABILITY is set to "true"

What's Added

  • Support for:

    • otel.sdk.exporter.log.inflight
    • otel.sdk.exporter.log.exported
    • otel.sdk.exporter.operation.duration

Related Issue

Closes #7020

@dashpole
Copy link
Contributor

dashpole commented Aug 8, 2025

We should follow the existing convention for including experimental features in an internal/x directory. You can follow the example in https://github.com/open-telemetry/opentelemetry-go/pull/7133/files#diff-0dd3a4492039e9f0aa24246db2fe468b32e1285411c2625fabafb53f9d64d07eR68

Copy link

codecov bot commented Aug 11, 2025

Codecov Report

❌ Patch coverage is 82.35294% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.9%. Comparing base (c09be18) to head (8835529).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
exporters/stdout/stdoutlog/exporter.go 76.6% 11 Missing and 7 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #7145     +/-   ##
=======================================
- Coverage   82.9%   82.9%   -0.1%     
=======================================
  Files        264     265      +1     
  Lines      24628   24730    +102     
=======================================
+ Hits       20425   20505     +80     
- Misses      3820    3835     +15     
- Partials     383     390      +7     
Files with missing lines Coverage Δ
exporters/stdout/stdoutlog/config.go 100.0% <ø> (ø)
exporters/stdout/stdoutlog/internal/x/x.go 100.0% <100.0%> (ø)
exporters/stdout/stdoutlog/exporter.go 80.9% <76.6%> (-10.0%) ⬇️

... and 3 files with indirect coverage changes

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

@pellared
Copy link
Member

pellared commented Aug 11, 2025

I have currently time to review this PR, but I can at least recommend looking at #7133 (that is already merged) and use similar patterns where appropriate.

@Horiodino Horiodino force-pushed the stdoutlog_exporter_metrics branch from caad2dd to 14d1c03 Compare August 13, 2025 13:18
@flc1125
Copy link
Member

flc1125 commented Aug 14, 2025

We are missing a CHANGELOG.

We can run make lint for lint checks and make test for unit tests, which helps address some basic issues before review.

Signed-off-by: Praful <holiodin@gmail.com>
Signed-off-by: Praful <holiodin@gmail.com>
…internal/x

Signed-off-by: Praful <holiodin@gmail.com>
Signed-off-by: Praful <holiodin@gmail.com>

follow existing convention for including experimental features in an internal/x

Signed-off-by: Praful <holiodin@gmail.com>
Signed-off-by: Praful <holiodin@gmail.com>
@Horiodino Horiodino force-pushed the stdoutlog_exporter_metrics branch from 14d1c03 to f54728a Compare August 14, 2025 13:51
Signed-off-by: Praful <holiodin@gmail.com>

fix: resolve linter err

Signed-off-by: Praful <holiodin@gmail.com>
@Horiodino Horiodino force-pushed the stdoutlog_exporter_metrics branch from f54728a to 8835529 Compare August 14, 2025 14:44
…servability

Signed-off-by: Praful <holiodin@gmail.com>

refactor: test case from TestSelfObservability to TestNewSelfObservability

Signed-off-by: Praful <holiodin@gmail.com>
e.selfObservability.operationDurationMetric.Record(ctx, time.Since(start).Seconds(), addAttrs...)

*bufPtr = addAttrs[:0]
selfObservabilityBuffer.Put(bufPtr)
Copy link
Contributor

@MrAlias MrAlias Aug 16, 2025

Choose a reason for hiding this comment

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

This needs to be defered right after the Get to ensure it will always be returned to the pool.

Copy link
Author

Choose a reason for hiding this comment

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

i’m not sure what you mean , the entire thing is deferred.

if err != nil {
addAttrs = append(addAttrs, semconv.ErrorType(err))
} else {
e.selfObservability.exportedMetric.Add(ctx, count, addAttrs...)
Copy link
Contributor

Choose a reason for hiding this comment

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

This only adds success metrics for exported count, and it only does so when there are no errors. This does not add counts for errored exports and it does not support partial successes.

For example, if the export is successfully able to export 4 records and fails on 2, this instrument needs to record both 4 and 2 with the appropriate attributes, if it fails all 6 it needs to record all 6 as errored, and if it succeeds for a 6 then 6 needs to be recorded without any error attribute.

…rvability

Signed-off-by: Praful <holiodin@gmail.com>
@Horiodino Horiodino requested a review from MrAlias August 24, 2025 11:11
@pellared
Copy link
Member

pellared commented Sep 1, 2025

@Horiodino PTAL #7272

@flc1125
Copy link
Member

flc1125 commented Sep 11, 2025

Hi, since this process involves specification adjustments and historical review records (which may contain invalid review suggestions), it’s impossible to tell which items need attention amid the large volume of information.

Could we create a new PR based on the current branch before preparing for the review, so that subsequent reviews can proceed more smoothly?

Thanks~

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.

Logs SDK observability - stdoutlog exporter metrics

5 participants