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

Output unexpected literal string in MetricsEventSource.ParseSpecs #60110

Closed
itn3000 opened this issue Oct 7, 2021 · 6 comments · Fixed by #60176
Closed

Output unexpected literal string in MetricsEventSource.ParseSpecs #60110

itn3000 opened this issue Oct 7, 2021 · 6 comments · Fixed by #60176

Comments

@itn3000
Copy link
Contributor

itn3000 commented Oct 7, 2021

Description

Some log message in MetricsEventSource seems to be unexpected literal string.
steps of reproduce are following.

  1. run following code snippet
using System;
using System.Diagnostics.Metrics;

using var meter = new Meter("appmeter");
var counter = meter.CreateCounter<int>("counter1", "unit", "desc");
while(true)
{
    await Task.Delay(1000).ConfigureAwait(false);
    if(counter.Enabled)
    {
        counter.Add(1);
    }
}
  1. listen MetricsEventSource with dotnet-trace collect -p [PID] --provideres System.Diagnostics.Metrics:::Metrics=appmeter
  2. open trace file with perfview
  3. view "System.Diagnostics.Metrics/Message" events

And there is record which has Message="Parsed metric: {spec}".
It should be Message="Parsed metric: appmeter".

Configuration

dotnet-sdk-6.0-rc1 windows10-x64

Other information

I found the source location which should be fixed.

if (!MetricSpec.TryParse(specString, out MetricSpec spec))
{
Log.Message("Failed to parse metric spec: {specString}");
}
else
{
Log.Message("Parsed metric: {spec}");
if (spec.InstrumentName != null)
{
_aggregationManager!.Include(spec.MeterName, spec.InstrumentName);
}
else
{
_aggregationManager!.Include(spec.MeterName);
}
}

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Diagnostics.Tracing untriaged New issue has not been triaged by the area owner labels Oct 7, 2021
@ghost
Copy link

ghost commented Oct 7, 2021

Tagging subscribers to this area: @tarekgh, @tommcdon, @pjanotti
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Some log message in MetricsEventSource seems to be unexpected literal string.
steps of reproduce are following.

  1. run following code snippet
using System;
using System.Diagnostics.Metrics;

using var meter = new Meter("appmeter");
var counter = meter.CreateCounter<int>("counter1", "unit", "desc");
while(true)
{
    await Task.Delay(1000).ConfigureAwait(false);
    if(counter.Enabled)
    {
        counter.Add(1);
    }
}
  1. listen MetricsEventSource with dotnet-trace collect -p [PID] --provideres System.Diagnostics.Metrics:::Metrics=appmeter
  2. open trace file with perfview
  3. view "System.Diagnostics.Metrics/Message" events

And there is record which has Message="Parsed metric: {spec}".
It should be Message="Parsed metric: appmeter".

Configuration

dotnet-sdk-6.0-rc1 windows10-x64

Other information

I found the source location which should be fixed.

if (!MetricSpec.TryParse(specString, out MetricSpec spec))
{
Log.Message("Failed to parse metric spec: {specString}");
}
else
{
Log.Message("Parsed metric: {spec}");
if (spec.InstrumentName != null)
{
_aggregationManager!.Include(spec.MeterName, spec.InstrumentName);
}
else
{
_aggregationManager!.Include(spec.MeterName);
}
}

Author: itn3000
Assignees: -
Labels:

area-System.Diagnostics.Tracing, untriaged

Milestone: -

@itn3000
Copy link
Contributor Author

itn3000 commented Oct 7, 2021

I made branch and commit for fixing it, not write test yet.
itn3000@81d5fa5

@tommcdon
Copy link
Member

tommcdon commented Oct 7, 2021

@tarekgh

@tommcdon tommcdon removed the untriaged New issue has not been triaged by the area owner label Oct 7, 2021
@tommcdon tommcdon added this to the 7.0.0 milestone Oct 7, 2021
@tarekgh
Copy link
Member

tarekgh commented Oct 7, 2021

@itn3000 thanks for your report. do you want to submit a PR to fix it? it should be a trivial fix

- Log.Message("Failed to parse metric spec: {specString}"); 
+ Log.Message($"Failed to parse metric spec: {specString}"); 

and

-Log.Message("Parsed metric: {spec}");
+Log.Message($"Parsed metric: {spec}");

I looked at the rest of the file and couldn't find any other similar case.

CC @noahfalk

@itn3000
Copy link
Contributor Author

itn3000 commented Oct 8, 2021

I create PR #60176

@kasperk81
Copy link
Contributor

a bug was found in a new API introduced in 6.0, should it be in 6.0 milestone (akin #60182)?

@ghost ghost locked as resolved and limited conversation to collaborators Nov 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants