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

Azure Monitor exporter exports metric values always as 0 for long counter measurements #18905

Closed
bastbu opened this issue Feb 24, 2023 · 2 comments · Fixed by #18914
Closed
Assignees
Labels
bug Something isn't working exporter/azuremonitor

Comments

@bastbu
Copy link
Contributor

bastbu commented Feb 24, 2023

Component(s)

exporter/azuremonitor

What happened?

Description

When using the Azure Monitor exporter to export metrics using the OTLP exporter, the customMetrics showing up in application insights always have value: 0.

Steps to Reproduce

Can be reproduced by taking measurements (e.g. from a counter) in a .NET application:

using OpenTelemetry;
using OpenTelemetry.Metrics;
using System.Diagnostics.Metrics;

namespace Test;

public class Program
{
    private static readonly Meter MyMeter = new("Test", "1.0");
    private static readonly Counter<long> MyFruitCounter = MyMeter.CreateCounter<long>("MyFruitCounter");

    public static void Main()
    {
        using var meterProvider = Sdk.CreateMeterProviderBuilder()
            .AddMeter("Test")
            .AddOtlpExporter()
            .AddConsoleExporter()
            .Build();

        MyFruitCounter.Add(10, new("name", "apple"), new("color", "red"));
    }
}

Expected Result

As per the above example, the value field should be 10 (given a valueCount of 1).

Actual Result

The value, valueMin, valueMax and valueSum fields are all 0:

image

The console exporter on the test application displays the value to be 10, which is correct:

Resource associated with Metric:
    service.name: unknown_service:dotnet

Export MyFruitCounter, Meter: Test/1.0
(2023-02-24T09:54:09.9409890Z, 2023-02-24T09:54:10.1143793Z] color: red name: apple LongSum
Value: 10

Collector version

0.72.0

Environment information

Environment

OS: WSL2 on Windows 11

OpenTelemetry Collector configuration

receivers:
  otlp:
    protocols: 
      grpc:
processors:
exporters:
  logging:
  azuremonitor:
    instrumentation_key: <redacted>
service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: []
      exporters: [logging,azuremonitor]
    metrics:
      receivers: [otlp]
      processors: []
      exporters: [logging,azuremonitor]
    logs:
      receivers: [otlp]
      processors: []
      exporters: [logging,azuremonitor]

Log output

No response

Additional context

No response

@bastbu bastbu added bug Something isn't working needs triage New item requiring triage labels Feb 24, 2023
@github-actions
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@bastbu
Copy link
Contributor Author

bastbu commented Feb 24, 2023

After looking at the source code, my guess is that this is a consequence of only using numberDataPoint.DoubleValue() in

dataPoint.Value = numberDataPoint.DoubleValue()

Any IntValue() will be discarded, which might be why for the above sample code (which uses Counter<long>) the value in Application Insights is 0. If wanted, I can work on a fix for this.

@bastbu bastbu changed the title Azure Monitor exporter exports metric values always as 0 for counter measurements Azure Monitor exporter exports metric values always as 0 for long counter measurements Feb 24, 2023
@atoulme atoulme removed the needs triage New item requiring triage label Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working exporter/azuremonitor
Projects
None yet
2 participants