Files
Andreas GerstmayrandGitHub 87058f7b85 Migrate from OpenTracing to OpenTelemetry instrumentation (#3646)
* Migrate from OpenTracing to OpenTelemetry instrumentation

Signed-off-by: Andreas Gerstmayr <[email protected]>

* update dskit to c41c58734f46

Signed-off-by: Andreas Gerstmayr <[email protected]>

* switch to exporters/autoexport, update docs and examples

Signed-off-by: Andreas Gerstmayr <[email protected]>

* update dependencies

Signed-off-by: Andreas Gerstmayr <[email protected]>

* refactor added code from opentracing to OTEL SDK

Signed-off-by: Andreas Gerstmayr <[email protected]>

* move the changelog entry to the correct version

Signed-off-by: Andreas Gerstmayr <[email protected]>

* run go mod tidy

Signed-off-by: Andreas Gerstmayr <[email protected]>

* align tracer name with pkg name, some fixes

Signed-off-by: Andreas Gerstmayr <[email protected]>

* update cmd/tempo-query/tempo tracer name

Signed-off-by: Andreas Gerstmayr <[email protected]>

* update changelog, enable tracing if OTEL_TRACES_EXPORTER is set

Signed-off-by: Andreas Gerstmayr <[email protected]>

---------

Signed-off-by: Andreas Gerstmayr <[email protected]>
2024-09-05 19:56:54 +00:00

33 lines
645 B
Go

package httpgrpcutil
import (
"github.com/grafana/dskit/httpgrpc"
)
// Used to transfer trace information from/to HTTP request.
type HttpgrpcHeadersCarrier httpgrpc.HTTPRequest
func (c *HttpgrpcHeadersCarrier) Get(key string) string {
for _, h := range c.Headers {
if h.Key == key {
return h.Values[0]
}
}
return ""
}
func (c *HttpgrpcHeadersCarrier) Set(key, val string) {
c.Headers = append(c.Headers, &httpgrpc.Header{
Key: key,
Values: []string{val},
})
}
func (c *HttpgrpcHeadersCarrier) Keys() []string {
k := make([]string, 0, len(c.Headers))
for _, h := range c.Headers {
k = append(k, h.Key)
}
return k
}