Skip to content

OpenTelemetry instrumentation for xUnit tests #18230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 13, 2025
Merged

Conversation

majocha
Copy link
Contributor

@majocha majocha commented Jan 12, 2025

Some tests were already instrumented ad-hoc.
This applies the instrumentation to the whole test assembly instead, so no additional work is needed to capture any test case.
Also replace deprecated Jaeger package.
It seems to work locally, at least with the net9.0 target.
Traces can be inspected in Jager all-in-one. If nothing interesting is produced, at least the test case name and duration is captured.

Copy link
Contributor

✅ No release notes required

@majocha majocha marked this pull request as ready for review January 13, 2025 14:30
@majocha majocha requested a review from a team as a code owner January 13, 2025 14:30
@majocha
Copy link
Contributor Author

majocha commented Jan 13, 2025

Locally I don't see any significant performance penalty for enabling this.
Desktop target unfortunately does not work, but there are some changes coming with OTel 1.11.0 version, currently in RC that may fix it.

Copy link
Member

@psfinaki psfinaki left a comment

Choose a reason for hiding this comment

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

That's cool, thank you!

@psfinaki psfinaki merged commit dfffae6 into dotnet:main Jan 13, 2025
33 checks passed
@@ -139,9 +146,24 @@ type FSharpXunitFramework(sink: IMessageSink) =
log "FSharpXunitFramework with XUNIT_EXTRAS installing TestConsole redirection"
TestConsole.install()

// TODO: Currently does not work with Desktop .NET Framework. Upcoming OpenTelemetry 1.11.0 may change it.
Copy link
Member

Choose a reason for hiding this comment

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

out of curiosity, what makes you think 1.11 will enable .NET Framework support for OTel? I don't see anything in the release notes or changelog to suggest that.

Copy link
Member

Choose a reason for hiding this comment

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

Is it this new builder pattern?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They say they're dropping the quasi-deprecated gRpc.Core. When I tried it here, grpc just fails silently (exception can be observed in debug mode) during runtime on desktop target.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

May be wishful thinking on my part, though!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just did a quick test with console app. Otel 1.9.0 does work in general with net472, just not here in this repo, for some reason.

@majocha majocha deleted the tests-otel branch January 13, 2025 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants