tele

package
v0.0.0-...-e07b07e Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0, MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const (
	AttrKeyError    = "error"
	AttrKeyPeerID   = "peer_id"
	AttrKeyKey      = "key"
	AttrKeyCacheHit = "hit"
	AttrKeyInEvent  = "in_event"
	AttrKeyOutEvent = "out_event"
)

Attributes that can be used with logging or tracing

View Source
const (
	MeterName  = "github.com/probe-lab/zikade"
	TracerName = "github.com/probe-lab/zikade"
)

Variables

View Source
var MeterProviderOpts = []motel.Option{
	motel.WithView(motel.NewView(
		motel.Instrument{Name: "*_bytes", Scope: instrumentation.Scope{Name: MeterName}},
		motel.Stream{
			Aggregation: motel.AggregationExplicitBucketHistogram{
				Boundaries: []float64{1024, 2048, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864, 268435456, 1073741824, 4294967296},
			},
		},
	)),
	motel.WithView(motel.NewView(
		motel.Instrument{Name: "*_request_latency", Scope: instrumentation.Scope{Name: MeterName}},
		motel.Stream{
			Aggregation: motel.AggregationExplicitBucketHistogram{
				Boundaries: []float64{0.01, 0.05, 0.1, 0.3, 0.6, 0.8, 1, 2, 3, 4, 5, 6, 8, 10, 13, 16, 20, 25, 30, 40, 50, 65, 80, 100, 130, 160, 200, 250, 300, 400, 500, 650, 800, 1000, 2000, 5000, 10000, 20000, 50000, 100000},
			},
		},
	)),
}

MeterProviderOpts is a method that returns metric options. Make sure to register these options to your metric.MeterProvider. Unfortunately, attaching these options to an already existing metric.MeterProvider is not possible. Therefore, you can't just register the options with the global MeterProvider that is returned by otel.GetMeterProvider. One example to register a new metric.MeterProvider would be:

provider := metric.NewMeterProvider(tele.MeterProviderOpts()...) // <-- also add your options, like a metric reader
otel.SetMeterProvider(provider)

Then you can use [NewWithGlobalProviders] and it will use a correctly configured meter provider.

The options that MeterProviderOpts returns are just custom histogram boundaries for a few metrics. In the future, we could reconsider these boundaries because we just blindly ported them from v1 to v2 of go-libp2p-kad-dht.

Functions

func AttrCacheHit

func AttrCacheHit(hit bool) attribute.KeyValue

func AttrInEvent

func AttrInEvent(t any) attribute.KeyValue

AttrInEvent creates an attribute that records the type of an event

func AttrInstanceID

func AttrInstanceID(instanceID string) attribute.KeyValue

AttrInstanceID identifies a dht instance by the pointer address. Useful for differentiating between different DHTs that have the same peer id.

func AttrKey

func AttrKey(val string) attribute.KeyValue

func AttrMessageType

func AttrMessageType(val string) attribute.KeyValue

func AttrOutEvent

func AttrOutEvent(t any) attribute.KeyValue

AttrOutEvent creates an attribute that records the type of an event being returned

func AttrPeerID

func AttrPeerID(pid string) attribute.KeyValue

func AttrRecordType

func AttrRecordType(val string) attribute.KeyValue

AttrRecordType is currently only used for the provider backend LRU cache

func DefaultLogger

func DefaultLogger(name string) *slog.Logger

func FromContext

func FromContext(ctx context.Context, attrs ...attribute.KeyValue) attribute.Set

FromContext returns the attributes that were previously associated with the given context via WithAttributes plus any attributes that are also passed into this function. The given attributes will take precedence over any attributes stored in the context.

func LogAttrError

func LogAttrError(err error) slog.Attr

func LogAttrKey

func LogAttrKey(kk kadt.Key) slog.Attr

func LogAttrPeerID

func LogAttrPeerID(id kadt.PeerID) slog.Attr

func NoopMeter

func NoopMeter() metric.Meter

NoopMeter returns a meter provider that does not record or emit metrics.

func NoopTracer

func NoopTracer() trace.Tracer

NoopTracer returns a tracer that does not emit traces.

func StartSpan

func StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)

StartSpan creates a span and a context.Context containing the newly-created span.

func WithAttributes

func WithAttributes(ctx context.Context, attrs ...attribute.KeyValue) context.Context

WithAttributes is a function that attaches the provided attributes to the given context. The given attributes will overwrite any already existing ones.

Types

This section is empty.

Jump to

Keyboard shortcuts

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