Skip to content

Conversation

@MrAlias
Copy link
Contributor

@MrAlias MrAlias commented Sep 4, 2025

Follow guidelines and move instrumentation into its own type.

@MrAlias MrAlias added this to the v1.39.0 milestone Sep 4, 2025
@MrAlias MrAlias added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Sep 4, 2025
@codecov
Copy link

codecov bot commented Sep 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.9%. Comparing base (a07b7e6) to head (5416fc5).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #7307   +/-   ##
=====================================
  Coverage   82.9%   82.9%           
=====================================
  Files        266     267    +1     
  Lines      24984   24997   +13     
=====================================
+ Hits       20733   20744   +11     
- Misses      3876    3877    +1     
- Partials     375     376    +1     
Files with missing lines Coverage Δ
...out/stdouttrace/internal/observ/instrumentation.go 100.0% <100.0%> (ø)
exporters/stdout/stdouttrace/trace.go 73.8% <100.0%> (-17.7%) ⬇️

... and 2 files with indirect coverage changes

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

@MrAlias MrAlias force-pushed the encap-stdouttrace-obs branch from 477479b to 404e2ad Compare September 4, 2025 21:17
@MrAlias MrAlias marked this pull request as ready for review September 4, 2025 21:22
@flc1125 flc1125 requested a review from Copilot September 5, 2025 01:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the stdouttrace.Exporter self-observability instrumentation by moving it into an internal package following OpenTelemetry Go project guidelines. The change encapsulates the instrumentation logic into a dedicated type to improve code organization and maintainability.

  • Extracted self-observability logic into a new internal/observ package
  • Created a dedicated Instrumentation type to handle metrics and measurement
  • Removed extensive test cases from the main test file that are now covered by the internal package tests

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
versions.yaml Added version reference configuration for the stdouttrace module
exporters/stdout/stdouttrace/trace_test.go Simplified tests by using the new observ package constants and removed detailed test cases
exporters/stdout/stdouttrace/trace.go Refactored to use the new Instrumentation type from the observ package
exporters/stdout/stdouttrace/internal/version.go Added version constant for the internal package
exporters/stdout/stdouttrace/internal/observ/instrumentation_test.go New comprehensive test suite for the instrumentation functionality
exporters/stdout/stdouttrace/internal/observ/instrumentation.go New package containing the extracted instrumentation logic
.codespellignore Added "observ" to the spell check ignore list

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

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

👍

@MrAlias MrAlias merged commit 9b6585a into open-telemetry:main Sep 9, 2025
30 checks passed
@MrAlias MrAlias deleted the encap-stdouttrace-obs branch September 9, 2025 19:11
MrAlias added a commit that referenced this pull request Sep 18, 2025
fix #7013 

References: 

- [Follow
guidelines](https://github.com/open-telemetry/opentelemetry-go/blob/a5dcd68ebb2f3669f7685ac7b0f3f1624251a381/CONTRIBUTING.md#encapsulation).
- PR: #7307 

Implement following self-observability metrics from
https://github.com/open-telemetry/semantic-conventions/blob/v1.36.0/docs/otel/sdk-metrics.md
for https://pkg.go.dev/go.opentelemetry.io/otel/exporters/prometheus:

- otel.sdk.exporter.metric_data_point.inflight
- otel.sdk.exporter.metric_data_point.exported
- otel.sdk.exporter.operation.duration
- otel.sdk.metric_reader.collection.duration

### Benchmarks

```console
➜ benchstat /tmp/bench_disabled.txt /tmp/bench_enabled.txt
goos: darwin
goarch: arm64
pkg: go.opentelemetry.io/otel/exporters/prometheus/internal/observ
cpu: Apple M1 Max
                                           │ /tmp/bench_disabled.txt │       /tmp/bench_enabled.txt       │
                                           │         sec/op          │   sec/op     vs base               │
InstrumentationExportMetrics-10                          177.5n ± 0%   177.8n ± 0%  +0.14% (p=0.039 n=20)
InstrumentationRecordOperationDuration-10                246.6n ± 0%   246.7n ± 0%       ~ (p=0.606 n=20)
InstrumentationRecordCollectionDuration-10               246.8n ± 1%   247.2n ± 0%       ~ (p=0.456 n=20)
geomean                                                  221.1n        221.3n       +0.09%

                                           │ /tmp/bench_disabled.txt │       /tmp/bench_enabled.txt        │
                                           │          B/op           │    B/op     vs base                 │
InstrumentationExportMetrics-10                           256.0 ± 0%   256.0 ± 0%       ~ (p=1.000 n=20) ¹
InstrumentationRecordOperationDuration-10                 272.0 ± 0%   272.0 ± 0%       ~ (p=1.000 n=20) ¹
InstrumentationRecordCollectionDuration-10                272.0 ± 0%   272.0 ± 0%       ~ (p=1.000 n=20) ¹
geomean                                                   266.6        266.6       +0.00%
¹ all samples are equal

                                           │ /tmp/bench_disabled.txt │       /tmp/bench_enabled.txt        │
                                           │        allocs/op        │ allocs/op   vs base                 │
InstrumentationExportMetrics-10                           3.000 ± 0%   3.000 ± 0%       ~ (p=1.000 n=20) ¹
InstrumentationRecordOperationDuration-10                 3.000 ± 0%   3.000 ± 0%       ~ (p=1.000 n=20) ¹
InstrumentationRecordCollectionDuration-10                3.000 ± 0%   3.000 ± 0%       ~ (p=1.000 n=20) ¹
geomean                                                   3.000        3.000       +0.00%
¹ all samples are equal
```

---------

Co-authored-by: Flc゛ <[email protected]>
Co-authored-by: Tyler Yahn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Skip Changelog PRs that do not require a CHANGELOG.md entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants