exptel

package
v0.33.13 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package exptel is a fork of core Span types from opentelemetry-go v0.2.0.

https://github.com/open-telemetry/opentelemetry-go/tree/v0.2.0

These are used to maintain serialization compatibility for the `experimental_telemetry_cmd` output, which uses the JSON serialization of these directly. The canonical JSON serialization for OTLP is not standardized as of Sept 2021 and was removed as a requirement for v1.0 GA.

See https://github.com/open-telemetry/opentelemetry-proto/issues/230.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Code

type Code uint32

type Event

type Event struct {
	// Message describes the Event.
	Message string

	// Attributes contains a list of keyvalue pairs.
	Attributes []KeyValue

	// Time is the time at which this event was recorded.
	Time time.Time
}

Event is used to describe an Event with a message string and set of Attributes.

func NewEventsFromOtel

func NewEventsFromOtel(e []sdktrace.Event) []Event

type ExperimentalTelemetrySpan

type ExperimentalTelemetrySpan struct {
	SpanContext  SpanContext
	ParentSpanID SpanID
	SpanKind     SpanKind
	Name         string
	StartTime    time.Time
	// The wall clock time of EndTime will be adjusted to always be offset
	// from StartTime by the duration of the span.
	EndTime                  time.Time
	Attributes               []KeyValue
	MessageEvents            []Event
	Links                    []Link
	Status                   Code
	HasRemoteParent          bool
	DroppedAttributeCount    int
	DroppedMessageEventCount int
	DroppedLinkCount         int

	// ChildSpanCount holds the number of child span created for this span.
	ChildSpanCount int
}

ExperimentalTelemetrySpan contains all the information collected by a span.

func NewSpanFromOtel

func NewSpanFromOtel(sd sdktrace.ReadOnlySpan, spanNamePrefix string) ExperimentalTelemetrySpan

NewSpanFromOtel converts an OpenTelemetry span to a type suitable for JSON marshaling for usage with `experimental_telemetry_cmd`.

This format corresponds to the JSON marshaling from opentelemetry-go v0.2.0. See the package docs for more details.

spanNamePrefix can be used to provide a prefix for the outgoing span name to mimic old opentelemetry-go behavior which would prepend the tracer name to each span. (See https://github.com/open-telemetry/opentelemetry-go/pull/430).

type Key

type Key string

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.

func (Key) Bool

func (k Key) Bool(v bool) KeyValue

Bool creates a KeyValue instance with a BOOL Value.

func (Key) Defined

func (k Key) Defined() bool

Defined returns true for non-empty keys.

func (Key) Float32

func (k Key) Float32(v float32) KeyValue

Float32 creates a KeyValue instance with a FLOAT32 Value.

func (Key) Float64

func (k Key) Float64(v float64) KeyValue

Float64 creates a KeyValue instance with a FLOAT64 Value.

func (Key) Int

func (k Key) Int(v int) KeyValue

Int creates a KeyValue instance with either an INT32 or an INT64 Value, depending on whether the int type is 32 or 64 bits wide.

func (Key) Int32

func (k Key) Int32(v int32) KeyValue

Int32 creates a KeyValue instance with an INT32 Value.

func (Key) Int64

func (k Key) Int64(v int64) KeyValue

Int64 creates a KeyValue instance with an INT64 Value.

func (Key) String

func (k Key) String(v string) KeyValue

String creates a KeyValue instance with a STRING Value.

func (Key) Uint

func (k Key) Uint(v uint) KeyValue

Uint creates a KeyValue instance with either an UINT32 or an UINT64 Value, depending on whether the uint type is 32 or 64 bits wide.

func (Key) Uint32

func (k Key) Uint32(v uint32) KeyValue

Uint32 creates a KeyValue instance with a UINT32 Value.

func (Key) Uint64

func (k Key) Uint64(v uint64) KeyValue

Uint64 creates a KeyValue instance with a UINT64 Value.

type KeyValue

type KeyValue struct {
	Key   Key
	Value Value
}

KeyValue holds a key and value pair.

func NewKeyValuesFromOtel

func NewKeyValuesFromOtel(kv []attribute.KeyValue) []KeyValue
type Link struct {
	SpanContext
	Attributes []KeyValue
}

Link is used to establish relationship between two spans within the same Trace or across different Traces. Few examples of Link usage.

  1. Batch Processing: A batch of elements may contain elements associated with one or more traces/spans. Since there can only be one parent SpanContext, Link is used to keep reference to SpanContext of all elements in the batch.
  2. Public Endpoint: A SpanContext in incoming client request on a public endpoint is untrusted from service provider perspective. In such case it is advisable to start a new trace with appropriate sampling decision. However, it is desirable to associate incoming SpanContext to new trace initiated on service provider side so two traces (from Client and from Service Provider) can be correlated.

func NewLinksFromOtel

func NewLinksFromOtel(l []sdktrace.Link) []Link

type SpanContext

type SpanContext struct {
	TraceID    TraceID
	SpanID     SpanID
	TraceFlags byte
}

SpanContext contains basic information about the span - its trace ID, span ID and trace flags.

func NewSpanContextFromOtel

func NewSpanContextFromOtel(c trace.SpanContext) SpanContext

type SpanID

type SpanID [8]byte

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

func (SpanID) MarshalJSON

func (s SpanID) MarshalJSON() ([]byte, error)

MarshalJSON implements a custom marshal function to encode SpanID as a hex string.

type SpanKind

type SpanKind int

SpanKind represents the role of a Span inside a Trace. Often, this defines how a Span will be processed and visualized by various backends.

type TraceID

type TraceID [16]byte

TraceID is a unique identity of a trace.

func (TraceID) MarshalJSON

func (t TraceID) MarshalJSON() ([]byte, error)

MarshalJSON implements a custom marshal function to encode TraceID as a hex string.

type Value

type Value struct {
	// contains filtered or unexported fields
}

Value represents the value part in key-value pairs.

func Bool

func Bool(v bool) Value

Bool creates a BOOL Value.

func Float32

func Float32(v float32) Value

Float32 creates a FLOAT32 Value.

func Float64

func Float64(v float64) Value

Float64 creates a FLOAT64 Value.

func Int

func Int(v int) Value

Int creates either an INT32 or an INT64 Value, depending on whether the int type is 32 or 64 bits wide.

func Int32

func Int32(v int32) Value

Int32 creates an INT32 Value.

func Int64

func Int64(v int64) Value

Int64 creates an INT64 Value.

func String

func String(v string) Value

String creates a STRING Value.

func Uint

func Uint(v uint) Value

Uint creates either a UINT32 or a UINT64 Value, depending on whether the uint type is 32 or 64 bits wide.

func Uint32

func Uint32(v uint32) Value

Uint32 creates a UINT32 Value.

func Uint64

func Uint64(v uint64) Value

Uint64 creates a UINT64 Value.

func (*Value) AsBool

func (v *Value) AsBool() bool

Bool returns the bool value. Make sure that the Value's type is BOOL.

func (*Value) AsFloat32

func (v *Value) AsFloat32() float32

AsFloat32 returns the float32 value. Make sure that the Value's type is FLOAT32.

func (*Value) AsFloat64

func (v *Value) AsFloat64() float64

AsFloat64 returns the float64 value. Make sure that the Value's type is FLOAT64.

func (*Value) AsInt32

func (v *Value) AsInt32() int32

AsInt32 returns the int32 value. Make sure that the Value's type is INT32.

func (*Value) AsInt64

func (v *Value) AsInt64() int64

AsInt64 returns the int64 value. Make sure that the Value's type is INT64.

func (*Value) AsInterface

func (v *Value) AsInterface() interface{}

AsInterface returns Value's data as interface{}.

func (*Value) AsString

func (v *Value) AsString() string

AsString returns the string value. Make sure that the Value's type is STRING.

func (*Value) AsUint32

func (v *Value) AsUint32() uint32

AsUint32 returns the uint32 value. Make sure that the Value's type is UINT32.

func (*Value) AsUint64

func (v *Value) AsUint64() uint64

AsUint64 returns the uint64 value. Make sure that the Value's type is UINT64.

func (*Value) Emit

func (v *Value) Emit() string

Emit returns a string representation of Value's data.

func (*Value) MarshalJSON

func (v *Value) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of the Value.

func (*Value) Type

func (v *Value) Type() ValueType

Type returns a type of the Value.

type ValueType

type ValueType int

ValueType describes the type of the data Value holds.

const (
	INVALID ValueType = iota // No value.
	BOOL                     // Boolean value, use AsBool() to get it.
	INT32                    // 32 bit signed integral value, use AsInt32() to get it.
	INT64                    // 64 bit signed integral value, use AsInt64() to get it.
	UINT32                   // 32 bit unsigned integral value, use AsUint32() to get it.
	UINT64                   // 64 bit unsigned integral value, use AsUint64() to get it.
	FLOAT32                  // 32 bit floating point value, use AsFloat32() to get it.
	FLOAT64                  // 64 bit floating point value, use AsFloat64() to get it.
	STRING                   // String value, use AsString() to get it.
)

func (ValueType) String

func (i ValueType) String() string

Jump to

Keyboard shortcuts

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