trace

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2025 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         = 2048
	DefaultMaxExportBatchLength   = 512
	DefaultMaxExportBatchByteSize = 4 * 1024 * 1024 // 4MB
	MaxRetryExportBatchLength     = 50
	DefaultScheduleDelay          = 1000 // millisecond

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

Defaults for batchQueueManagerOptions.

Variables

View Source
var DefaultNoopSpan = &noopSpan{}

Functions

This section is empty.

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 []*UploadSpan) error
	ExportFiles(ctx context.Context, files []*UploadFile) error
}

type Options

type Options struct {
	WorkspaceID      string
	UltraLargeReport bool
}

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 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
	WorkspaceID  string
	ParentSpanID string
	StartTime    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) GetDuration

func (s *Span) GetDuration() int64

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) 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) GetTagMap

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

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) SetError

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

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) 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) SetStartTimeFirstResp

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

func (*Span) SetStatusCode

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

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 []*UploadFile) error

func (*SpanExporter) ExportSpans

func (e *SpanExporter) ExportSpans(ctx context.Context, ss []*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(client *httpclient.Client) SpanProcessor

type StartSpanOptions

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

type UploadFile

type UploadFile struct {
	TosKey     string
	Data       string
	UploadType model2.UploadType
	TagKey     string
	Name       string
	FileType   string
	SpaceID    string
}

type UploadSpan

type UploadSpan struct {
	StartedATMicros  int64              `json:"started_at_micros"`
	SpanID           string             `json:"span_id"`
	ParentID         string             `json:"parent_id"`
	TraceID          string             `json:"trace_id"`
	Duration         int64              `json:"duration"`
	WorkspaceID      string             `json:"workspace_id"`
	SpanName         string             `json:"span_name"`
	SpanType         string             `json:"span_type"`
	StatusCode       int32              `json:"status_code"`
	Input            string             `json:"input"`
	Output           string             `json:"output"`
	ObjectStorage    string             `json:"object_storage"`
	SystemTagsString map[string]string  `json:"system_tags_string"`
	SystemTagsLong   map[string]int64   `json:"system_tags_long"`
	SystemTagsDouble map[string]float64 `json:"system_tags_double"`
	TagsString       map[string]string  `json:"tags_string"`
	TagsLong         map[string]int64   `json:"tags_long"`
	TagsDouble       map[string]float64 `json:"tags_double"`
}

type UploadSpanData

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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