Documentation
¶
Index ¶
- Constants
- Variables
- func GetTraceParentFromContext(ctx context.Context) string
- func InjectTraceParentIntoContext(ctx context.Context, traceParent string) context.Context
- func OtelVersion() string
- type Collector
- type Counter
- type Gauge
- type GoRoutineFactory
- type Histogram
- type Measurement
- type Option
- func WithDefaultHistogramBuckets(buckets []float64) Option
- func WithHistogramBuckets(histogramName string, buckets []float64) Option
- func WithPrometheusRegistry(registerer prometheus.Registerer, gatherer prometheus.Gatherer) Option
- func WithServiceName(name string) Option
- func WithServiceVersion(version string) Option
- type SpanContext
- type SpanKind
- type SpanOption
- type SpanStatus
- type Stats
- type Tags
- type Timer
- type TraceSpan
- type Tracer
Constants ¶
const ( CountType = "count" TimerType = "timer" GaugeType = "gauge" HistogramType = "histogram" )
const ( // SpanStatusUnset is the default status code. SpanStatusUnset = SpanStatus(codes.Unset) // SpanStatusError indicates the operation contains an error. SpanStatusError = SpanStatus(codes.Error) // SpanStatusOk indicates operation has been validated by an Application developers // or Operator to have completed successfully, or contain no error. SpanStatusOk = SpanStatus(codes.Ok) )
const ( // SpanKindUnspecified is an unspecified SpanKind and is not a valid // SpanKind. SpanKindUnspecified should be replaced with SpanKindInternal // if it is received. SpanKindUnspecified = trace.SpanKindUnspecified // SpanKindInternal is a SpanKind for a Span that represents an internal // operation within an application. SpanKindInternal = trace.SpanKindInternal // SpanKindServer is a SpanKind for a Span that represents the operation // of handling a request from a client. SpanKindServer = trace.SpanKindServer // SpanKindClient is a SpanKind for a Span that represents the operation // of client making a request to a server. SpanKindClient = trace.SpanKindClient // SpanKindProducer is a SpanKind for a Span that represents the operation // of a producer sending a message to a message broker. Unlike // SpanKindClient and SpanKindServer, there is often no direct // relationship between this kind of Span and a SpanKindConsumer kind. A // SpanKindProducer Span will end once the message is accepted by the // message broker which might not overlap with the processing of that // message. SpanKindProducer = trace.SpanKindProducer // SpanKindConsumer is a SpanKind for a Span that represents the operation // of a consumer receiving a message from a message broker. Like // SpanKindProducer Spans, there is often no direct relationship between // this Span and the Span that produced the message. SpanKindConsumer = trace.SpanKindConsumer )
Variables ¶
var DefaultGoRoutineFactory = defaultGoRoutineFactory{}
Functions ¶
func GetTraceParentFromContext ¶
GetTraceParentFromContext returns the traceparent header from the context
func InjectTraceParentIntoContext ¶
InjectTraceParentIntoContext injects the traceparent header into the context
func OtelVersion ¶
func OtelVersion() string
Types ¶
type Collector ¶
type Collector interface {
Collect(gaugeTagsFunc)
Zero(gaugeTagsFunc)
ID() string
}
type Counter ¶
type Counter interface {
Count(n int)
Increment()
}
Counter represents a counter metric
type GoRoutineFactory ¶
type GoRoutineFactory interface {
Go(function func())
}
type Histogram ¶
type Histogram interface {
Observe(value float64)
}
Histogram represents a histogram metric
type Measurement ¶
Measurement provides all stat measurement functions TODO: the API should not return a union of measurement methods, but rather a distinct type for each measurement type
type Option ¶
type Option func(*statsConfig)
Option is a function used to configure the stats service.
func WithDefaultHistogramBuckets ¶
WithDefaultHistogramBuckets sets the histogram buckets for the stats service.
func WithHistogramBuckets ¶
WithHistogramBuckets sets the histogram buckets for a measurement.
func WithPrometheusRegistry ¶
func WithPrometheusRegistry(registerer prometheus.Registerer, gatherer prometheus.Gatherer) Option
WithPrometheusRegistry sets the prometheus registerer and gatherer for the stats service. If nil is passed the default ones will be used.
func WithServiceName ¶
WithServiceName sets the service name for the stats service.
func WithServiceVersion ¶
WithServiceVersion sets the service version for the stats service.
type SpanContext ¶
type SpanContext = trace.SpanContext
type SpanOption ¶
type SpanOption func(*spanConfig)
SpanOption can be used with span.Start() and span.AddEvent()
func SpanWithTimestamp ¶
func SpanWithTimestamp(timestamp time.Time) SpanOption
SpanWithTimestamp sets the timestamp for the span
type Stats ¶
type Stats interface {
// NewStat creates a new Measurement with provided Name and Type
NewStat(name, statType string) (m Measurement)
// NewTaggedStat creates a new Measurement with provided Name, Type and Tags
NewTaggedStat(name, statType string, tags Tags) Measurement
NewSampledTaggedStat(name, statType string, tags Tags) Measurement
NewTracer(name string) Tracer
// Start starts the stats service and the collection of periodic stats.
Start(ctx context.Context, goFactory GoRoutineFactory) error
// Stop stops the service and the collection of periodic stats.
Stop()
// RegisterCollector registers a collector that will collect stats periodically.
// You can find available collectors in the stats/collectors package.
RegisterCollector(c Collector) error
}
Stats manages stat Measurements
var Default Stats
Default is the default (singleton) Stats instance
var NOP Stats = &nop{}
type Tags ¶
Tags is a map of key value pairs
type Timer ¶
type Timer interface {
SendTiming(duration time.Duration)
Since(start time.Time)
RecordDuration() func()
}
Timer represents a timer metric
type TraceSpan ¶
type TraceSpan interface {
// AddEvent adds an event with the provided name and options.
AddEvent(name string, options ...SpanOption)
// SetStatus sets the status of the Span in the form of a code and a
// description, provided the status hasn't already been set to a higher
// value before (OK > Error > Unset). The description is only included in a
// status when the code is for an error.
SetStatus(code SpanStatus, description string)
// SpanContext returns the SpanContext of the Span. The returned SpanContext
// is usable even after the End method has been called for the Span.
SpanContext() SpanContext
// SetAttributes sets kv as attributes of the Span. If a key from kv
// already exists for an attribute of the Span it will be overwritten with
// the value contained in kv.
SetAttributes(tags Tags)
// End terminates the span
End()
}
type Tracer ¶
type Tracer interface {
SpanFromContext(context.Context) TraceSpan
Start(
ctx context.Context, spanName string, spanKind SpanKind, options ...SpanOption,
) (context.Context, TraceSpan)
}
func NewTracerFromOpenTelemetry ¶
NewTracerFromOpenTelemetry creates a new go-kit Tracer from an OpenTelemetry Tracer.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
otel/prometheus
Package prometheus is imported from the official OpenTelemetry package: https://github.com/open-telemetry/opentelemetry-go/tree/v1.14.0/exporters/prometheus The version of the exporter would be v0.37.0 (not v1.14.0, see releases).
|
Package prometheus is imported from the official OpenTelemetry package: https://github.com/open-telemetry/opentelemetry-go/tree/v1.14.0/exporters/prometheus The version of the exporter would be v0.37.0 (not v1.14.0, see releases). |
|
Package metric implements an abstraction for safely managing metrics in concurrent environments.
|
Package metric implements an abstraction for safely managing metrics in concurrent environments. |
|
Package mock_stats is a generated GoMock package.
|
Package mock_stats is a generated GoMock package. |