Help us shape the future of Go! Take the 2026 Go Developer Survey

trace

package
v0.1.23 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyTemplateLargeText     = "%s_%s_%s_%s_large_text"
	KeyTemplateMultiModality = "%s_%s_%s_%s_%s"
)
View Source
const (
	DefaultMaxQueueLength         = 1024
	DefaultMaxRetryQueueLength    = 512
	DefaultMaxExportBatchLength   = 100
	DefaultMaxExportBatchByteSize = 4 * 1024 * 1024 // 4MB
	MaxRetryExportBatchLength     = 50
	DefaultScheduleDelay          = 1000 // millisecond

	MaxFileQueueLength         = 512
	MaxFileExportBatchLength   = 1
	MaxFileExportBatchByteSize = 100 * 1024 * 1024 // 100MB
	FileScheduleDelay          = 5000              // millisecond
)

Defaults for batchQueueManagerOptions.

Variables

View Source
var DefaultNoopSpan = &noopSpan{}

Functions

func DefaultFinishEventProcessor added in v0.1.9

func DefaultFinishEventProcessor(ctx context.Context, info *consts.FinishEventInfo)

Types

type BatchQueueManager

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

BatchQueueManager four queue: span, span retry, file, file retry

func (*BatchQueueManager) Enqueue

func (b *BatchQueueManager) Enqueue(ctx context.Context, sd interface{}, byteSize int64)

func (*BatchQueueManager) ForceFlush

func (b *BatchQueueManager) ForceFlush(ctx context.Context) error

func (*BatchQueueManager) Shutdown

func (b *BatchQueueManager) Shutdown(ctx context.Context) error

type BatchSpanProcessor

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

BatchSpanProcessor implements SpanProcessor

func (*BatchSpanProcessor) ForceFlush

func (b *BatchSpanProcessor) ForceFlush(ctx context.Context) error

func (*BatchSpanProcessor) OnSpanEnd

func (b *BatchSpanProcessor) OnSpanEnd(ctx context.Context, s *Span)

func (*BatchSpanProcessor) Shutdown

func (b *BatchSpanProcessor) Shutdown(ctx context.Context) error

type Exporter

type Exporter interface {
	ExportSpans(ctx context.Context, spans []*entity.UploadSpan) error
	ExportFiles(ctx context.Context, files []*entity.UploadFile) error
}

type Options

type Options struct {
	WorkspaceID          string
	UltraLargeReport     bool
	Exporter             Exporter
	FinishEventProcessor func(ctx context.Context, info *consts.FinishEventInfo)
	TagTruncateConf      *TagTruncateConf
	SpanUploadPath       string
	FileUploadPath       string
	QueueConf            *QueueConf
}

type Provider

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

func NewTraceProvider

func NewTraceProvider(httpClient *httpclient.Client, options Options) *Provider

func (*Provider) CloseTrace

func (t *Provider) CloseTrace(ctx context.Context)

func (*Provider) Flush

func (t *Provider) Flush(ctx context.Context)

func (*Provider) GetOpts

func (t *Provider) GetOpts() *Options

func (*Provider) GetSpanFromContext

func (t *Provider) GetSpanFromContext(ctx context.Context) *Span

func (*Provider) GetSpanFromHeader

func (t *Provider) GetSpanFromHeader(ctx context.Context, header map[string]string) *SpanContext

func (*Provider) StartSpan

func (t *Provider) StartSpan(ctx context.Context, name, spanType string, opts StartSpanOptions) (context.Context, *Span, error)

type QueueConf added in v0.1.9

type QueueConf struct {
	SpanQueueLength          int
	SpanMaxExportBatchLength int
}

type QueueManager

type QueueManager interface {
	Enqueue(ctx context.Context, s interface{}, byteSize int64)
	Shutdown(ctx context.Context) error
	ForceFlush(ctx context.Context) error
}

QueueManager is a queue that batches spans and exports them

type Span

type Span struct {
	// span context param
	SpanContext

	// basic param
	SpanType string
	Name     string

	// These params can be changed, but remember locking when changed
	ServiceName  string
	LogID        string
	WorkspaceID  string
	ParentSpanID string
	StartTime    time.Time
	FinishTime   time.Time
	Duration     time.Duration
	TagMap       map[string]interface{} // custom tags
	SystemTagMap map[string]interface{} // system tags
	StatusCode   int32
	// contains filtered or unexported fields
}

func (*Span) Finish

func (s *Span) Finish(ctx context.Context)

func (*Span) GetBaggage added in v0.1.17

func (s *Span) GetBaggage() map[string]string

func (*Span) GetDuration

func (s *Span) GetDuration() int64

func (*Span) GetFinishTime added in v0.1.9

func (s *Span) GetFinishTime() time.Time

func (*Span) GetLogID added in v0.1.9

func (s *Span) GetLogID() string

func (*Span) GetParentID

func (s *Span) GetParentID() string

func (*Span) GetRectifiedMap

func (s *Span) GetRectifiedMap(ctx context.Context, inputMap map[string]interface{}) (map[string]interface{}, []string, int64)

GetRectifiedMap get rectified tag map and cut off keys

func (*Span) GetServiceName added in v0.1.9

func (s *Span) GetServiceName() string

func (*Span) GetSpaceID

func (s *Span) GetSpaceID() string

func (*Span) GetSpanName

func (s *Span) GetSpanName() string

func (*Span) GetSpanType

func (s *Span) GetSpanType() string

func (*Span) GetStartTime

func (s *Span) GetStartTime() time.Time

func (*Span) GetStatusCode

func (s *Span) GetStatusCode() int32

func (*Span) GetSystemTagMap added in v0.1.23

func (s *Span) GetSystemTagMap() map[string]interface{}

func (*Span) GetTagMap

func (s *Span) GetTagMap() map[string]interface{}

func (*Span) IsRootSpan added in v0.1.9

func (s *Span) IsRootSpan() bool

func (*Span) SetBaggage

func (s *Span) SetBaggage(ctx context.Context, baggageItems map[string]string)

func (*Span) SetBaggageItem

func (s *Span) SetBaggageItem(restrictedKey, value string)

func (*Span) SetDeploymentEnv added in v0.1.9

func (s *Span) SetDeploymentEnv(ctx context.Context, deploymentEnv string)

func (*Span) SetError

func (s *Span) SetError(ctx context.Context, err error)

func (*Span) SetFinishTime added in v0.1.9

func (s *Span) SetFinishTime(finishTime time.Time)

SetFinishTime Default is time.Now() when span Finish(). DO NOT set unless you do not use default time.

func (*Span) SetInput

func (s *Span) SetInput(ctx context.Context, input interface{})

func (*Span) SetInputTokens

func (s *Span) SetInputTokens(ctx context.Context, inputTokens int)

func (*Span) SetLogID added in v0.1.9

func (s *Span) SetLogID(ctx context.Context, logID string)

func (*Span) SetMessageID

func (s *Span) SetMessageID(ctx context.Context, messageID string)

func (*Span) SetMessageIDBaggage

func (s *Span) SetMessageIDBaggage(ctx context.Context, messageID string)

func (*Span) SetModelCallOptions added in v0.1.2

func (s *Span) SetModelCallOptions(ctx context.Context, callOptions interface{})

func (*Span) SetModelName

func (s *Span) SetModelName(ctx context.Context, modelName string)

func (*Span) SetModelProvider

func (s *Span) SetModelProvider(ctx context.Context, modelProvider string)

func (*Span) SetMultiModalityMap

func (s *Span) SetMultiModalityMap(key string)

func (*Span) SetOutput

func (s *Span) SetOutput(ctx context.Context, output interface{})

func (*Span) SetOutputTokens

func (s *Span) SetOutputTokens(ctx context.Context, outputTokens int)

func (*Span) SetPrompt

func (s *Span) SetPrompt(ctx context.Context, prompt entity.Prompt)

func (*Span) SetRuntime added in v0.1.5

func (s *Span) SetRuntime(ctx context.Context, runtime tracespec.Runtime)

func (*Span) SetServiceName added in v0.1.9

func (s *Span) SetServiceName(ctx context.Context, serviceName string)

func (*Span) SetStartTimeFirstResp

func (s *Span) SetStartTimeFirstResp(ctx context.Context, startTimeFirstResp int64)

func (*Span) SetStatusCode

func (s *Span) SetStatusCode(ctx context.Context, code int)

func (*Span) SetSystemTags added in v0.1.9

func (s *Span) SetSystemTags(ctx context.Context, systemTags map[string]interface{})

func (*Span) SetTags

func (s *Span) SetTags(ctx context.Context, tagKVs map[string]interface{})

func (*Span) SetThreadID

func (s *Span) SetThreadID(ctx context.Context, threadID string)

func (*Span) SetThreadIDBaggage

func (s *Span) SetThreadIDBaggage(ctx context.Context, threadID string)

func (*Span) SetUserID

func (s *Span) SetUserID(ctx context.Context, userID string)

func (*Span) SetUserIDBaggage

func (s *Span) SetUserIDBaggage(ctx context.Context, userID string)

func (*Span) ToHeader

func (s *Span) ToHeader() (map[string]string, error)

func (*Span) UltraLargeReport

func (s *Span) UltraLargeReport() bool

type SpanContext

type SpanContext struct {
	SpanID  string
	TraceID string
	Baggage map[string]string
}

func FromHeader

func FromHeader(ctx context.Context, h map[string]string) *SpanContext

func (*SpanContext) GetBaggage

func (s *SpanContext) GetBaggage() map[string]string

func (*SpanContext) GetSpanID

func (s *SpanContext) GetSpanID() string

func (*SpanContext) GetTraceID

func (s *SpanContext) GetTraceID() string

type SpanExporter

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

func (*SpanExporter) ExportFiles

func (e *SpanExporter) ExportFiles(ctx context.Context, files []*entity.UploadFile) error

func (*SpanExporter) ExportSpans

func (e *SpanExporter) ExportSpans(ctx context.Context, ss []*entity.UploadSpan) (err error)

type SpanProcessor

type SpanProcessor interface {
	OnSpanEnd(ctx context.Context, s *Span)
	Shutdown(ctx context.Context) error
	ForceFlush(ctx context.Context) error
}

func NewBatchSpanProcessor

func NewBatchSpanProcessor(
	ex Exporter,
	client *httpclient.Client,
	uploadPath *UploadPath,
	finishEventProcessor func(ctx context.Context, info *consts.FinishEventInfo),
	queueConf *QueueConf,
) SpanProcessor

type StartSpanOptions

type StartSpanOptions struct {
	StartTime     time.Time
	ParentSpanID  string
	SpanID        string
	TraceID       string
	Baggage       map[string]string
	StartNewTrace bool
	Scene         string
	WorkspaceID   string
}

type TagTruncateConf added in v0.1.9

type TagTruncateConf struct {
	NormalFieldMaxByte      int
	InputOutputFieldMaxByte int
}

type UploadPath added in v0.1.9

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

type UploadSpanData

type UploadSpanData struct {
	Spans []*entity.UploadSpan `json:"spans"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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