Documentation ¶
Overview ¶
Package tracing is a library that provides distributed tracing to Go applications. It offers features such as collecting performance data of an application, identifying where requests are spending most of their time, and segmenting requests. It trace exporting to support 3rd-party services such as Jaeger, Zipkin, Opentelemetry, and NewRelic. Go-Coldbrew Tracing helps developers quickly identify issues and take corrective action when performance bottlenecks occur.
Index ¶
- func ClientSpan(operationName string, ctx context.Context) (context.Context, opentracing.Span)
- func CloneContextValues(parent context.Context) context.Context
- func GRPCTracingSpan(operationName string, ctx context.Context) context.Context
- func MergeContextValues(parent context.Context, main context.Context) context.Context
- func MergeParentContext(parent context.Context, main context.Context) context.Context
- func NewContextWithParentValues(parent context.Context) context.Context
- type Span
- func NewDatastoreSpan(ctx context.Context, datastore, operation, collection string) (Span, context.Context)
- func NewExternalSpan(ctx context.Context, name string, url string) (Span, context.Context)
- func NewHTTPExternalSpan(ctx context.Context, name string, url string, hdr http.Header) (Span, context.Context)
- func NewInternalSpan(ctx context.Context, name string) (Span, context.Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClientSpan ¶
ClientSpan starts a new client span linked to the existing spans if any are found in the context. The returned context should be used in place of the original
func CloneContextValues ¶
CloneContextValues clones a given context values and returns a new context obj which is not affected by Cancel, Deadline etc Deprecated: The function name is a bit confusing, use CloneContextValues instead
func GRPCTracingSpan ¶
GRPCTracingSpan starts a new client span linked to the existing spans if any are found in the context. The returned context should be used in place of the original
func MergeContextValues ¶
MergeContextValues merged the given main context with a parent context, Cancel/Deadline etc are used from the main context and values are looked in both the contexts can be use to merge a parent context with a new context, the new context will have the values from both the contexts
func MergeParentContext ¶ added in v0.0.4
MergeParentContext merged the given main context with a parent context, Cancel/Deadline etc are used from the main context and values are looked in both the contexts Deprecated: The function name is a bit confusing, use MergeContextValues instead
func NewContextWithParentValues ¶ added in v0.0.4
NewContextWithParentValues clones a given context values and returns a new context obj which is not affected by Cancel, Deadline etc can be used to pass context values to a new context which is not affected by the parent context cancel/deadline etc from parent
Types ¶
type Span ¶
type Span interface { // End ends the span, can also use Finish() End() // Finish ends the span, can also use End() Finish() // SetTag sets a tag on the span, can be used to add custom attributes SetTag(key string, value interface{}) // SetQuery sets the query on the span, can be used to add query for datastore spans SetQuery(query string) // SetError sets the error on the span SetError(err error) error }
Span defines an interface for implementing a tracing span This is used to abstract the underlying tracing implementation, currently using opentracing/opentelemetry and newrelic tracing libraries for implementation
func NewDatastoreSpan ¶
func NewDatastoreSpan(ctx context.Context, datastore, operation, collection string) (Span, context.Context)
NewDatastoreSpan starts a span for tracing data store actions This is used to trace actions against a data store, for example, a database query or a redis call
func NewExternalSpan ¶
NewExternalSpan starts a span for tracing external actions This is used to trace actions against an external service, for example, a call to another service or a call to an external API
func NewHTTPExternalSpan ¶
func NewHTTPExternalSpan(ctx context.Context, name string, url string, hdr http.Header) (Span, context.Context)
NewHTTPExternalSpan starts a span for tracing external HTTP actions This is used to trace actions against an external service, for example, a call to another service or a call to an external API It also adds the HTTP headers to the span so that the external service can trace the call back to this service if needed