A continuation of HomeBox the inventory and organization system built for the Home User
fix: issue with path prefixed endpoints, ignore unneeded spans
Matthew Kilgore9842a6d68df5
diff --git a/backend/internal/sys/otel/otel.go b/backend/internal/sys/otel/otel.goindex 95e1c3f6..97de4474 100644--- a/backend/internal/sys/otel/otel.go+++ b/backend/internal/sys/otel/otel.go@@ -299,7 +299,12 @@ func createOTLPExporter(ctx context.Context, cfg *config.OTelConfig) (*otlptracecase "http":opts := []otlptracehttp.Option{}if cfg.Endpoint != "" {- opts = append(opts, otlptracehttp.WithEndpoint(cfg.Endpoint))+ host, path := parseEndpoint(cfg.Endpoint)+ opts = append(opts, otlptracehttp.WithEndpoint(host))+ if path != "" {+ // Custom base path - append the standard OTLP trace path+ opts = append(opts, otlptracehttp.WithURLPath(path+"/v1/traces"))+ }}if cfg.Insecure {opts = append(opts, otlptracehttp.WithInsecure())@@ -353,7 +358,12 @@ func createOTLPMetricExporter(ctx context.Context, cfg *config.OTelConfig) (sdkmcase "http":opts := []otlpmetrichttp.Option{}if cfg.Endpoint != "" {- opts = append(opts, otlpmetrichttp.WithEndpoint(cfg.Endpoint))+ host, path := parseEndpoint(cfg.Endpoint)+ opts = append(opts, otlpmetrichttp.WithEndpoint(host))+ if path != "" {+ // Custom base path - append the standard OTLP metrics path+ opts = append(opts, otlpmetrichttp.WithURLPath(path+"/v1/metrics"))+ }}if cfg.Insecure {opts = append(opts, otlpmetrichttp.WithInsecure())@@ -406,7 +416,12 @@ func createOTLPLogExporter(ctx context.Context, cfg *config.OTelConfig) (sdklog.case "http":opts := []otlploghttp.Option{}if cfg.Endpoint != "" {- opts = append(opts, otlploghttp.WithEndpoint(cfg.Endpoint))+ host, path := parseEndpoint(cfg.Endpoint)+ opts = append(opts, otlploghttp.WithEndpoint(host))+ if path != "" {+ // Custom base path - append the standard OTLP logs path+ opts = append(opts, otlploghttp.WithURLPath(path+"/v1/logs"))+ }}if cfg.Insecure {opts = append(opts, otlploghttp.WithInsecure())@@ -455,6 +470,23 @@ func parseHeaders(headerStr string) map[string]string {return headers}+// parseEndpoint splits an endpoint into host and path components.+// For example: "oneuptime.com/otlp" returns ("oneuptime.com", "/otlp")+// For "localhost:8080" returns ("localhost:8080", "")+func parseEndpoint(endpoint string) (host, path string) {+ // Remove any protocol prefix if present (shouldn't be there but handle it anyway)+ endpoint = strings.TrimPrefix(endpoint, "http://")+ endpoint = strings.TrimPrefix(endpoint, "https://")++ // Find the first slash to split host and path+ if idx := strings.Index(endpoint, "/"); idx != -1 {+ return endpoint[:idx], endpoint[idx:]+ }++ // No path component+ return endpoint, ""+}+// getEnvironment returns the current deployment environment.func getEnvironment() string {return "production"