package tracing

import (
	"context"
)

type contextKey string

const traceContextKey contextKey = "acp_trace_id"

// WithTraceID attaches a trace ID to a standard context.
func WithTraceID(ctx context.Context, traceID string) context.Context {
	return context.WithValue(ctx, traceContextKey, traceID)
}

// TraceIDFromStdContext reads a trace ID from a standard context.
func TraceIDFromStdContext(ctx context.Context) string {
	v := ctx.Value(traceContextKey)
	if v == nil {
		return ""
	}
	s, _ := v.(string)
	return s
}
