Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions DevProxy.Plugins/Inspection/OpenAITelemetryPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,20 @@ private void InitializeOpenTelemetryExporter()

try
{
void configureOtlpExporter(OtlpExporterOptions options)
var baseExporterUri = new Uri(Configuration.ExporterEndpoint);

void configureTracesOtlpExporter(OtlpExporterOptions options)
{
// We use protobuf to allow intercepting Dev Proxy's own LLM traffic
options.Protocol = OtlpExportProtocol.HttpProtobuf;
options.Endpoint = new Uri(baseExporterUri, "/v1/traces");
}

void configureMetricsOtlpExporter(OtlpExporterOptions options)
{
// We use protobuf to allow intercepting Dev Proxy's own LLM traffic
options.Protocol = OtlpExportProtocol.HttpProtobuf;
options.Endpoint = new Uri(Configuration.ExporterEndpoint + "/v1/traces");
options.Endpoint = new Uri(baseExporterUri, "/v1/metrics");
}

var resourceBuilder = ResourceBuilder
Expand All @@ -232,7 +241,7 @@ void configureOtlpExporter(OtlpExporterOptions options)
_tracerProvider = Sdk.CreateTracerProviderBuilder()
.SetResourceBuilder(resourceBuilder)
.AddSource(ActivitySourceName)
.AddOtlpExporter(configureOtlpExporter)
.AddOtlpExporter(configureTracesOtlpExporter)
.Build();

_meterProvider = Sdk.CreateMeterProviderBuilder()
Expand All @@ -247,7 +256,7 @@ void configureOtlpExporter(OtlpExporterOptions options)
Boundaries = [0.0001, 0.0005, 0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 5, 10, 50, 100]
})
.AddView(SemanticConvention.GEN_AI_USAGE_TOTAL_COST, new MetricStreamConfiguration())
.AddOtlpExporter(configureOtlpExporter)
.AddOtlpExporter(configureMetricsOtlpExporter)
.Build();

_tokenUsageMetric = _meter.CreateHistogram<long>(
Expand Down