tracing

package
v0.0.0-...-3470e27 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TracerName OpenTelemetry Tracer 名称
	TracerName = "go-cache"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheTracer

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

CacheTracer 缓存追踪器

func NewCacheTracer

func NewCacheTracer() *CacheTracer

NewCacheTracer 创建缓存追踪器

func (*CacheTracer) EndSpan

func (ct *CacheTracer) EndSpan(span trace.Span)

EndSpan 结束 Span

func (*CacheTracer) GetCacheNameFromContext

func (ct *CacheTracer) GetCacheNameFromContext(ctx context.Context) (string, bool)

GetCacheNameFromContext 从上下文获取缓存名称

func (*CacheTracer) RecordCacheHit

func (ct *CacheTracer) RecordCacheHit(span trace.Span)

RecordCacheHit 记录缓存命中

func (*CacheTracer) RecordCacheMiss

func (ct *CacheTracer) RecordCacheMiss(span trace.Span)

RecordCacheMiss 记录缓存未命中

func (*CacheTracer) RecordError

func (ct *CacheTracer) RecordError(span trace.Span, err error)

RecordError 记录错误

func (*CacheTracer) StartDeleteSpan

func (ct *CacheTracer) StartDeleteSpan(ctx context.Context, cacheName, key string) (context.Context, trace.Span)

StartDeleteSpan 开始 Delete 操作追踪

func (*CacheTracer) StartExecuteSpan

func (ct *CacheTracer) StartExecuteSpan(ctx context.Context, cacheName, methodName, keyExpr string) (context.Context, trace.Span)

StartExecuteSpan 开始 Execute 操作追踪(用于方法级缓存)

func (*CacheTracer) StartGetSpan

func (ct *CacheTracer) StartGetSpan(ctx context.Context, cacheName, key string) (context.Context, trace.Span)

StartGetSpan 开始 Get 操作追踪

func (*CacheTracer) StartSetSpan

func (ct *CacheTracer) StartSetSpan(ctx context.Context, cacheName, key string, ttlSeconds float64) (context.Context, trace.Span)

StartSetSpan 开始 Set 操作追踪

func (*CacheTracer) StartSpan

func (ct *CacheTracer) StartSpan(ctx context.Context, operation, cacheName string) (context.Context, trace.Span)

StartSpan 开始追踪 Span

func (*CacheTracer) WithCacheSpan

func (ct *CacheTracer) WithCacheSpan(ctx context.Context, cacheName string) context.Context

WithCacheSpan 在上下文中添加缓存 Span 信息

type TracedCacheBackend

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

TracedCacheBackend 带追踪的缓存包装器

func NewTracedCacheBackend

func NewTracedCacheBackend(backend backend.CacheBackend, tracer *CacheTracer, cacheName string) *TracedCacheBackend

NewTracedCacheBackend 创建带追踪的缓存包装器

func (*TracedCacheBackend) Close

func (t *TracedCacheBackend) Close() error

Close 关闭缓存

func (*TracedCacheBackend) Delete

func (t *TracedCacheBackend) Delete(ctx context.Context, key string) error

Delete 删除缓存值并记录追踪

func (*TracedCacheBackend) Get

func (t *TracedCacheBackend) Get(ctx context.Context, key string) (interface{}, bool, error)

Get 获取缓存值并记录追踪

func (*TracedCacheBackend) Set

func (t *TracedCacheBackend) Set(ctx context.Context, key string, value interface{}, ttl time.Duration) error

Set 设置缓存值并记录追踪

func (*TracedCacheBackend) Stats

Stats 获取统计信息

func (*TracedCacheBackend) WithTracingSpan

func (t *TracedCacheBackend) WithTracingSpan(ctx context.Context, operation string) (context.Context, trace.Span)

WithTracingSpan 在上下文中添加追踪 Span

Jump to

Keyboard shortcuts

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