Skip to content

Add tracetest example for testing instrumentation#7107

Merged
pellared merged 2 commits intoopen-telemetry:mainfrom
adity1raut:main
Sep 1, 2025
Merged

Add tracetest example for testing instrumentation#7107
pellared merged 2 commits intoopen-telemetry:mainfrom
adity1raut:main

Conversation

@adity1raut
Copy link
Copy Markdown
Contributor

Fixes #7051

This PR adds a basic example demonstrating how to test tracing instrumentation using the tracetest.SpanRecorder from the OpenTelemetry SDK.

✅ It ensures:

A span is emitted when a function is instrumented
The span name is as expected
Inspired by:

logtest package example

Signed-off-by: adity1raut <araut7798@gmail.com>
@flc1125
Copy link
Copy Markdown
Member

flc1125 commented Jul 31, 2025

Can you also add an example based on InMemoryExporter (it's fine to do it as another PR)?

@flc1125
Copy link
Copy Markdown
Member

flc1125 commented Jul 31, 2025

Please add a CHANGELOG.

@flc1125
Copy link
Copy Markdown
Member

flc1125 commented Jul 31, 2025

As two additional supplements (currently under discussion):

  • Do we need to provide examples in the form of *testing.T.
  • Is it necessary to supplement examples for scenarios such as: SetAttributes, AddEvent, etc.

cc @pellared

@dmathieu dmathieu added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Jul 31, 2025
@dmathieu
Copy link
Copy Markdown
Member

Please add a CHANGELOG.

Please don't. This is not a user-facing change.
Also, this is the third PR for this change. Let's keep things simple and not expand the goal.

@pellared
Copy link
Copy Markdown
Member

This is not a user-facing change.

It is kind of user-facing (public docs).
See: #7074 (comment)

But I am also fine not adding a changelog entry for it.

@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 1, 2025

Codecov Report

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

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #7107   +/-   ##
=====================================
  Coverage   82.9%   82.9%           
=====================================
  Files        265     265           
  Lines      24894   24894           
=====================================
+ Hits       20644   20645    +1     
+ Misses      3875    3874    -1     
  Partials     375     375           

see 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.

@pellared pellared merged commit 5e3b939 into open-telemetry:main Sep 1, 2025
31 checks passed
@MrAlias MrAlias added this to the v1.39.0 milestone Oct 14, 2025
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.

tracetest: Add package example

5 participants