tracing

package
v0.0.0-...-d283dcf Latest Latest
Warning

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

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

Documentation

Overview

Package tracing wraps cache backends that talk to remote systems with OpenTelemetry spans. In-memory backends are not wrapped: a span per nanosecond-scale operation costs orders of magnitude more than the operation itself.

Spans never carry a cache key verbatim. Callers routinely build keys from bearer credentials — session ids that are the login cookie's own value, MFA challenge ids, password-reset tokens — so exporting the key would stream live credentials to whatever collects traces, where they are readable by anyone with access to it and replayable until they expire. Each span instead carries the key's namespace, which says which cache domain was touched, and a truncated digest, which lets the same key be correlated across spans without being reversible. Everything a cache span is normally read for survives that substitution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Wrapper

type Wrapper[T any] struct {
	// contains filtered or unexported fields
}

Wrapper decorates a Cache implementation with distributed tracing. It is stateless: the caller context of each operation parents its span, and when tracing is disabled every operation forwards to the wrapped cache directly.

func NewWrapper

func NewWrapper[T any](cache types.Cache[T], cacheType string) *Wrapper[T]

NewWrapper creates a new tracing wrapper for the given cache.

func (*Wrapper[T]) Delete

func (tw *Wrapper[T]) Delete(ctx context.Context, key string) error

Delete removes a key from the cache with tracing.

func (*Wrapper[T]) Exists

func (tw *Wrapper[T]) Exists(ctx context.Context, key string) bool

Exists checks if a key exists in the cache with tracing.

func (*Wrapper[T]) Get

func (tw *Wrapper[T]) Get(ctx context.Context, key string) (T, error)

Get retrieves a value by key with tracing.

func (*Wrapper[T]) Set

func (tw *Wrapper[T]) Set(ctx context.Context, key string, value T, ttl time.Duration) error

Set stores a key-value pair with tracing.

Jump to

Keyboard shortcuts

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