telemetry

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttributeHttpHost         = "http.host"
	AttributeHttpMethod       = "http.method"
	AttributeHttpPath         = "http.path"
	AttributeHttpQuery        = "http.query"
	AttributeHttpUserAgent    = "http.userAgent"
	AttributeHttpClientIP     = "http.clientIp"
	AttributeHttpStatusCode   = "http.statusCode"
	AttributeHttpStatusClass  = "http.statusClass"
	AttributeHttpBytesWritten = "http.bytesWritten"
	AttributeHttpRequestID    = "http.requestId"
	AttributeHttpLatencyMS    = "http.latencyMS"
	AttributeExceptionMessage = "exception.message"
	AttributeExceptionType    = "exception.type"
	AttributeExceptionStack   = "exception.stacktrace"
	AttributeExceptionCode    = "exception.code"
)
View Source
const (
	DefaultSampleRate     float64            = 0.5
	DefaultTracerExporter TracerExporterType = TracerExporterOTLP
	DefaultMeterExporter  MeterExporterType  = MeterExporterOTLP
	DefaultLoggerExporter LoggerExporterType = LoggerExporterOTLP

	// application environments
	EnvProduction  EnvironmentType = "production"
	EnvStaging     EnvironmentType = "staging"
	EnvDevelopment EnvironmentType = "development"

	// tracer exporters
	TracerExporterOTLP TracerExporterType = "OTLP"

	// meter exporters
	MeterExporterOTLP MeterExporterType = "OTLP"

	// logger exporters
	LoggerExporterOTLP LoggerExporterType = "otlp"
)

Variables

This section is empty.

Functions

func ConvertToAttributes

func ConvertToAttributes(attrMap map[string]interface{}) []attribute.KeyValue

ConvertToAttributes converts a plain map[string]interface{} into OTEL []attribute.KeyValue, supporting all common primitive types.

Types

type EnvironmentType

type EnvironmentType string // e.g., "production", "staging", "development"

type LoggerExporterType

type LoggerExporterType string // e.g., "OTLP", "Prometheus", etc.

type MeterExporterType

type MeterExporterType string // e.g., "OTLP", "Prometheus", etc.

type Options

type Options struct {
	ServiceName string          // Name of the service
	SampleRate  float64         // Between 0.0 and 1.0 for trace sampling rate
	Environment EnvironmentType // e.g., "production", "staging", "development"

	NoOpTracer     bool               // If true, no tracing will be performed
	TracerExporter TracerExporterType // exporter type, e.g., grafana tempo
	TracerEndpoint *RemoteEndpoint    // remote endpoint for tracing

	NoOpMeter     bool              // If true, no metrics will be collected
	MeterExporter MeterExporterType // exporter type, e.g., otel-collector+prometheus
	MeterEndpoint *RemoteEndpoint   // remote endpoint for metrics collection

	NoOpLogger     bool               // If true, no logging will be performed
	LoggerExporter LoggerExporterType // exporter type, e.g., otel-collector+prometheus
	LoggerEndpoint *RemoteEndpoint    // remote endpoint for logging
}

type RemoteEndpoint

type RemoteEndpoint struct {
	Host     string
	Port     string
	Insecure bool
}

func (*RemoteEndpoint) AsString

func (oe *RemoteEndpoint) AsString() string

type Telemetry

type Telemetry struct {
	Tracer trace.Tracer
	Meter  metric.Meter
	Logger log.Logger
	// contains filtered or unexported fields
}

func Get

func Get() *Telemetry

Get returns the initialized Telemetry instance or a no-op instance when telemetry has not been initialized.

func InitTelemetry

func InitTelemetry(options *Options) (*Telemetry, error)

InitTelemetry initializes OpenTelemetry with the provided options.

func InitTelemetryContext

func InitTelemetryContext(ctx context.Context, options *Options) (*Telemetry, error)

InitTelemetryContext initializes OpenTelemetry with the provided context and options.

func (*Telemetry) Shutdown

func (t *Telemetry) Shutdown(ctx context.Context) error

Shutdown flushes and shuts down telemetry providers that support those lifecycle hooks.

type TracerExporterType

type TracerExporterType string // e.g., "OTLP", "Jaeger", etc.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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