admin管理员组

文章数量:1122846

I'm using OpenTelemetry for metrics instrumentation in a 8.0 console application.

    services.AddOpenTelemetry()
        .WithMetrics(builder =>
        {
            builder
                .AddMeter("System.Net.Http")
                .AddView(instrumentName: "http.client.open_connections", MetricStreamConfiguration.Drop)
                .AddView(instrumentName: "http.client.connection.duration", MetricStreamConfiguration.Drop)
                .AddView(instrumentName: "http.client.request.time_in_queue", MetricStreamConfiguration.Drop)
                .AddView(instrumentName: "http.client.active_requests", MetricStreamConfiguration.Drop)
                .AddView(instrumentName: "http.client.request.duration", new MetricStreamConfiguration
                    {
                        TagKeys = new string[] { "http.response.status_code", "server.port" },
                    })
                .AddOtlpExporter((exporterOptions, metricReaderOptions) =>
                {
                    exporterOptions.Endpoint = new Uri("http://localhost:4317");
                });
        });

I noticed that measurements for OTLP exporter requests are also collected (gRPC requests over port 4317).

As http.client.request.duration metric has a tag port, can I filter out measurements by tag value?

I'm using .net OpenTelemetry for metrics instrumentation in a .net8.0 console application.

    services.AddOpenTelemetry()
        .WithMetrics(builder =>
        {
            builder
                .AddMeter("System.Net.Http")
                .AddView(instrumentName: "http.client.open_connections", MetricStreamConfiguration.Drop)
                .AddView(instrumentName: "http.client.connection.duration", MetricStreamConfiguration.Drop)
                .AddView(instrumentName: "http.client.request.time_in_queue", MetricStreamConfiguration.Drop)
                .AddView(instrumentName: "http.client.active_requests", MetricStreamConfiguration.Drop)
                .AddView(instrumentName: "http.client.request.duration", new MetricStreamConfiguration
                    {
                        TagKeys = new string[] { "http.response.status_code", "server.port" },
                    })
                .AddOtlpExporter((exporterOptions, metricReaderOptions) =>
                {
                    exporterOptions.Endpoint = new Uri("http://localhost:4317");
                });
        });

I noticed that measurements for OTLP exporter requests are also collected (gRPC requests over port 4317).

As http.client.request.duration metric has a tag port, can I filter out measurements by tag value?

Share Improve this question edited Nov 21, 2024 at 14:29 Mhd asked Nov 21, 2024 at 14:19 MhdMhd 2,9685 gold badges29 silver badges60 bronze badges 2
  • The title asks one thing, the question another. Why are you trying to filter meters in the first place? The values aren't generated by AddMeter, this only specifies that OpenTelemetry should read the already available metrics under Systen.Net.Http and send them whenever a monitoring application asks for them on 4317 – Panagiotis Kanavos Commented Nov 21, 2024 at 14:22
  • updated the question. I was hoping to drop measurements with port == 4317 – Mhd Commented Nov 21, 2024 at 14:29
Add a comment  | 

1 Answer 1

Reset to default 1

There is no ability to filter metrics based on tags today in OpenTelemetry .NET.

本文标签: open telemetryFilter metrics by tag value using net OpenTelemetryStack Overflow