dotnet / dotnet/runtime

MeterListener for http.client.open_connections

Open
#133,895 4 comments 0 reactions 0 assignees View on GitHub
area-System.Net.Http untriaged
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

### Description

I have updated to .NET 11 RC1 (from the previous preview version), and what I notice is that when I listen to the instrument `http.client.open_connections` a send HTTP requests as before:

```csharp
var httpListener = new MeterListener();
httpListener.InstrumentPublished = (instrument, listener) =>
{
if (instrument.Name == "http.client.open_connections")
{
_tcs = new(TaskCreationOptions.RunContinuationsAsynchronously);
_instrument = instrument;
listener.EnableMeasurementEvents(instrument);
}
};
httpListener.SetMeasurementEventCallback(OnMeasurementRecorded);
httpListener.Start();
```

and the callback:

```csharp
private void OnMeasurementRecorded(
Instrument instrument,
T measurement,
ReadOnlySpan> tags,
object? state) { ... }
```

Then the callback isn't invoked. However, the EnableMeasurementEvents is invoked surely, so the instrument exists.

### Reproduction Steps

See as above

### Expected behavior

The callback invoked.

### Actual behavior

Callback not invoked.

### Regression?

Yes

### Known Workarounds

no

### Configuration

```
dotnet --info
.NET SDK:
Version: 11.0.100-rc.1.26425.128
Commit: 3551975be0
Workload version: 11.0.100-manifests.a6e318ce
MSBuild version: 18.11.0-1.26425.128+3551975be

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26200
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\11.0.100-rc.1.26425.128

.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.

Host:
Version: 11.0.0-rc.1.26425.128
Architecture: x64
Commit: 3551975be0

.NET SDKs installed:
10.0.401 [C:\Program Files\dotnet\sdk]
11.0.100-rc.1.26425.128 [C:\Program Files\dotnet\sdk]
```

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by running the provided C# reproduction with .NET 11 RC1 and inspect the MeterListener flow through InstrumentPublished and EnableMeasurementEvents for http.client.open_connections. Trace why OnMeasurementRecorded is not reached despite the instrument being enabled. Done means the measurement callback is invoked when HTTP requests are sent.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking, observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.