Skip to content

Use explicitly custom code snippet examples in otelecho#8381

Merged
dmathieu merged 5 commits intoopen-telemetry:mainfrom
eddyariki:dangerous-otelcho-example
Jan 13, 2026
Merged

Use explicitly custom code snippet examples in otelecho#8381
dmathieu merged 5 commits intoopen-telemetry:mainfrom
eddyariki:dangerous-otelcho-example

Conversation

@eddyariki
Copy link
Copy Markdown
Contributor

@eddyariki eddyariki commented Jan 10, 2026

Addresses #8373

  • Adds comment in echo_test.go to explicitly recommend avoiding using high-cardinality attributes
  • Replaces custom metrics example in WithMetricAttributeFn and WithEchoMetricAttributeFn with safer examples.
  • Showcases behavior with duplicate metrics as well.

Note:

  • Most standard metrics for http.Request and echo context are already added as attributes in the middleware, so I went with a more custom metric for the sake of high-lighting potential use-cases.
  • I checked other code snippets and only found echo_test.go's dangerous pattern in their tests. I believe there are no other dangerous patterns in the core packages and instrumentation libraries.

@eddyariki eddyariki requested review from a team and flc1125 as code owners January 10, 2026 00:52
@dmathieu dmathieu changed the title Replace dangerous code snippet examples in otelecho Use explicitly custom code snippet examples in otelecho Jan 10, 2026
@dmathieu dmathieu added the Skip Changelog Allow PR to succeed without requiring an addition to the CHANGELOG label Jan 10, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.3%. Comparing base (4726bd3) to head (9fe7867).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #8381   +/-   ##
=====================================
  Coverage   82.3%   82.3%           
=====================================
  Files        182     182           
  Lines      13764   13764           
=====================================
  Hits       11329   11329           
  Misses      2030    2030           
  Partials     405     405           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@flc1125 flc1125 left a comment

Choose a reason for hiding this comment

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

There's nothing wrong with it overall.

Comment thread instrumentation/github.com/labstack/echo/otelecho/example_test.go Outdated
Comment thread instrumentation/github.com/labstack/echo/otelecho/example_test.go Outdated
@flc1125 flc1125 linked an issue Jan 10, 2026 that may be closed by this pull request
@dmathieu dmathieu merged commit 6e187c4 into open-telemetry:main Jan 13, 2026
28 checks passed
@MrAlias MrAlias added this to the v1.40.0 milestone Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Skip Changelog Allow PR to succeed without requiring an addition to the CHANGELOG

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Dangerous metric labeling practices in example

4 participants