Skip to content
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

Meters are not collected if Native AOT compilation is turned on #111801

Open
bsdayo opened this issue Jan 24, 2025 · 0 comments
Open

Meters are not collected if Native AOT compilation is turned on #111801

bsdayo opened this issue Jan 24, 2025 · 0 comments
Labels
area-System.Diagnostics.Metric untriaged New issue has not been triaged by the area owner

Comments

@bsdayo
Copy link

bsdayo commented Jan 24, 2025

Description

System.Diagnostics.Metrics.Meter related instruments (Counters etc.) are not collected when <PublishAot>true</PublihAot>

Reproduction Steps

Create a new console project targeting net9.0.

<!-- TestCounters.csproj -->

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net9.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
        <PublishAot>true</PublishAot>
        <InvariantGlobalization>true</InvariantGlobalization>
    </PropertyGroup>

</Project>
// Program.cs

using System.Diagnostics.Metrics;

var meter = new Meter("Test", "1.0.0");
var counter = meter.CreateCounter<int>("test.counter");

while (true)
{
    counter.Add(4);
    Thread.Sleep(1000);
}

Start dotnet-counters with the following command:

dotnet-counters monitor -n TestCounters --counters Test

Output:

Press p to pause, r to resume, q to quit.
    Status: Waiting for initial payload...

Name                                                                                                       Current Value

As shown, no meter data is collected.

If I comment out <PublishAot>true</PublishAot> is csproj, the data is collected without any issue:

Press p to pause, r to resume, q to quit.
    Status: Running

Name                                                                                                       Current Value
[Test]
    test.counter (Count)                                                                                          12

Expected behavior

Meters data is collected in Native AOT compilation.

Actual behavior

Meters data is not collected in Native AOT compilation.

Regression?

Targeting net8.0 produces the same problem.

Known Workarounds

No response

Configuration

.NET SDK:
 Version:           9.0.102
 Commit:            cb83cd4923
 Workload version:  9.0.100-manifests.43af17c7
 MSBuild version:   17.12.18+ed8c6aec5

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jan 24, 2025
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Jan 24, 2025
@filipnavara filipnavara added area-System.Diagnostics.Metric and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Diagnostics.Metric untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

2 participants