Documentation
¶
Index ¶
- Constants
- Variables
- func AttrCacheHit(hit bool) attribute.KeyValue
- func AttrInEvent(t any) attribute.KeyValue
- func AttrInstanceID(instanceID string) attribute.KeyValue
- func AttrKey(val string) attribute.KeyValue
- func AttrMessageType(val string) attribute.KeyValue
- func AttrOutEvent(t any) attribute.KeyValue
- func AttrPeerID(pid string) attribute.KeyValue
- func AttrRecordType(val string) attribute.KeyValue
- func DefaultLogger(name string) *slog.Logger
- func FromContext(ctx context.Context, attrs ...attribute.KeyValue) attribute.Set
- func LogAttrError(err error) slog.Attr
- func LogAttrKey(kk kadt.Key) slog.Attr
- func LogAttrPeerID(id kadt.PeerID) slog.Attr
- func NoopMeter() metric.Meter
- func NoopTracer() trace.Tracer
- func StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
- func WithAttributes(ctx context.Context, attrs ...attribute.KeyValue) context.Context
Constants ¶
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
const ( MeterName = "github.com/probe-lab/zikade" TracerName = "github.com/probe-lab/zikade" )
Variables ¶
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 AttrInEvent ¶
AttrInEvent creates an attribute that records the type of an event
func AttrInstanceID ¶
AttrInstanceID identifies a dht instance by the pointer address. Useful for differentiating between different DHTs that have the same peer id.
func AttrMessageType ¶
func AttrOutEvent ¶
AttrOutEvent creates an attribute that records the type of an event being returned
func AttrPeerID ¶
func AttrRecordType ¶
AttrRecordType is currently only used for the provider backend LRU cache
func DefaultLogger ¶
func FromContext ¶
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 NoopTracer ¶
NoopTracer returns a tracer that does not emit traces.
Types ¶
This section is empty.