twirptrace

package
v0.0.0-...-29c3169 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestReceivedEvent = "request.received"
)

Variables

This section is empty.

Functions

func NewOpenTracingHooks

func NewOpenTracingHooks(tracer otrace.Tracer, opts ...TraceOption) *twirp.ServerHooks

NewOpenTracingHooks provides a twirp.ServerHooks struct which records OpenTracing spans.

func WithTraceContext

func WithTraceContext(base http.Handler, tracer otrace.Tracer) http.Handler

WithTraceContext wraps the handler and extracts the span context from request headers to attach to the context for connecting client and server calls.

Types

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient as an interface that models *http.Client.

type TraceHTTPClient

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

TraceHTTPClient wraps a provided http.Client and tracer for instrumenting requests.

func NewTraceHTTPClient

func NewTraceHTTPClient(client HTTPClient) *TraceHTTPClient

func (*TraceHTTPClient) Do

Do injects the tracing headers into the tracer and updates the headers before making the actual request.

type TraceOption

type TraceOption func(opts *TraceOptions)

func IncludeClientErrors

func IncludeClientErrors(includeClientErrors bool) TraceOption

IncludeClientErrors, if set, will report client errors (4xx) as errors in the server span. If not set, only 5xx status will be reported as erroneous.

func WithContextTags

func WithContextTags(fn func(ctx context.Context) (context.Context, []TraceTag)) TraceOption

WithContextTags defines a function that returns set of trace tags. This is useful to extract values from the request ctx and return a set of tags that are set on the span. The function is used during the `RequestReceived` server hook.

func WithTags

func WithTags(tags ...TraceTag) TraceOption

WithTags defines tags to be added to each outoing span by default. If there is a pre-existing tag set for `key`, it is overwritten.

type TraceOptions

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

type TraceServerHooks

type TraceServerHooks struct {
	Tracer otrace.Tracer
	// contains filtered or unexported fields
}

func (*TraceServerHooks) TwirpHooks

func (t *TraceServerHooks) TwirpHooks() *twirp.ServerHooks

type TraceTag

type TraceTag struct {
	// Key defines the span's tag key.
	Key string

	// Value defines the span's tag value. Values can be numeric types, strings, or
	// bools.
	Value interface{}
}

TraceTag represents a single span tag.

Jump to

Keyboard shortcuts

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