mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: update buildkit to opentelemetry support
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
54
vendor/github.com/moby/buildkit/util/tracing/env/traceenv.go
generated
vendored
Normal file
54
vendor/github.com/moby/buildkit/util/tracing/env/traceenv.go
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
package detect
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
|
||||
"github.com/moby/buildkit/util/appcontext"
|
||||
"go.opentelemetry.io/otel/propagation"
|
||||
)
|
||||
|
||||
const (
|
||||
traceparentHeader = "traceparent"
|
||||
tracestateHeader = "tracestate"
|
||||
)
|
||||
|
||||
func init() {
|
||||
appcontext.Register(initContext)
|
||||
}
|
||||
|
||||
func initContext(ctx context.Context) context.Context {
|
||||
// previously defined in https://github.com/open-telemetry/opentelemetry-swift/blob/4ea467ed4b881d7329bf2254ca7ed7f2d9d6e1eb/Sources/OpenTelemetrySdk/Trace/Propagation/EnvironmentContextPropagator.swift#L14-L15
|
||||
parent := os.Getenv("OTEL_TRACE_PARENT")
|
||||
state := os.Getenv("OTEL_TRACE_STATE")
|
||||
|
||||
if parent == "" {
|
||||
return ctx
|
||||
}
|
||||
|
||||
tc := propagation.TraceContext{}
|
||||
return tc.Extract(ctx, &textMap{parent: parent, state: state})
|
||||
}
|
||||
|
||||
type textMap struct {
|
||||
parent string
|
||||
state string
|
||||
}
|
||||
|
||||
func (tm *textMap) Get(key string) string {
|
||||
switch key {
|
||||
case traceparentHeader:
|
||||
return tm.parent
|
||||
case tracestateHeader:
|
||||
return tm.state
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func (tm *textMap) Set(key string, value string) {
|
||||
}
|
||||
|
||||
func (tm *textMap) Keys() []string {
|
||||
return []string{traceparentHeader, tracestateHeader}
|
||||
}
|
Reference in New Issue
Block a user