Documentation ¶
Overview ¶
Package cloudtrace provides primitives for Cloud Trace integration.
Index ¶
Constants ¶
const ContextHeader = "x-cloud-trace-context"
ContextHeader is the metadata key of the Cloud Trace context header.
Variables ¶
This section is empty.
Functions ¶
func StartExporter ¶
func StartExporter( ctx context.Context, exporterConfig ExporterConfig, resource *resource.Resource, ) (func(), error)
StartExporter starts the OpenTelemetry Cloud Trace exporter.
Types ¶
type Context ¶
type Context struct { // TraceID is a 32-character hexadecimal value representing a 128-bit number. TraceID string // SpanID is the decimal representation of the (unsigned) span ID. SpanID string // Sampled indicates if the trace is being sampled. Sampled bool }
Context represents a Google Cloud Trace context header value.
The format of the X-Cloud-Trace-Context header is:
TRACE_ID/SPAN_ID;o=TRACE_TRUE"
See: https://cloud.google.com/trace/docs/setup
func FromIncomingContext ¶
FromIncomingContext returns the incoming Cloud Trace Context.
func (*Context) UnmarshalString ¶
UnmarshalString parses the provided X-Cloud-Trace-Context header.
type ExporterConfig ¶
type ExporterConfig struct { Enabled bool `onGCE:"true"` Timeout time.Duration `default:"10s"` SampleProbability float64 `default:"0.01"` }
ExporterConfig configures the trace exporter.
type Middleware ¶
type Middleware struct { // ProjectID of the project the service is running in. ProjectID string // TraceHook is an optional callback that gets called with the parsed trace context. TraceHook func(context.Context, Context) context.Context }
Middleware that ensures incoming traces are forwarded and included in logging.
func (*Middleware) GRPCServerUnaryInterceptor ¶
func (i *Middleware) GRPCServerUnaryInterceptor( ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler, ) (resp interface{}, err error)
GRPCServerUnaryInterceptor provides unary RPC middleware for gRPC servers.
func (*Middleware) HTTPServer ¶
func (i *Middleware) HTTPServer(next http.Handler) http.Handler
HTTPServer provides middleware for HTTP servers.