Documentation ¶
Overview ¶
Package trace provides trace support and helper methods.
Index ¶
- Constants
- Variables
- func ChildSpan(ctx context.Context, opName, cmp string, tags ...opentracing.Tag) (opentracing.Span, context.Context)
- func Close() error
- func ComponentOpName(cmp, target string) string
- func ConsumerSpan(ctx context.Context, opName, cmp, corID string, hdr map[string]string, ...) (opentracing.Span, context.Context)
- func Setup(name, ver, agent, typ string, prm float64, buckets []float64) error
- func SpanComplete(sp opentracing.Span, err error)
- func SpanError(sp opentracing.Span)
- func SpanSuccess(sp opentracing.Span)
- type Counter
- type Histogram
Constants ¶
const ( // HostsTag is used to tag the component's hosts. HostsTag = "hosts" // VersionTag is used to tag the component's version. VersionTag = "version" // TraceID is a label name for a request trace ID. TraceID = "traceID" )
Variables ¶
var ( // Version will be used to tag all traced components. // It can be used to distinguish between dev, stage, and prod environments. Version = "dev" )
Functions ¶
func ChildSpan ¶ added in v0.4.6
func ChildSpan(ctx context.Context, opName, cmp string, tags ...opentracing.Tag) (opentracing.Span, context.Context)
ChildSpan starts a new child span with specified tags.
func ComponentOpName ¶ added in v0.5.0
ComponentOpName returns an operation name for a component.
func ConsumerSpan ¶ added in v0.4.6
func ConsumerSpan(ctx context.Context, opName, cmp, corID string, hdr map[string]string, tags ...opentracing.Tag) (opentracing.Span, context.Context)
ConsumerSpan starts a new consumer span.
func SpanComplete ¶ added in v0.31.0
func SpanComplete(sp opentracing.Span, err error)
SpanComplete finishes a span with or without an error indicator.
func SpanError ¶ added in v0.4.6
func SpanError(sp opentracing.Span)
SpanError finishes a span with an error indicator.
func SpanSuccess ¶ added in v0.4.6
func SpanSuccess(sp opentracing.Span)
SpanSuccess finishes a span with a success indicator.
Types ¶
type Counter ¶ added in v0.63.0
type Counter struct {
prometheus.Counter
}
Counter is a wrapper of a prometheus.Counter.
func (*Counter) Add ¶ added in v0.63.0
Add adds the given value to the counter. If there is a span associated with a context ctx the method replaces the currently saved exemplar (if any) with a new one, created from the provided value. NB: to have a counter metric augmented with exemplars a counter metric name MUST have a suffix "_total" otherwise the metric will not be collected by Prometheus, refer to an OpenMetrics specification: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md
func (*Counter) Inc ¶ added in v0.63.0
Inc increments the given value to the counter. If there is a span associated with a context ctx the method replaces the currently saved exemplar (if any) with a new one, created from the provided value. NB: to have a counter metric augmented with exemplars a counter metric name MUST have a suffix "_total" otherwise the metric will not be collected by Prometheus, refer to an OpenMetrics specification: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md
type Histogram ¶ added in v0.63.0
type Histogram struct {
prometheus.Observer
}
Histogram is a wrapper of a prometheus.Observer.
func (*Histogram) Observe ¶ added in v0.63.0
Observe adds an observation. If there is a span associated with a context ctx the method replaces the currently saved exemplar (if any) with a new one, created from the provided value. NB: to have a histogram metric augmented with exemplars a histogram metric name MUST have a suffix "_bucket". otherwise, the metric will not be collected by Prometheus, refer to an OpenMetrics specification: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md