Skip to content

Conversation

@gorbach
Copy link

@gorbach gorbach commented Oct 21, 2025

Fixes #2075

Changes

Adds OpenTelemetry metrics support to Hangfire instrumentation following workflow semantic conventions.

Implemented metrics:

  • workflow.execution.count - Counter for task executions
  • workflow.execution.duration - Histogram for execution duration
  • workflow.execution.status - UpDownCounter for state transitions
  • workflow.execution.errors - Counter for execution errors
  • hangfire.queue.latency - Optional histogram for queue wait time

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated
  • CHANGELOG.md updated
  • Changes in public API reviewed

@gorbach gorbach requested a review from a team as a code owner October 21, 2025 18:51
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 21, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: gorbach / name: Gorbach Oleksii (64514b8)

@github-actions github-actions bot requested a review from fred2u October 21, 2025 18:51
@github-actions github-actions bot added the comp:instrumentation.hangfire Things related to OpenTelemetry.Instrumentation.Hangfire label Oct 21, 2025
@gorbach gorbach force-pushed the feature/2075-hangfire-telemetry branch from 289b75d to 5655113 Compare October 21, 2025 19:55
Copy link
Contributor

@thompson-tomo thompson-tomo left a comment

Choose a reason for hiding this comment

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

Looks to be a good step forward and I have suggested a couple of changes here as well as to the sem conv based on the learnings.

@Kielek
Copy link
Member

Kielek commented Oct 22, 2025

@gorbach, please check this comment #2075 (comment)

The second point is technical requirements to separate metrics/traces signal. It will be great to rename classes in the separate PR and then merge it/rebase here.

@gorbach gorbach requested a review from thompson-tomo October 22, 2025 22:41
Implements OpenTelemetry workflow semantic conventions for Hangfire metrics.

Fixes open-telemetry#2075
…ve trigger.type to workflow-level metrics, add workflow.count
@gorbach gorbach force-pushed the feature/2075-hangfire-telemetry branch from dd6e74a to d43ee2c Compare October 22, 2025 22:42
Copy link
Contributor

@thompson-tomo thompson-tomo left a comment

Choose a reason for hiding this comment

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

Looking good. Only 1 design question #3258 (comment) which when resolved would mean I approve.

Copy link
Contributor

@thompson-tomo thompson-tomo left a comment

Choose a reason for hiding this comment

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

Have left a bunch of nits for things which could be improved/simplified.

gorbach and others added 9 commits October 26, 2025 08:45
…fireMetricsErrorFilterAttribute.cs

Co-authored-by: James Thompson <[email protected]>
…fireMetricsInstrumentation.cs

Co-authored-by: James Thompson <[email protected]>
…fireMetricsStateFilter.cs

Co-authored-by: James Thompson <[email protected]>
…fireMetricsStateFilter.cs

Co-authored-by: James Thompson <[email protected]>
…fireMetricsStateFilter.cs

Co-authored-by: James Thompson <[email protected]>
…fireMetricsErrorFilterAttribute.cs

Co-authored-by: James Thompson <[email protected]>
…fireMetricsStateFilter.cs

Co-authored-by: James Thompson <[email protected]>
@gorbach gorbach requested a review from thompson-tomo October 26, 2025 15:09
Copy link
Contributor

@thompson-tomo thompson-tomo left a comment

Choose a reason for hiding this comment

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

Looks good to me & thanks for adapting based on feedback.

@fred2u
Copy link
Contributor

fred2u commented Oct 27, 2025

Thanks for the contribution, don't forget to update the CHANGELOG.md

@gorbach
Copy link
Author

gorbach commented Oct 28, 2025

Thanks for the contribution, don't forget to update the CHANGELOG.md

Done, thanks!

@gorbach gorbach requested a review from Kielek October 28, 2025 20:15
@fred2u
Copy link
Contributor

fred2u commented Nov 4, 2025

@Kielek Is there still something blocking this PR?

@Kielek
Copy link
Member

Kielek commented Nov 4, 2025

@fred2u, I am not sure if there is any blocker. The metrics names suggests that all of them came from the opentelemetry-specification, but in fact, all of most of them are custom. Need to check with othet @open-telemetry/dotnet-contrib-approvers what to do with this PR.

For sure, in the same time, you can clean up public contract for spans/traces in the separate PR. It will be great to align to standard conventions from this repository: #2075 (comment)

@github-actions
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Nov 12, 2025
@Kielek Kielek removed the Stale label Nov 12, 2025
Copy link
Member

@Kielek Kielek left a comment

Choose a reason for hiding this comment

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

I think that you need put clear information, that you are providing metrics, but all of them are hangfire specific, and it will be subject to change if there occurs any recommendations from the semantic convetion. When the statement will be clear, I think that we should be fine to merge.

Do you have any plan to work towards this definition?


## Unreleased

* Add metrics instrumentation following workflow semantic conventions.
Copy link
Member

Choose a reason for hiding this comment

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

It is not true. There is nothing like workflow semantic convention.

Comment on lines +169 to +170
This instrumentation library collects metrics following the OpenTelemetry
[workflow semantic conventions](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/workflow/workflow-metrics.md).
Copy link
Member

Choose a reason for hiding this comment

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

Also here.

Copy link
Contributor

@thompson-tomo thompson-tomo left a comment

Choose a reason for hiding this comment

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

So the work to get these definitions into semconv is covered by open-telemetry/semantic-conventions#1688 with very recent interest from cicd sig to be involved, so hopefully this topic can now get traction.

I have added a comment on the readme with proposed text to make it clearer the signal definitions are subject to change.

Comment on lines +169 to +170
This instrumentation library collects metrics following the OpenTelemetry
[workflow semantic conventions](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/workflow/workflow-metrics.md).
Copy link
Contributor

Choose a reason for hiding this comment

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

Howabout something like

Suggested change
This instrumentation library collects metrics following the OpenTelemetry
[workflow semantic conventions](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/workflow/workflow-metrics.md).
This instrumentation library collects metrics following a POC/draft definition of workflow metrics defined as part of [semantic-conventions/#1688](https://github.com/open-telemetry/semantic-conventions/issues/1688).
As those definitions evolve, changes including breaking ones will flow back to this implementation.

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.

Support for metrics in OpenTelemetry.Instrumentation.Hangfire

4 participants