telemetry

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: Apache-2.0 Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(ctx context.Context, cfg Config, baseHandler slog.Handler) (shutdownFn func(context.Context) error, logger *slog.Logger, err error)

Init initialises TracerProvider, MeterProvider and returns a composite shutdown function together with a configured *slog.Logger.

If OTLP exporter creation fails the error is logged as a warning and the service continues to operate without telemetry export.

Types

type Config

type Config struct {
	OTLPEndpoint      string // OTEL_EXPORTER_OTLP_ENDPOINT, default "localhost:4317"
	ServiceName       string // OTEL_SERVICE_NAME, default "easyp-api-service"
	PyroscopeEndpoint string // PYROSCOPE_ENDPOINT, default "http://localhost:4040"
}

Config contains telemetry settings.

type TraceHandler

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

TraceHandler wraps an slog.Handler, injecting trace_id and span_id from the OpenTelemetry SpanContext found in the context.Context.

func NewTraceHandler

func NewTraceHandler(inner slog.Handler) *TraceHandler

NewTraceHandler returns a new TraceHandler that delegates to inner.

func (*TraceHandler) Enabled

func (h *TraceHandler) Enabled(ctx context.Context, level slog.Level) bool

Enabled delegates to the inner handler.

func (*TraceHandler) Handle

func (h *TraceHandler) Handle(ctx context.Context, r slog.Record) error

Handle extracts SpanContext from ctx. When the SpanContext is valid it appends trace_id and span_id attributes to the record before forwarding to the inner handler. All existing record attributes are preserved.

func (*TraceHandler) WithAttrs

func (h *TraceHandler) WithAttrs(attrs []slog.Attr) slog.Handler

WithAttrs returns a new TraceHandler wrapping the result of calling WithAttrs on the inner handler.

func (*TraceHandler) WithGroup

func (h *TraceHandler) WithGroup(name string) slog.Handler

WithGroup returns a new TraceHandler wrapping the result of calling WithGroup on the inner handler.

type TracingCore

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

TracingCore — декоратор core.CoreService, добавляющий span-ы трассировки. Проксирует все вызовы в реальный Core.

func NewTracingCore

func NewTracingCore(inner core.CoreService) *TracingCore

NewTracingCore creates a new TracingCore decorator wrapping the given CoreService.

func (*TracingCore) Generate

Generate creates a span "core.Generate" with attribute "plugin.name", proxies the call to the inner service, and on error sets span status to Error with RecordError.

func (*TracingCore) ListPlugins

func (c *TracingCore) ListPlugins(ctx context.Context, filter core.PluginFilter) ([]core.PluginInfo, error)

ListPlugins creates a span "core.ListPlugins", proxies the call to the inner service, and on error sets span status to Error with RecordError.

type TracingPlugin

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

TracingPlugin — декоратор core.Plugin, добавляющий span и метрику длительности.

func NewTracingPlugin

func NewTracingPlugin(inner core.Plugin, tracer trace.Tracer) *TracingPlugin

NewTracingPlugin creates a new TracingPlugin decorator wrapping the given Plugin.

func (*TracingPlugin) Generate

Generate creates a span "plugin.Generate" with attribute "plugin.image", records histogram "plugin.execution.duration" with attribute "plugin.name", and on error sets span status to Error with RecordError.

func (*TracingPlugin) Info

Info proxies the call to the inner Plugin without creating a span.

type TracingRegistry

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

TracingRegistry — декоратор core.Registry, добавляющий span-ы трассировки. Проксирует все вызовы в реальную реализацию Registry.

func NewTracingRegistry

func NewTracingRegistry(inner core.Registry) *TracingRegistry

NewTracingRegistry creates a new TracingRegistry decorator wrapping the given Registry.

func (*TracingRegistry) Get

func (r *TracingRegistry) Get(ctx context.Context, pluginGroup, pluginName, pluginVersion string) (core.Plugin, error)

Get creates a span "registry.Get" with attributes db.system=postgresql, plugin.group, plugin.name, plugin.version. On error sets span status to Error with RecordError. On success wraps the returned Plugin in TracingPlugin.

func (*TracingRegistry) List

List creates a span "registry.List", proxies the call to the inner Registry, and on error sets span status to Error with RecordError.

Jump to

Keyboard shortcuts

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