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) Handle ¶
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.
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 ¶
func (c *TracingCore) Generate(ctx context.Context, req core.GenerateCodeRequest) (*core.GenerateCodeResponse, error)
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 ¶
func (p *TracingPlugin) Generate(ctx context.Context, req *pluginpb.CodeGeneratorRequest) (*pluginpb.CodeGeneratorResponse, error)
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 ¶
func (p *TracingPlugin) Info(ctx context.Context) *core.PluginInfo
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 ¶
func (r *TracingRegistry) List(ctx context.Context, filter core.PluginFilter) ([]core.PluginInfo, error)
List creates a span "registry.List", proxies the call to the inner Registry, and on error sets span status to Error with RecordError.