Setup different name; Copying of headers is not required for spans

This commit is contained in:
Rajat Vig
2021-12-22 01:29:21 +00:00
parent ab9f7410c2
commit c4f2a6c5e6
3 changed files with 4 additions and 25 deletions

View File

@@ -3,14 +3,14 @@ version: '2'
services:
podinfo_frontend:
build: .
command: ./podinfo --backend-url http://podinfo_backend:9899/status/200
command: ./podinfo --backend-url http://podinfo_backend:9899/status/200 --otel-service-name=podinfo_frontend
environment:
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://otel:4317
ports:
- "9898:9898"
podinfo_backend:
build: .
command: ./podinfo --port 9899
command: ./podinfo --port 9899 --otel-service-name=podinfo_backend
environment:
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://otel:4317
ports:

View File

@@ -55,9 +55,6 @@ func (s *Server) echoHandler(w http.ResponseWriter, r *http.Request) {
return
}
// forward headers
copyTracingHeaders(r, backendReq)
backendReq.Header.Set("X-API-Version", version.VERSION)
backendReq.Header.Set("X-API-Revision", version.REVISION)
@@ -107,22 +104,3 @@ func (s *Server) echoHandler(w http.ResponseWriter, r *http.Request) {
w.Write(body)
}
}
func copyTracingHeaders(from *http.Request, to *http.Request) {
headers := []string{
"x-request-id",
"x-b3-traceid",
"x-b3-spanid",
"x-b3-parentspanid",
"x-b3-sampled",
"x-b3-flags",
"x-ot-span-context",
}
for i := range headers {
headerValue := from.Header.Get(headers[i])
if len(headerValue) > 0 {
to.Header.Set(headers[i], headerValue)
}
}
}

View File

@@ -1,9 +1,10 @@
package api
import (
"go.opentelemetry.io/otel/trace"
"time"
"go.opentelemetry.io/otel/trace"
"github.com/gorilla/mux"
"go.uber.org/zap"
)