Documentation
¶
Index ¶
- Constants
- type CacheTracer
- func (ct *CacheTracer) EndSpan(span trace.Span)
- func (ct *CacheTracer) GetCacheNameFromContext(ctx context.Context) (string, bool)
- func (ct *CacheTracer) RecordCacheHit(span trace.Span)
- func (ct *CacheTracer) RecordCacheMiss(span trace.Span)
- func (ct *CacheTracer) RecordError(span trace.Span, err error)
- func (ct *CacheTracer) StartDeleteSpan(ctx context.Context, cacheName, key string) (context.Context, trace.Span)
- func (ct *CacheTracer) StartExecuteSpan(ctx context.Context, cacheName, methodName, keyExpr string) (context.Context, trace.Span)
- func (ct *CacheTracer) StartGetSpan(ctx context.Context, cacheName, key string) (context.Context, trace.Span)
- func (ct *CacheTracer) StartSetSpan(ctx context.Context, cacheName, key string, ttlSeconds float64) (context.Context, trace.Span)
- func (ct *CacheTracer) StartSpan(ctx context.Context, operation, cacheName string) (context.Context, trace.Span)
- func (ct *CacheTracer) WithCacheSpan(ctx context.Context, cacheName string) context.Context
- type TracedCacheBackend
- func (t *TracedCacheBackend) Close() error
- func (t *TracedCacheBackend) Delete(ctx context.Context, key string) error
- func (t *TracedCacheBackend) Get(ctx context.Context, key string) (interface{}, bool, error)
- func (t *TracedCacheBackend) Set(ctx context.Context, key string, value interface{}, ttl time.Duration) error
- func (t *TracedCacheBackend) Stats() *backend.CacheStats
- func (t *TracedCacheBackend) WithTracingSpan(ctx context.Context, operation string) (context.Context, trace.Span)
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 (*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 ¶
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) Delete ¶
func (t *TracedCacheBackend) Delete(ctx context.Context, key string) error
Delete 删除缓存值并记录追踪
func (*TracedCacheBackend) Set ¶
func (t *TracedCacheBackend) Set(ctx context.Context, key string, value interface{}, ttl time.Duration) error
Set 设置缓存值并记录追踪
func (*TracedCacheBackend) Stats ¶
func (t *TracedCacheBackend) Stats() *backend.CacheStats
Stats 获取统计信息
func (*TracedCacheBackend) WithTracingSpan ¶
func (t *TracedCacheBackend) WithTracingSpan(ctx context.Context, operation string) (context.Context, trace.Span)
WithTracingSpan 在上下文中添加追踪 Span
Click to show internal directories.
Click to hide internal directories.