Closed
Description
Question
I'm trying to emit metrics using OTLP HttpExporter (ConsoleExporter works) but nothing is getting sent. I wonder whether HttpExporter is supported for Metrics path?
<ItemGroup>
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.2.0-beta1" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.2.0-beta1" />
</ItemGroup>
private static readonly Meter MyMeter = new Meter("ConsoleWithOTel.Meters", "1.0");
private static readonly Counter<long> IncomingRequestsCounter = MyMeter.CreateCounter<long>("IncomingRequests");
private static async Task Main(string[] args)
{
using var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddMeter("ConsoleWithOTel.Meters")
//.AddConsoleExporter(options => { options.MetricExportIntervalMilliseconds = 1000; })
.AddOtlpExporter(opt =>
{
opt.MetricExportIntervalMilliseconds = 1000;
opt.Endpoint = new Uri("https://bla.com/v1/metrics");
opt.ExportProcessorType = ExportProcessorType.Simple; // tried Batch as well
opt.Protocol = OtlpExportProtocol.HttpProtobuf; // Is this option supported?
})
.Build();
IncomingRequestsCounter.Add(1, new KeyValuePair<string, object>("version", "v1"));
IncomingRequestsCounter.Add(1, new KeyValuePair<string, object>("version", "v1"));
IncomingRequestsCounter.Add(1, new KeyValuePair<string, object>("version", "v1"));
IncomingRequestsCounter.Add(1, new KeyValuePair<string, object>("version", "v2"));
IncomingRequestsCounter.Add(1, new KeyValuePair<string, object>("version", "v3"));
Console.WriteLine($"{DateTimeOffset.UtcNow:O} Press any key to stop...");
Console.ReadKey();
}