2

I'm getting this error every time that the endpoint /actuator/prometheus is being call. I don't have any idea what could be the problem? This is the initialization code (I'm sure that openTelemetryEndpoint variable has a value):

            builder.Services.AddAllActuators();
            builder.Services.AddPrometheusActuator();

            // OpenTelemetry configuration
            var openTelemetryServiceName = Environment.GetEnvironmentVariable("OTEL_SERVICE_NAME");
            var openTelemetryEndpoint = Environment.GetEnvironmentVariable("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT");

            if (!string.IsNullOrWhiteSpace(openTelemetryEndpoint))
            {
                // Configure metrics
                builder.Services.AddOpenTelemetryMetrics(b =>
                {
                    b.AddHttpClientInstrumentation();
                    b.AddAspNetCoreInstrumentation();
                    b.AddMeter(openTelemetryServiceName + "-metrics");
                    b.AddOtlpExporter(options =>
                    {
                        options.Endpoint = new Uri(openTelemetryEndpoint);
                        options.Protocol = OpenTelemetry.Exporter.OtlpExportProtocol.Grpc;
                    });
                });

                // Configure tracing
                builder.Services.AddOpenTelemetryTracing(b =>
                {
                    b.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(openTelemetryServiceName));
                    b.AddHttpClientInstrumentation();
                    b.AddAspNetCoreInstrumentation();
                    b.AddSource(openTelemetryServiceName + "-activity-source");
                    b.AddOtlpExporter(options =>
                    {
                        options.Endpoint = new Uri(openTelemetryEndpoint);
                        options.Protocol = OpenTelemetry.Exporter.OtlpExportProtocol.Grpc;
                    });
                });

                // Configure logging
                builder.Logging.AddOpenTelemetry(b =>
                {
                    b.IncludeFormattedMessage = true;
                    b.IncludeScopes = true;
                    b.ParseStateValues = true;
                    b.AddOtlpExporter(options =>
                    {
                        options.Endpoint = new Uri(openTelemetryEndpoint);
                        options.Protocol = OpenTelemetry.Exporter.OtlpExportProtocol.Grpc;
                    });
                    b.AddConsoleExporter();
                });
            }

1 Answers1

0

Marcelo, The error message is saying that you need to use the Steeltoe extension for Metrics: `AddOpenTelemetryMetricsForSteeltoe to get the desired functionality. Steeltoe internally uses OpentelemetryMetrics for its own exports for example /Metrics, /Prometheus and also Wavefront Exporter. If you want to in addition to these add an OLTP exporter you would in addition have to use the extension methods to add the additional configuration.

Hananiel
  • 421
  • 2
  • 9
  • I never knew that AddOpenTelemetryMetricsForSteeltoe exists, I add it, but still getting the same error. Thx for your answer! – Marcelo Mosquera Aug 18 '22 at 14:03
  • You have to use the Steeltoe extension method instead of the Otel extension method. Added a sample here : https://github.com/hananiel/OtelSample – Hananiel Aug 22 '22 at 15:15