spanattr

package
v0.48.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: Apache-2.0 Imports: 2 Imported by: 1 module, 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

Overview

Package spanattr carries request-scoped span attributes — tenant, user, feature flag, request ID — on a context.Context, so every span started under that ctx (agent run, iteration, chat, execute_tool, sub-agent runs) can be stamped with them without threading values through each instrumentation layer.

Set them once at the request boundary:

ctx = spanattr.With(ctx,
    attribute.String("tenant.id", tenantID),
    attribute.String("enduser.id", userID))
for ev := range loop.RunText(ctx, sessionKey, input) { ... }

The stamping itself is done by the span processor otelsetup installs; this package imports only the OpenTelemetry attribute API and stays free for library consumers.

Attributes are in-process only — unlike W3C Baggage they are never written to outbound headers, so identifiers cannot leak to downstream services. They land on spans, never on metrics: per-tenant or per-user metric labels would make series cardinality unbounded.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func From

func From(ctx context.Context) []attribute.KeyValue

From returns the attributes carried on ctx, or nil. Callers must not modify the returned slice.

func With

func With(ctx context.Context, kvs ...attribute.KeyValue) context.Context

With returns a ctx carrying kvs in addition to any attributes already on ctx. On a key conflict the later value wins. The parent ctx's attributes are never mutated, so concurrent branches can extend the same parent safely.

Types

This section is empty.

Jump to

Keyboard shortcuts

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