[API Proposal]: Gauge metric creation should support async callback signature
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 45/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- csharp
- Domain
- api, backend-api-design
Research direction
Start with the linked Meter.CreateObservableGauge API documentation and compare the existing overload signatures with the proposed async callback shape. Then review the runtime's API design and validation conventions to determine the complete overload set and callback contract. Done means the async API design is agreed, implemented, and validated against the relevant API and behavior tests.
Written by the indexing model from the issue text.
Description
Background and motivation
System.Diagnostics.Metrics.Meter exposes the set of CreateObservableGauge overloads, but none of them allow for safe and efficient use of threads in the callback implementation. I.e. given that most of modern IO APIs are starting to ship exclusively with Async APIs (returning Task or similar), acquiring the value for the gauge metric will mean blocking the thread in order to conform to the sync callback signature.
API Proposal
Add the overloads to support async signatures, for example:
CreateObservableGauge<T>(String, Func<Task<Measurement<T>>>, String, String, IEnumerable<KeyValuePair<String,Object>>)
API Usage
meter.CreateObservableGauge<int>("name", MyTaskReturingFunction)
Alternative Designs
Alternatives, like separating the acquisition of the metric value from the callback impl would complicate and potentially defeat the purpose of having the configurable framework that already has an internal scheduler.
Risks
No response
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 589
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/runtime
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
area-System.Reflection blocking-clean-ci-optional Known Build Error os-mac-os-x untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
area-CodeGen-coreclr untriaged
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
agentic-workflows untriaged
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
area-VM-meta-mono untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Similar issues
-
bug documentation frontend
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
azurenoops/spin_agent#975 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100