cloudtrace

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package cloudtrace provides primitives for Cloud Trace integration.

Index

Constants

View Source
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

func FromIncomingContext(ctx context.Context) (Context, bool)

FromIncomingContext returns the incoming Cloud Trace Context.

func (Context) String

func (c Context) String() string

String returns a string representation of the trace context.

func (*Context) UnmarshalString

func (c *Context) UnmarshalString(value string) error

UnmarshalString parses the provided X-Cloud-Trace-Context header.

type ExporterConfig

type ExporterConfig struct {
	Enabled bool `onGCE:"true"`
}

ExporterConfig configures the trace exporter.

type Middleware

type Middleware struct {
	// ProjectID of the project the service is running in.
	ProjectID string
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL