tracing

package
v0.0.0-...-455eedf Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TracerContextName         = "cf-trace-id"
	TracerContextNameOverride = "uber-trace-id"

	IntCloudflaredTracingHeader = "cf-int-cloudflared-tracing"

	MaxErrorDescriptionLen = 100
)
View Source
const (
	// 16 bytes for tracing ID, 8 bytes for span ID and 1 byte for flags
	IdentityLength = 16 + 8 + 1
)
View Source
const (
	MaxTraceAmount = 20
)

Variables

View Source
var (
	CanonicalCloudflaredTracingHeader = http.CanonicalHeaderKey(IntCloudflaredTracingHeader)
	Http2TransportAttribute           = trace.WithAttributes(transportAttributeKey.String("http2"))
	QuicTransportAttribute            = trace.WithAttributes(transportAttributeKey.String("quic"))
	HostOSAttribute                   = semconv.HostTypeKey.String(runtime.GOOS)
	HostArchAttribute                 = semconv.HostArchKey.String(runtime.GOARCH)
)

Functions

func End

func End(span trace.Span)

End will set the OK status for the span and then end it.

func EndWithErrorStatus

func EndWithErrorStatus(span trace.Span, err error)

EndWithErrorStatus will set a status for the span and then end it.

func EndWithStatusCode

func EndWithStatusCode(span trace.Span, statusCode int)

EndWithStatusCode will set a status for the span and then end it.

func Init

func Init(version string)

func NewNoopSpan

func NewNoopSpan() trace.Span

Types

type Identity

type Identity struct {
	// contains filtered or unexported fields
}

func NewIdentity

func NewIdentity(trace string) (*Identity, error)

func (*Identity) MarshalBinary

func (tc *Identity) MarshalBinary() ([]byte, error)

func (*Identity) String

func (tc *Identity) String() string

TODO: TUN-6604 Remove this. To reconstruct into Jaeger propagation format, convert tracingContext to tracing.Identity

func (*Identity) UnmarshalBinary

func (tc *Identity) UnmarshalBinary(data []byte) error

type InMemoryClient

type InMemoryClient interface {
	// Spans returns a copy of the list of in-memory stored spans as a base64
	// encoded otlp protobuf string.
	Spans() (string, error)
	// ExportProtoSpans returns a copy of the list of in-memory stored spans as otlp
	// protobuf byte array and clears the in-memory spans.
	ExportProtoSpans() ([]byte, error)
}

type InMemoryOtlpClient

type InMemoryOtlpClient struct {
	// contains filtered or unexported fields
}

InMemoryOtlpClient is a client implementation for otlptrace.Client

func (*InMemoryOtlpClient) ExportProtoSpans

func (mc *InMemoryOtlpClient) ExportProtoSpans() ([]byte, error)

ProtoSpans returns the list of in-memory stored spans as the protobuf byte array.

func (*InMemoryOtlpClient) Spans

func (mc *InMemoryOtlpClient) Spans() (string, error)

Spans returns the list of in-memory stored spans as a base64 encoded otlp protobuf string.

func (*InMemoryOtlpClient) Start

func (mc *InMemoryOtlpClient) Start(_ context.Context) error

func (*InMemoryOtlpClient) Stop

func (*InMemoryOtlpClient) UploadTraces

func (mc *InMemoryOtlpClient) UploadTraces(_ context.Context, protoSpans []*tracepb.ResourceSpans) error

UploadTraces adds the provided list of spans to the in-memory list.

type NoopOtlpClient

type NoopOtlpClient struct{}

NoopOtlpClient is a client implementation for otlptrace.Client that does nothing

func (*NoopOtlpClient) ClearSpans

func (mc *NoopOtlpClient) ClearSpans()

func (*NoopOtlpClient) ExportProtoSpans

func (mc *NoopOtlpClient) ExportProtoSpans() ([]byte, error)

Spans always returns no traces error

func (*NoopOtlpClient) Spans

func (mc *NoopOtlpClient) Spans() (string, error)

Spans always returns no traces error

func (*NoopOtlpClient) Start

func (mc *NoopOtlpClient) Start(_ context.Context) error

func (*NoopOtlpClient) Stop

func (mc *NoopOtlpClient) Stop(_ context.Context) error

func (*NoopOtlpClient) UploadTraces

func (mc *NoopOtlpClient) UploadTraces(_ context.Context, _ []*tracepb.ResourceSpans) error

type TracedContext

type TracedContext struct {
	context.Context
	// contains filtered or unexported fields
}

func NewTracedContext

func NewTracedContext(ctx context.Context, traceContext string, log *zerolog.Logger) *TracedContext

NewTracedContext creates a new tracer for the current context.

func (TracedContext) AddSpans

func (cft TracedContext) AddSpans(headers http.Header)

AddSpans assigns spans as base64 encoded protobuf otlp traces to provided HTTP headers.

func (TracedContext) GetProtoSpans

func (cft TracedContext) GetProtoSpans() (proto []byte)

GetProtoSpans returns the spans as the otlp traces in protobuf byte array.

func (TracedContext) GetSpans

func (cft TracedContext) GetSpans() (enc string)

GetSpans returns the spans as base64 encoded string of protobuf otlp traces.

func (TracedContext) Tracer

func (cft TracedContext) Tracer() trace.Tracer

type TracedHTTPRequest

type TracedHTTPRequest struct {
	*http.Request

	ConnIndex uint8 // The connection index used to proxy the request
	// contains filtered or unexported fields
}

func NewTracedHTTPRequest

func NewTracedHTTPRequest(req *http.Request, connIndex uint8, log *zerolog.Logger) *TracedHTTPRequest

NewTracedHTTPRequest creates a new tracer for the current HTTP request context.

func (TracedHTTPRequest) AddSpans

func (cft TracedHTTPRequest) AddSpans(headers http.Header)

AddSpans assigns spans as base64 encoded protobuf otlp traces to provided HTTP headers.

func (TracedHTTPRequest) GetProtoSpans

func (cft TracedHTTPRequest) GetProtoSpans() (proto []byte)

GetProtoSpans returns the spans as the otlp traces in protobuf byte array.

func (TracedHTTPRequest) GetSpans

func (cft TracedHTTPRequest) GetSpans() (enc string)

GetSpans returns the spans as base64 encoded string of protobuf otlp traces.

func (*TracedHTTPRequest) ToTracedContext

func (tr *TracedHTTPRequest) ToTracedContext() *TracedContext

func (TracedHTTPRequest) Tracer

func (cft TracedHTTPRequest) Tracer() trace.Tracer

Jump to

Keyboard shortcuts

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