trace

package
v0.67.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package trace provides trace support and helper methods.

Index

Constants

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

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

func Close() error

Close the tracer.

func ComponentOpName added in v0.5.0

func ComponentOpName(cmp, target string) string

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 Setup

func Setup(name, ver, agent, typ string, prm float64, buckets []float64) error

Setup tracing by providing all necessary parameters.

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

func (c *Counter) Add(ctx context.Context, count float64)

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

func (c *Counter) Inc(ctx context.Context)

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

func (h *Histogram) Observe(ctx context.Context, v float64)

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

Jump to

Keyboard shortcuts

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