Skip to content

Conversation

@gao-artur
Copy link
Contributor

Fixes #
Design discussion issue #

Changes

The HangfireInstrumentationJobFilterAttribute was trying to inject a default ActivityContext when there was no activity. This is not supported by the TraceContextPropagator and was leading to EventSource message

Failed to inject activity context in format: 'TraceContextPropagator', context: 'Invalid context'.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@github-actions github-actions bot added the comp:instrumentation.hangfire Things related to OpenTelemetry.Instrumentation.Hangfire label Aug 11, 2025
@codecov
Copy link

codecov bot commented Aug 11, 2025

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 69.70%. Comparing base (e5ebf34) to head (99a8dff).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ation/HangfireInstrumentationJobFilterAttribute.cs 75.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2990      +/-   ##
==========================================
- Coverage   69.79%   69.70%   -0.09%     
==========================================
  Files         386      388       +2     
  Lines       15917    15850      -67     
==========================================
- Hits        11109    11048      -61     
+ Misses       4808     4802       -6     
Flag Coverage Δ
unittests-Instrumentation.Hangfire 84.61% <75.00%> (-8.98%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ation/HangfireInstrumentationJobFilterAttribute.cs 77.77% <75.00%> (-12.97%) ⬇️

... and 13 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

using var tel = Sdk.CreateTracerProviderBuilder()
.AddHangfireInstrumentation()
.AddInMemoryExporter(exportedItems)
.SetSampler<AlwaysOnSampler>()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason, this test started to fail intermittently when I added a new test. I guess it's related to the static configuration in the HangfireFixture. Adding AlwaysOnSampler seems to fix/workaround it.

gao-artur and others added 3 commits August 11, 2025 17:32
…fireInstrumentationJobFilterAttribute.cs

Co-authored-by: Martin Costello <[email protected]>
…fireInstrumentationJobFilterAttribute.cs

Co-authored-by: Martin Costello <[email protected]>
@gao-artur gao-artur marked this pull request as ready for review August 11, 2025 14:36
@gao-artur gao-artur requested a review from a team as a code owner August 11, 2025 14:36
@Kielek Kielek changed the title Fix 'FailedToInjectActivityContext' when no ActivityContext exists [Instrumentation.Hangfire] Fix 'FailedToInjectActivityContext' when no ActivityContext exists Aug 18, 2025
@Kielek
Copy link
Member

Kielek commented Aug 18, 2025

@fred2u, FYI

@Kielek Kielek merged commit 7671c02 into open-telemetry:main Aug 18, 2025
63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:instrumentation.hangfire Things related to OpenTelemetry.Instrumentation.Hangfire

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants