tel

package module
v0.0.0-...-adae3a6 Latest Latest
Warning

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

Go to latest
Published: May 22, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

README

tel: Open-Telemetry wrapper API for Go

Go Reference

This project is a wrapper for the OpenTelemetry Go API and SDK.

Goals

  • Make it possible to use the OpenTelemetry API without having to part ways with the idioms of the GO programming language.
  • Create a more concise API that is easier to use and discover.
  • Encourage changing the go.opentelemetry.io API and SDK.

Why

The current API for go.opentelemetry.io is hard to use as it exposes dozens of packages, requiring someone to be very familiar with OpenTelemetry before taking advantage of its APIs.

This makes it very uninviting for Go developers who are not telemetry experts to instrument their code. Furthermore, many package names used are common names, leading to conflicts with function/variable names or other packages – which can be a problem, especially when relying on auto-completion.

For example: a package called go.opentelemetry.io/sdk/metric/controller/time, is exported as time, even though the standard library has a package named time.

It is important to remember that there is no concept of subpackage in Go and that a package name should speak clearly about what it is, independently of its whole path.

Packages net/http/httptest or net/http/httptrace contain the prefix http exactly to mitigate this problem.

Status

  1. The code here was mapped manually, with minor code editor tooling helping.
  2. Code generation was not considered for this prototype but would be essential to move things forward.
  3. go.opentelemetry.io/semconv was not included.

semconv

Package semconv implements OpenTelemetry semantic conventions. OpenTelemetry semantic conventions are agreed standardized naming patterns for OpenTelemetry things.

In the opentelemetry-go/semconv directory in the official repository you're going to find the following:

├── internal
│   ├── http.go
│   └── http_test.go
├── template.j2
├── v1.10.0
│   └── doc.go, exception.go, http.go, resource.go, schema.go, trace.go
├── v1.4.0
│   └── doc.go, exception.go, http.go, resource.go, schema.go, trace.go
├── v1.5.0
│   └── doc.go, exception.go, http.go, resource.go, schema.go, trace.go
├── v1.6.1
│   └── doc.go, exception.go, http.go, resource.go, schema.go, trace.go
├── v1.7.0
│   └── doc.go, exception.go, http.go, resource.go, schema.go, trace.go
├── v1.8.0
│   └── doc.go, exception.go, http.go, resource.go, schema.go, trace.go
└── v1.9.0
    └── doc.go, exception.go, http.go, resource.go, schema.go, trace.go
    
    8 directories, 45 files

For each version, there will be a set of Go files there. Instead, there could be a separate repository, perhaps called gosemconv, tagged for each version. This would mean just quickly checking go.mod would be enough for most people to define what to use.

In case someone requires support for multiple versions, they could resort to the following Go proverb and solve it themselves:

A little copying is better than a little dependency.

This is a better trade-off than versioning each different version in directories. It will make it less likely for a majority to use an old version by mistake and negatively impact only a few users.

Future

If this proposal:

  1. Succeeds in improving the official API: success; archive this.
  2. Fails: API code generation mapping the official API. This is a suboptimal outcome, but might be worth.

Documentation

Index

Constants

View Source
const (
	// INVALID is used for a Value with no value set.
	INVALID = attribute.INVALID
	// BOOL is a boolean Type Value.
	BOOL = attribute.BOOL
	// INT64 is a 64-bit signed integral Type Value.
	INT64 = attribute.INT64
	// FLOAT64 is a 64-bit floating point Type Value.
	FLOAT64 = attribute.FLOAT64
	// STRING is a string Type Value.
	STRING = attribute.STRING
	// BOOLSLICE is a slice of booleans Type Value.
	BOOLSLICE = attribute.BOOLSLICE
	// INT64SLICE is a slice of 64-bit signed integral numbers Type Value.
	INT64SLICE = attribute.INT64SLICE
	// FLOAT64SLICE is a slice of 64-bit floating point numbers Type Value.
	FLOAT64SLICE = attribute.FLOAT64SLICE
	// STRINGSLICE is a slice of strings Type Value.
	STRINGSLICE = attribute.STRINGSLICE
)
View Source
const (
	Dimensionless = unit.Dimensionless
	Bytes         = unit.Bytes
	Milliseconds  = unit.Milliseconds
)

Units defined by OpenTelemetry.

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

As a convenience, these match the proto definition, see https://github.com/open-telemetry/opentelemetry-proto/blob/30d237e1ff3ab7aa50e0922b5bebdd93505090af/opentelemetry/proto/trace/v1/trace.proto#L101-L129

The unspecified value is not a valid `SpanKind`. Use `ValidateSpanKind()` to coerce a span kind to a valid value.

View Source
const FlagsSampled = TraceFlags(0x01)

FlagsSampled is a bitmask with the sampled bit set. A SpanContext with the sampling bit set means the span is sampled.

Variables

This section is empty.

Functions

func ContextWithBaggage

func ContextWithBaggage(parent context.Context, b Baggage) context.Context

ContextWithBaggage returns a copy of parent with baggage.

func ContextWithRemoteSpanContext

func ContextWithRemoteSpanContext(parent context.Context, rsc SpanContext) context.Context

ContextWithRemoteSpanContext returns a copy of parent with rsc set explicly as a remote SpanContext and as the current Span. The Span implementation that wraps rsc is non-recording and performs no operations other than to return rsc as the SpanContext from the SpanContext method.

func ContextWithSpan

func ContextWithSpan(parent context.Context, span Span) context.Context

ContextWithSpan returns a copy of parent with span set as the current Span.

func ContextWithSpanContext

func ContextWithSpanContext(parent context.Context, sc SpanContext) context.Context

ContextWithSpanContext returns a copy of parent with sc as the current Span. The Span implementation that wraps sc is non-recording and performs no operations other than to return sc as the SpanContext from the SpanContext method.

func ContextWithoutBaggage

func ContextWithoutBaggage(parent context.Context) context.Context

ContextWithoutBaggage returns a copy of parent with no baggage.

func Handle

func Handle(err error)

Handle is a convenience function for ErrorHandler().Handle(err).

func NewSetWithFiltered

func NewSetWithFiltered(kvs []KeyValue, filter Filter) (Set, []KeyValue)

NewSetWithFiltered returns a new Set. See the documentation for NewSetWithSortableFiltered for more details.

This call includes a Filter to include/exclude attribute keys from the return value. Excluded keys are returned as a slice of attribute values.

func NewSetWithSortableFiltered

func NewSetWithSortableFiltered(kvs []KeyValue, tmp *Sortable, filter Filter) (Set, []KeyValue)

NewSetWithSortableFiltered returns a new Set.

Duplicate keys are eliminated by taking the last value. This re-orders the input slice so that unique last-values are contiguous at the end of the slice.

This ensures the following:

- Last-value-wins semantics - Caller sees the reordering, but doesn't lose values - Repeated call preserve last-value wins.

Note that methods are defined on Set, although this returns Set. Callers can avoid memory allocations by:

- allocating a Sortable for use as a temporary in this method - allocating a Set for storing the return value of this constructor.

The result maintains a cache of encoded attributes, by attribute.EncoderID. This value should not be copied after its first use.

The second []KeyValue return value is a list of attributes that were excluded by the Filter (if non-nil).

func SetErrorHandler

func SetErrorHandler(h ErrorHandler)

SetErrorHandler sets the global ErrorHandler to h.

The first time this is called all ErrorHandler previously returned from GetErrorHandler will send errors to h instead of the default logging ErrorHandler. Subsequent calls will set the global ErrorHandler, but not delegate errors to h.

func SetGlobalMeterProvider

func SetGlobalMeterProvider(mp MeterProvider)

SetGlobalMeterProvider registers `mp` as the global meter provider.

func SetLogger

func SetLogger(logger logr.Logger)

SetLogger configures the logger used internally to opentelemetry.

func SetTextMapPropagator

func SetTextMapPropagator(propagator TextMapPropagator)

SetTextMapPropagator sets propagator as the global TextMapPropagator.

func SetTracerProvider

func SetTracerProvider(tp TracerProvider)

SetTracerProvider registers `tp` as the global trace provider.

func TraceIDFromHex

func TraceIDFromHex(h string) (trace.TraceID, error)

TraceIDFromHex returns a TraceID from a hex string if it is compliant with the W3C trace-context specification. See more at https://www.w3.org/TR/trace-context/#trace-id nolint:revive // revive complains about stutter of `trace.TraceIDFromHex`.

func Version

func Version() string

Version is the current release version of OpenTelemetry in use.

Types

type AsyncFloat64Counter

type AsyncFloat64Counter = asyncfloat64.Counter

AsyncFloat64Counter is an instrument that records increasing values.

type AsyncFloat64Gauge

type AsyncFloat64Gauge = asyncfloat64.Gauge

AsyncFloat64Gauge is an instrument that records independent readings.

type AsyncFloat64InstrumentProvider

type AsyncFloat64InstrumentProvider = asyncfloat64.InstrumentProvider

InstrumentProvider provides access to individual instruments.

type AsyncFloat64UpDownCounter

type AsyncFloat64UpDownCounter = asyncfloat64.UpDownCounter

AsyncFloat64UpDownCounter is an instrument that records increasing or decresing values.

type AsyncInt64Counter

type AsyncInt64Counter = asyncint64.Counter

AsyncInt64Counter is an instrument that records increasing values.

type AsyncInt64InstrumentProvider

type AsyncInt64InstrumentProvider = asyncint64.InstrumentProvider

AsyncInt64InstrumentProvider provides access to individual instruments.

type AsyncInt64UpDownCounter

type AsyncInt64UpDownCounter = asyncint64.UpDownCounter

AsyncInt64UpDownCounter is an instrument that records increasing or decresing values.

type Asynchronous

type Asynchronous = instrument.Asynchronous

Asynchronous instruments are instruments that are updated within a Callback. If an instrument is observed outside of it's callback it should be an error.

This interface is used as a grouping mechanism.

type AttributeIterator

type AttributeIterator = attribute.Iterator

AttributeIterator allows iterating over the set of attributes in order, sorted by key.

type AttributeMergeIterator

type AttributeMergeIterator = attribute.MergeIterator

AttributeMergeIterator supports iterating over two sets of attributes while eliminating duplicate values from the combined set. The first iterator value takes precedence.

func AttributeNewMergeIterator

func AttributeNewMergeIterator(s1, s2 *Set) AttributeMergeIterator

AttributeNewMergeIterator returns a MergeIterator for merging two attribute sets. Duplicates are resolved by taking the value from the first set.

type Baggage

type Baggage = baggage.Baggage

Baggage is a list of baggage members representing the baggage-string as defined by the W3C Baggage specification.

func FromContext

func FromContext(ctx context.Context) Baggage

FromContext returns the baggage contained in ctx.

func NewBaggage

func NewBaggage(members ...BaggageMember) (Baggage, error)

NewBaggage returns a new valid Baggage. It returns an error if it results in a Baggage exceeding limits set in that specification.

It expects all the provided members to have already been validated.

func ParseBaggage

func ParseBaggage(bStr string) (Baggage, error)

ParseBaggage attempts to decode a baggage-string from the passed string. It returns an error if the input is invalid according to the W3C Baggage specification.

If there are duplicate list-members contained in baggage, the last one defined (reading left-to-right) will be the only one kept. This diverges from the W3C Baggage specification which allows duplicate list-members, but conforms to the OpenTelemetry Baggage specification.

type BaggageMember

type BaggageMember = baggage.Member

BaggageMember is a list-member of a baggage-string as defined by the W3C Baggage specification.

func NewMember

func NewMember(key, value string, props ...BaggageProperty) (BaggageMember, error)

NewMember returns a new Member from the passed arguments. An error is returned if the created Member would be invalid according to the W3C Baggage specification.

type BaggageProperty

type BaggageProperty = baggage.Property

BaggageProperty is an additional metadata entry for a baggage list-member.

func NewKeyProperty

func NewKeyProperty(key string) (BaggageProperty, error)

func NewKeyValueProperty

func NewKeyValueProperty(key, value string) (BaggageProperty, error)

type Code

type Code = codes.Code

Code is an 32-bit representation of a status state.

const (
	// Unset is the default status code.
	Unset Code = codes.Unset
	// Error indicates the operation contains an error.
	Error Code = codes.Error
	// OK indicates operation has been validated by an Application developers
	// or Operator to have completed successfully, or contain no error.
	OK Code = codes.Ok
)

type Distinct

type Distinct = attribute.Distinct

Distinct wraps a variable-size array of KeyValue, constructed with keys in sorted order. This can be used as a map key or for equality checking between Sets.

type Encoder

type Encoder = attribute.Encoder

Encoder is a mechanism for serializing an attribute set into a specific string representation that supports caching, to avoid repeated serialization. An example could be an exporter encoding the attribute set into a wire representation.

func DefaultEncoder

func DefaultEncoder() Encoder

DefaultEncoder returns an attribute encoder that encodes attributes in such a way that each escaped attribute's key is followed by an equal sign and then by an escaped attribute's value. All key-value pairs are separated by a comma.

Escaping is done by prepending a backslash before either a backslash, equal sign or a comma.

type EncoderID

type EncoderID = attribute.EncoderID

EncoderID is used to identify distinct Encoder implementations, for caching encoded results.

func NewEncoderID

func NewEncoderID() EncoderID

NewEncoderID returns a unique attribute encoder ID. It should be called once per each type of attribute encoder. Preferably in init() or in var definition.

type ErrorHandler

type ErrorHandler = otel.ErrorHandler

ErrorHandler handles irremediable events.

func GetErrorHandler

func GetErrorHandler() ErrorHandler

GetErrorHandler returns the global ErrorHandler instance.

The default ErrorHandler instance returned will log all errors to STDERR until an override ErrorHandler is set with SetErrorHandler. All ErrorHandler returned prior to this will automatically forward errors to the set instance instead of logging.

Subsequent calls to SetErrorHandler after the first will not forward errors to the new ErrorHandler for prior returned instances.

type ErrorHandlerFunc

type ErrorHandlerFunc = otel.ErrorHandlerFunc

ErrorHandlerFunc is a convenience adapter to allow the use of a function as an ErrorHandler.

type EventConfig

type EventConfig = trace.EventConfig

EventConfig is a group of options for an Event.

func NewEventConfig

func NewEventConfig(options ...EventOption) EventConfig

NewEventConfig applies all the EventOptions to a returned EventConfig. If no timestamp option is passed, the returned EventConfig will have a Timestamp set to the call time, otherwise no validation is performed on the returned EventConfig.

type EventOption

type EventOption = trace.EventOption

EventOption applies span event options to an EventConfig.

type Filter

type Filter = attribute.Filter

Filter supports removing certain attributes from attribute sets. When the filter returns true, the attribute will be kept in the filtered attribute set. When the filter returns false, the attribute is excluded from the filtered attribute set, and the attribute instead appears in the removed list of excluded attributes.

type Gauge

type Gauge = asyncint64.Gauge

Gauge is an instrument that records independent readings.

type HeaderCarrier

type HeaderCarrier = propagation.HeaderCarrier

HeaderCarrier adapts http.Header to satisfy the TextMapCarrier interface.

type InstrumentConfig

type InstrumentConfig = instrument.Config

InstrumentConfig contains options for metric instrument descriptors.

func NewInstrumentConfig

func NewInstrumentConfig(opts ...InstrumentOption) InstrumentConfig

NewInstrumentConfig creates a new Config and applies all the given options.

type InstrumentOption

type InstrumentOption = instrument.Option

InstrumentOption is an interface for applying metric instrument options.

func WithInstrumentDescription

func WithInstrumentDescription(desc string) InstrumentOption

WithInstrumentDescription applies provided description.

func WithInstrumentUnit

func WithInstrumentUnit(unit MetricUnit) InstrumentOption

WithInstrumentUnit applies provided unit.

type InstrumentProvider

type InstrumentProvider = syncfloat64.InstrumentProvider

InstrumentProvider provides access to individual instruments.

type Key

type Key = attribute.Key

Key represents the key part in key-value pairs. It's a string. The allowed character set in the key depends on the use of the key.

type KeyValue

type KeyValue = attribute.KeyValue

KeyValue holds a key and value pair.

func AttributeBool

func AttributeBool(k string, v bool) KeyValue

AttributeBool creates a KeyValue with a BOOL Value type.

func AttributeBoolSlice

func AttributeBoolSlice(k string, v []bool) KeyValue

AttributeBoolSlice creates a KeyValue with a BOOLSLICE Value type.

func AttributeFloat64

func AttributeFloat64(k string, v float64) KeyValue

AttributeFloat64 creates a KeyValue with a FLOAT64 Value type.

func AttributeFloat64Slice

func AttributeFloat64Slice(k string, v []float64) KeyValue

AttributeFloat64Slice creates a KeyValue with a FLOAT64SLICE Value type.

func AttributeInt

func AttributeInt(k string, v int) KeyValue

AttributeInt creates a KeyValue with an INT64 Value type.

func AttributeInt64

func AttributeInt64(k string, v int64) KeyValue

AttributeInt64 creates a KeyValue with an INT64 Value type.

func AttributeInt64Slice

func AttributeInt64Slice(k string, v []int64) KeyValue

AttributeInt64Slice creates a KeyValue with an INT64SLICE Value type.

func AttributeIntSlice

func AttributeIntSlice(k string, v []int) KeyValue

AttributeIntSlice creates a KeyValue with an INT64SLICE Value type.

func AttributeString

func AttributeString(k, v string) KeyValue

AttributeString creates a KeyValue with a STRING Value type.

func AttributeStringSlice

func AttributeStringSlice(k string, v []string) KeyValue

AttributeStringSlice creates a KeyValue with a STRINGSLICE Value type.

func AttributeStringer

func AttributeStringer(k string, v fmt.Stringer) KeyValue

Stringer creates a new key-value pair with a passed name and a string Attributevalue generated by the passed Stringer interface.

type Link = trace.Link

Link is the relationship between two Spans. The relationship can be within the same Trace or across different Traces.

For example, a Link is used in the following situations:

  1. Batch Processing: A batch of operations may contain operations associated with one or more traces/spans. Since there can only be one parent SpanContext, a Link is used to keep reference to the SpanContext of all operations in the batch.
  2. Public Endpoint: A SpanContext for an in incoming client request on a public endpoint should be considered untrusted. In such a case, a new trace with its own identity and sampling decision needs to be created, but this new trace needs to be related to the original trace in some form. A Link is used to keep reference to the original SpanContext and track the relationship.

func LinkFromContext

func LinkFromContext(ctx context.Context, attrs ...KeyValue) Link

LinkFromContext returns a link encapsulating the SpanContext in the provided ctx.

type MapCarrier

type MapCarrier = propagation.MapCarrier

MapCarrier is a TextMapCarrier that uses a map held in memory as a storage medium for propagated key-value pairs.

type Meter

type Meter = metric.Meter

Meter provides access to instrument instances for recording metrics.

func GlobalMeter

func GlobalMeter(instrumentationName string, opts ...MeterOption) Meter

Meter returns a Meter from the global MeterProvider. The instrumentationName must be the name of the library providing instrumentation. This name may be the same as the instrumented code only if that code provides built-in instrumentation. If the instrumentationName is empty, then a implementation defined default name will be used instead.

This is short for MeterProvider().Meter(name).

type MeterConfig

type MeterConfig = metric.MeterConfig

MeterConfig contains options for Meters.

func NewMeterConfig

func NewMeterConfig(opts ...MeterOption) MeterConfig

NewMeterConfig creates a new MeterConfig and applies all the given options.

type MeterOption

type MeterOption = metric.MeterOption

MeterOption is an interface for applying Meter options.

func WithInstrumentationVersion

func WithInstrumentationVersion(version string) MeterOption

WithInstrumentationVersion sets the instrumentation version.

func WithSchemaURL

func WithSchemaURL(schemaURL string) MeterOption

WithSchemaURL sets the schema URL.

type MeterProvider

type MeterProvider = metric.MeterProvider

MeterProvider provides access to named Meter instances, for instrumenting an application or library.

func GlobalMeterProvider

func GlobalMeterProvider() MeterProvider

MeterProvider returns the registered global trace provider. If none is registered then a No-op MeterProvider is returned.

type MetricUnit

type MetricUnit = unit.Unit

type PropagationBaggage

type PropagationBaggage = propagation.Baggage

Baggage is a propagator that supports the W3C Baggage format.

This propagates user-defined baggage associated with a trace. The complete specification is defined at https://www.w3.org/TR/baggage/.

type Set

type Set = attribute.Set

Set is the representation for a distinct attribute set. It manages an immutable set of attributes, with an internal cache for storing attribute encodings.

This type supports the Equivalent method of comparison using values of type Distinct.

func EmptySet

func EmptySet() *Set

EmptySet returns a reference to a Set with no elements.

This is a convenience provided for optimized calling utility.

func NewSet

func NewSet(kvs ...KeyValue) Set

NewSet returns a new Set. See the documentation for NewSetWithSortableFiltered for more details.

Except for empty sets, this method adds an additional allocation compared with calls that include a Sortable.

func NewSetWithSortable

func NewSetWithSortable(kvs []KeyValue, tmp *Sortable) Set

NewSetWithSortable returns a new Set. See the documentation for NewSetWithSortableFiltered for more details.

This call includes a Sortable option as a memory optimization.

type Sortable

type Sortable = attribute.Sortable

Sortable implements sort.Interface, used for sorting KeyValue. This is an exported type to support a memory optimization. A pointer to one of these is needed for the call to sort.Stable(), which the caller may provide in order to avoid an allocation. See NewSetWithSortable().

type Span

type Span = trace.Span

Span is the individual component of a trace. It represents a single named and timed operation of a workflow that is traced. A Tracer is used to create a Span and it is then up to the operation the Span represents to properly end the Span when the operation itself ends.

Warning: methods may be added to this interface in minor releases.

func SpanFromContext

func SpanFromContext(ctx context.Context) Span

SpanFromContext returns the current Span from ctx.

If no Span is currently set in ctx an implementation of a Span that performs no operations is returned.

type SpanConfig

type SpanConfig = trace.SpanConfig

SpanConfig is a group of options for a Span.

func NewSpanEndConfig

func NewSpanEndConfig(options ...SpanEndOption) SpanConfig

NewSpanEndConfig applies all the options to a returned SpanConfig. No validation is performed on the returned SpanConfig (e.g. no uniqueness checking or bounding of data), it is left to the SDK to perform this action.

func NewSpanStartConfig

func NewSpanStartConfig(options ...SpanStartOption) SpanConfig

NewSpanStartConfig applies all the options to a returned SpanConfig. No validation is performed on the returned SpanConfig (e.g. no uniqueness checking or bounding of data), it is left to the SDK to perform this action.

type SpanContext

type SpanContext = trace.SpanContext

SpanContext contains identifying trace information about a Span.

func NewSpanContext

func NewSpanContext(config SpanContextConfig) SpanContext

NewSpanContext constructs a SpanContext using values from the provided SpanContextConfig.

func SpanContextFromContext

func SpanContextFromContext(ctx context.Context) SpanContext

SpanContextFromContext returns the current Span's SpanContext.

type SpanContextConfig

type SpanContextConfig = trace.SpanContextConfig

SpanContextConfig contains mutable fields usable for constructing an immutable SpanContext.

type SpanEndEventOption

type SpanEndEventOption = trace.SpanEndEventOption

SpanEndEventOption are options that can be used at the end of a span, or with an event.

func WithStackTrace

func WithStackTrace(b bool) SpanEndEventOption

WithStackTrace sets the flag to capture the error with stack trace (e.g. true, false).

type SpanEndOption

type SpanEndOption = trace.SpanEndOption

SpanEndOption applies an option to a SpanConfig. These options are applicable only when the span is ended.

type SpanEventOption

type SpanEventOption = trace.SpanEventOption

SpanEventOption are options that can be used with an event or a span.

func WithTimestamp

func WithTimestamp(t time.Time) SpanEventOption

WithTimestamp sets the time of a Span or Event life-cycle moment (e.g. started, stopped, errored).

type SpanID

type SpanID = trace.SpanID

SpanID is a unique identity of a span in a trace.

func SpanIDFromHex

func SpanIDFromHex(h string) (SpanID, error)

SpanIDFromHex returns a SpanID from a hex string if it is compliant with the w3c trace-context specification. See more at https://www.w3.org/TR/trace-context/#parent-id

type SpanKind

type SpanKind = trace.SpanKind

SpanKind is the role a Span plays in a Trace.

func ValidateSpanKind

func ValidateSpanKind(spanKind SpanKind) SpanKind

ValidateSpanKind returns a valid span kind value. This will coerce invalid values into the default value, SpanKindInternal.

type SpanOption

type SpanOption = trace.SpanOption

SpanOption are options that can be used at both the beginning and end of a span.

type SpanStartEventOption

type SpanStartEventOption = trace.SpanStartEventOption

SpanStartEventOption are options that can be used at the start of a span, or with an event.

func WithAttributes

func WithAttributes(attributes ...KeyValue) SpanStartEventOption

WithAttributes adds the attributes related to a span life-cycle event. These attributes are used to describe the work a Span represents when this option is provided to a Span's start or end events. Otherwise, these attributes provide additional information about the event being recorded (e.g. error, state change, processing progress, system event).

If multiple of these options are passed the attributes of each successive option will extend the attributes instead of overwriting. There is no guarantee of uniqueness in the resulting attributes.

type SpanStartOption

type SpanStartOption = trace.SpanStartOption

SpanStartOption applies an option to a SpanConfig. These options are applicable only when the span is created.

func WithLinks(links ...Link) SpanStartOption

WithLinks adds links to a Span. The links are added to the existing Span links, i.e. this does not overwrite. Links with invalid span context are ignored.

func WithNewRoot

func WithNewRoot() SpanStartOption

WithNewRoot specifies that the Span should be treated as a root Span. Any existing parent span context will be ignored when defining the Span's trace identifiers.

func WithSpanKind

func WithSpanKind(kind SpanKind) SpanStartOption

WithSpanKind sets the SpanKind of a Span.

type SyncFloat64Counter

type SyncFloat64Counter = syncfloat64.Counter

SyncFloat64Counter is an instrument that records increasing values.

type SyncFloat64Histogram

type SyncFloat64Histogram = syncfloat64.Histogram

SyncFloat64Histogram is an instrument that records a distribution of values.

type SyncFloat64UpDownCounter

type SyncFloat64UpDownCounter = syncfloat64.UpDownCounter

SyncFloat64UpDownCounter is an instrument that records increasing or decresing values.

type SyncInt64Counter

type SyncInt64Counter = syncint64.Counter

SyncInt64Counter is an instrument that records increasing values.

type SyncInt64Histogram

type SyncInt64Histogram = syncint64.Histogram

SyncInt64Histogram is an instrument that records a distribution of values.

type SyncInt64InstrumentProvider

type SyncInt64InstrumentProvider = syncint64.InstrumentProvider

SyncInt64InstrumentProvider provides access to individual instruments.

type SyncInt64UpDownCounter

type SyncInt64UpDownCounter = syncint64.UpDownCounter

SyncInt64UpDownCounter is an instrument that records increasing or decresing values.

type Synchronous

type Synchronous = instrument.Synchronous

Synchronous instruments are updated in line with application code.

This interface is used as a grouping mechanism.

type TextMapCarrier

type TextMapCarrier = propagation.TextMapCarrier

TextMapCarrier is the storage medium used by a TextMapPropagator.

type TextMapPropagator

type TextMapPropagator = propagation.TextMapPropagator

TextMapPropagator propagates cross-cutting concerns as key-value text pairs within a carrier that travels in-band across process boundaries.

func GetTextMapPropagator

func GetTextMapPropagator() TextMapPropagator

GetTextMapPropagator returns the global TextMapPropagator. If none has been set, a No-Op TextMapPropagator is returned.

func NewCompositeTextMapPropagator

func NewCompositeTextMapPropagator(p ...TextMapPropagator) TextMapPropagator

NewCompositeTextMapPropagator returns a unified TextMapPropagator from the group of passed TextMapPropagator. This allows different cross-cutting concerns to be propagates in a unified manner.

The returned TextMapPropagator will inject and extract cross-cutting concerns in the order the TextMapPropagators were provided. Additionally, the Fields method will return a de-duplicated slice of the keys that are set with the Inject method.

type TraceContext

type TraceContext = propagation.TraceContext

TraceContext is a propagator that supports the W3C Trace Context format (https://www.w3.org/TR/trace-context/)

This propagator will propagate the traceparent and tracestate headers to guarantee traces are not broken. It is up to the users of this propagator to choose if they want to participate in a trace by modifying the traceparent header and relevant parts of the tracestate header containing their proprietary information.

type TraceFlags

type TraceFlags byte

TraceFlags contains flags that can be set on a SpanContext.

type TraceID

type TraceID = trace.TraceID

TraceID is a unique identity of a trace. nolint:revive // revive complains about stutter of `trace.TraceID`.

type TraceState

type TraceState = trace.TraceState

TraceState provides additional vendor-specific trace identification information across different distributed tracing systems. It represents an immutable list consisting of key/value pairs, each pair is referred to as a list-member.

TraceState conforms to the W3C Trace Context specification (https://www.w3.org/TR/trace-context-1). All operations that create or copy a TraceState do so by validating all input and will only produce TraceState that conform to the specification. Specifically, this means that all list-member's key/value pairs are valid, no duplicate list-members exist, and the maximum number of list-members (32) is not exceeded.

func ParseTraceState

func ParseTraceState(tracestate string) (TraceState, error)

ParseTraceState attempts to decode a TraceState from the passed string. It returns an error if the input is invalid according to the W3C Trace Context specification.

type Tracer

type Tracer = trace.Tracer

Tracer is the creator of Spans.

Warning: methods may be added to this interface in minor releases.

func NewTracer

func NewTracer(name string, opts ...TracerOption) Tracer

NewTracer creates a named tracer that implements Tracer interface. If the name is an empty string then provider uses default name.

This is short for GetTracerProvider().Tracer(name, opts...)

type TracerConfig

type TracerConfig = trace.TracerConfig

TracerConfig is a group of options for a Tracer.

func NewTracerConfig

func NewTracerConfig(options ...TracerOption) TracerConfig

NewTracerConfig applies all the options to a returned TracerConfig.

type TracerOption

type TracerOption = trace.TracerOption

TracerOption applies an option to a TracerConfig.

func TraceWithInstrumentationVersion

func TraceWithInstrumentationVersion(version string) TracerOption

TraceWithInstrumentationVersion sets the instrumentation version.

func TraceWithSchemaURL

func TraceWithSchemaURL(schemaURL string) TracerOption

TraceWithSchemaURL sets the schema URL for the Tracer.

type TracerProvider

type TracerProvider = trace.TracerProvider

TracerProvider provides access to instrumentation Tracers.

Warning: methods may be added to this interface in minor releases.

func GetTracerProvider

func GetTracerProvider() TracerProvider

GetTracerProvider returns the registered global trace provider. If none is registered then an instance of NoopTracerProvider is returned.

Use the trace provider to create a named tracer. E.g.

tracer := otel.GetTracerProvider().Tracer("example.com/foo")

or

tracer := otel.Tracer("example.com/foo")

func NewNoopTracerProvider

func NewNoopTracerProvider() TracerProvider

NewNoopTracerProvider returns an implementation of TracerProvider that performs no operations. The Tracer and Spans created from the returned TracerProvider also perform no operations.

type Type

type Type = attribute.Type

Type describes the type of the data Value holds.

type Value

type Value = attribute.Value

Value represents the value part in key-value pairs.

func BoolSliceValue

func BoolSliceValue(v []bool) Value

BoolSliceValue creates a BOOLSLICE Value.

func BoolValue

func BoolValue(v bool) Value

BoolValue creates a BOOL Value.

func Float64SliceValue

func Float64SliceValue(v []float64) Value

Float64SliceValue creates a FLOAT64SLICE Value.

func Float64Value

func Float64Value(v float64) Value

Float64Value creates a FLOAT64 Value.

func Int64SliceValue

func Int64SliceValue(v []int64) Value

Int64SliceValue creates an INT64SLICE Value.

func Int64Value

func Int64Value(v int64) Value

Int64Value creates an INT64 Value.

func IntSliceValue

func IntSliceValue(v []int) Value

IntSliceValue creates an INTSLICE Value.

func IntValue

func IntValue(v int) Value

IntValue creates an INT64 Value.

func StringSliceValue

func StringSliceValue(v []string) Value

StringSliceValue creates a STRINGSLICE Value.

func StringValue

func StringValue(v string) Value

StringValue creates a STRING Value.

Directories

Path Synopsis
bridge
export

Jump to

Keyboard shortcuts

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