telemetry

package
v0.0.0-...-2cbf6af Latest Latest
Warning

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

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

Documentation

Overview

Package telemetry provides functions for managing instrumented code and measure data about that code's performance and operation.

You can setup instrumentation by creating providers

// Create Tracer.
tracer, _ := telemetry.NewTracer("myservicename")

// Create a Meter.
meter, _ := telemetry.NewMeter("myservicename")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(m middleware.Middleware) func(http.Handler) http.Handler

Middleware sets up a handler to record metric of the incoming requests. This middleware will register the route template and not the url path. in case of high cardinality path

Eg: mux register /users/{id}/devices/{device_id} ulr will be /users/12345467/devices/omni_123232 the metric record will be under /users/{id}/devices/{device_id}

func NewMeter

func NewMeter(name string, opts ...func(option *MeterOption)) (*metric.MeterProvider, error)

NewMeter configures the OpenTelemetry Resource and metrics exporter.

A list of attributes can be passed via env variable OTEL_RESOURCE_ATTRIBUTES;

eg:

OTEL_RESOURCE_ATTRIBUTES=service.version=0.0.1,service.namespace=default

see: https://pkg.go.dev/go.opentelemetry.io/otel/semconv/v1.7.0#pkg-constants

func NewTracer

func NewTracer(serviceName string, opts ...func(*TracerOption)) (*sdktrace.TracerProvider, error)

NewTracer returns a new and configured TracerProvider.

You can define the Trace sample rate by env var via OTL_TRACE_SAMPLE_RATE You can define the OTL endpoint by env var via OTL_ENDPOINT A list of attributes can be passed via env variable OTEL_RESOURCE_ATTRIBUTES;

eg:

OTEL_RESOURCE_ATTRIBUTES=service.version=0.0.1,service.namespace=default

see: https://pkg.go.dev/go.opentelemetry.io/otel/semconv/v1.7.0#pkg-constants

func WithOtelEndpoint

func WithOtelEndpoint(endpoint string) func(option *TracerOption)

func WithSampleRate

func WithSampleRate(rate float64) func(*TracerOption)

WithSampleRate set the sample rate of tracing. For example, set sample_rate to 1 if you wanna sampling 100% of trace data. Set 0.5 if you wanna sampling 50% of trace data, and so forth.

Types

type MeterOption

type MeterOption struct {
}

MeterOption for the Meter.

type TracerOption

type TracerOption struct {
	OtlEndpoint string
	SampleRate  float64
}

TracerOption for the Tracer.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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