Documentation
¶
Overview ¶
Package obs provides tenant observability fields, redaction helpers, slog helpers, and OpenTelemetry API helpers.
Index ¶
- Constants
- func AddSpanAttributes(ctx context.Context)
- func Fields(ctx context.Context) map[string]string
- func LogAttrs(ctx context.Context, logger *slog.Logger, level slog.Level, msg string, ...)
- func LoggerWithTenant(ctx context.Context, logger *slog.Logger) *slog.Logger
- func NewTracer(provider trace.TracerProvider) trace.Tracer
- func RecordSpanError(ctx context.Context, err error, description string)
- func Redact(fields map[string]string) map[string]string
- func RedactSlogAttrs(attrs ...slog.Attr) []slog.Attr
- func SlogAttrs(ctx context.Context) []slog.Attr
- func SpanAttributes(ctx context.Context) []attribute.KeyValue
- func StartSpan(ctx context.Context, tracer trace.Tracer, name string, ...) (context.Context, trace.Span)
Constants ¶
const ( // TenantIDField is the standard observability field for tenant ID. TenantIDField = "tenant_id" // TenantSideField is the standard observability field for tenant side. TenantSideField = "tenant_side" )
const (
// InstrumentationName is the OpenTelemetry instrumentation scope name for GoTenancy.
InstrumentationName = "github.com/DarkInno/gotenancy"
)
Variables ¶
This section is empty.
Functions ¶
func AddSpanAttributes ¶ added in v0.1.6
AddSpanAttributes adds tenant attributes to the current span in ctx.
func LogAttrs ¶ added in v0.1.6
func LogAttrs(ctx context.Context, logger *slog.Logger, level slog.Level, msg string, attrs ...slog.Attr)
LogAttrs logs attrs with tenant fields from ctx and redacts sensitive attrs.
func LoggerWithTenant ¶ added in v0.1.6
LoggerWithTenant returns logger enriched with tenant fields from ctx.
func NewTracer ¶ added in v0.1.6
func NewTracer(provider trace.TracerProvider) trace.Tracer
NewTracer returns an OpenTelemetry tracer for GoTenancy.
Libraries should not initialize an SDK or exporter. When provider is nil, the process-global OpenTelemetry provider is used, which is no-op until the host application configures it.
func RecordSpanError ¶ added in v0.1.6
RecordSpanError records a sanitized error event on the current span and marks it as failed.
func RedactSlogAttrs ¶ added in v0.1.6
RedactSlogAttrs returns a redacted copy of attrs.
func SpanAttributes ¶ added in v0.1.6
SpanAttributes returns tenant OpenTelemetry span attributes for ctx.
Types ¶
This section is empty.