From 278ae3d26a86d9ce5883c92bf570b810fb883290 Mon Sep 17 00:00:00 2001 From: Toby Date: Tue, 23 May 2023 11:11:58 +0800 Subject: [PATCH] feat: add OtlpHttpPath config support for ZincObserve Telemetry (#3271) Signed-off-by: Toby Yan Co-authored-by: cong --- core/trace/agent.go | 3 +++ core/trace/agent_test.go | 1 + core/trace/config.go | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/core/trace/agent.go b/core/trace/agent.go index 9b293e45..5bae9f6d 100644 --- a/core/trace/agent.go +++ b/core/trace/agent.go @@ -91,6 +91,9 @@ func createExporter(c Config) (sdktrace.SpanExporter, error) { if len(c.OtlpHeaders) > 0 { opts = append(opts, otlptracehttp.WithHeaders(c.OtlpHeaders)) } + if len(c.OtlpHttpPath) > 0 { + opts = append(opts, otlptracehttp.WithURLPath(c.OtlpHttpPath)) + } return otlptracehttp.New( context.Background(), opts..., diff --git a/core/trace/agent_test.go b/core/trace/agent_test.go index a3871a42..cbced387 100644 --- a/core/trace/agent_test.go +++ b/core/trace/agent_test.go @@ -50,6 +50,7 @@ func TestStartAgent(t *testing.T) { OtlpHeaders: map[string]string{ "uptrace-dsn": "http://project2_secret_token@localhost:14318/2", }, + OtlpHttpPath: "/v1/traces", } c7 := Config{ Name: "UDP", diff --git a/core/trace/config.go b/core/trace/config.go index 9423f97c..b59af555 100644 --- a/core/trace/config.go +++ b/core/trace/config.go @@ -13,4 +13,8 @@ type Config struct { // For example: // uptrace-dsn: 'http://project2_secret_token@localhost:14317/2' OtlpHeaders map[string]string `json:",optional"` + // OtlpHttpPath represents the path for OTLP HTTP transport. + // For example + // /v1/traces + OtlpHttpPath string `json:",optional"` }