Browse Source

feat: add OtlpHttpPath config support for ZincObserve Telemetry (#3271)

Signed-off-by: Toby Yan <me@tobyan.com>
Co-authored-by: cong <zhangcong1992@gmail.com>
Toby 1 year ago
parent
commit
278ae3d26a
3 changed files with 8 additions and 0 deletions
  1. 3 0
      core/trace/agent.go
  2. 1 0
      core/trace/agent_test.go
  3. 4 0
      core/trace/config.go

+ 3 - 0
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...,

+ 1 - 0
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",

+ 4 - 0
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"`
 }