looptracer

package
v0.0.0-...-d027d8b Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtxKeyEnv = "K_ENV"
	XttEnv    = "x_tt_env"
)
View Source
const (
	TraceContextHeaderParent     = "X-Cozeloop-Traceparent"
	TraceContextHeaderBaggage    = "X-Cozeloop-Tracestate"
	TraceContextHeaderParentW3C  = "traceparent"
	TraceContextHeaderBaggageW3C = "tracestate"
)

trace context header

Variables

This section is empty.

Functions

func InitTracer

func InitTracer(t Tracer)

InitTracer Init the tracer. Must call before GetTracer.

Types

type MultiSpaceSpanExporter

type MultiSpaceSpanExporter struct{}

func (*MultiSpaceSpanExporter) ExportFiles

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

func (*MultiSpaceSpanExporter) ExportSpans

func (e *MultiSpaceSpanExporter) ExportSpans(ctx context.Context, spans []*entity.UploadSpan) error

type Span

type Span interface {
	cozeloop.Span
	SetCallType(callType string)
}

type SpanImpl

type SpanImpl struct {
	LoopSpan cozeloop.Span
}

func (SpanImpl) Finish

func (s SpanImpl) Finish(ctx context.Context)

func (SpanImpl) GetBaggage

func (s SpanImpl) GetBaggage() map[string]string

func (SpanImpl) GetSpanID

func (s SpanImpl) GetSpanID() string

func (SpanImpl) GetStartTime

func (s SpanImpl) GetStartTime() time.Time

func (SpanImpl) GetTraceID

func (s SpanImpl) GetTraceID() string

func (SpanImpl) SetBaggage

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

func (SpanImpl) SetCallType

func (s SpanImpl) SetCallType(callType string)

func (SpanImpl) SetDeploymentEnv

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

func (SpanImpl) SetError

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

func (SpanImpl) SetFinishTime

func (s SpanImpl) SetFinishTime(finishTime time.Time)

func (SpanImpl) SetInput

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

func (SpanImpl) SetInputTokens

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

func (SpanImpl) SetLogID

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

func (SpanImpl) SetMessageID

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

func (SpanImpl) SetMessageIDBaggage

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

func (SpanImpl) SetModelCallOptions

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

func (SpanImpl) SetModelName

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

func (SpanImpl) SetModelProvider

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

func (SpanImpl) SetOutput

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

func (SpanImpl) SetOutputTokens

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

func (SpanImpl) SetPrompt

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

func (SpanImpl) SetRuntime

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

func (SpanImpl) SetServiceName

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

func (SpanImpl) SetStartTimeFirstResp

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

func (SpanImpl) SetStatusCode

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

func (SpanImpl) SetSystemTags

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

func (SpanImpl) SetTags

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

func (SpanImpl) SetThreadID

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

func (SpanImpl) SetThreadIDBaggage

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

func (SpanImpl) SetUserID

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

func (SpanImpl) SetUserIDBaggage

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

func (SpanImpl) ToHeader

func (s SpanImpl) ToHeader() (map[string]string, error)

type StartSpanOption

type StartSpanOption = func(o *StartSpanOptions)

func WithChildOf

func WithChildOf(childOf cozeloop.SpanContext) StartSpanOption

WithChildOf Set the parent span of the span.

func WithSpanWorkspaceID

func WithSpanWorkspaceID(workspaceID string) StartSpanOption

WithSpanWorkspaceID Set the workspaceID of the span. This field is inner field. You should not set it.

func WithStartNewTrace

func WithStartNewTrace() StartSpanOption

WithStartNewTrace Set the parent span of the span. This field is optional. If specified, start a span of a new trace.

func WithStartTime

func WithStartTime(t time.Time) StartSpanOption

WithStartTime Set the start time of the span. This field is optional. If not specified, the time when StartSpan is called will be used as the default.

type StartSpanOptions

type StartSpanOptions struct {
	StartTime     time.Time
	StartNewTrace bool
	WorkspaceID   string
	ChildOf       cozeloop.SpanContext
}

type Tracer

type Tracer interface {
	// StartSpan Generate a span that automatically links to the previous span in the context.
	// The start time of the span starts counting from the call of StartSpan.
	// The generated span will be automatically written into the context.
	// Subsequent spans that need to be chained should call StartSpan based on the new context.
	StartSpan(ctx context.Context, name, spanType string, opts ...StartSpanOption) (context.Context, Span)
	// GetSpanFromContext Get the span from the context.
	GetSpanFromContext(ctx context.Context) Span
	// Flush Force the reporting of spans in the queue.
	Flush(ctx context.Context)
	// Inject Inject the tracer into the context.
	Inject(ctx context.Context) context.Context
	// InjectW3CTraceContext Inject the trace context into W3C trace context specification
	InjectW3CTraceContext(ctx context.Context) map[string]string
}

func GetTracer

func GetTracer() Tracer

GetTracer Get the tracer. Must call InitTracer first.

func NewTracer

func NewTracer(client cozeloop.Client) Tracer

type TracerImpl

type TracerImpl struct {
	cozeloop.Client
}

func (*TracerImpl) Flush

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

func (*TracerImpl) GetSpanFromContext

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

func (*TracerImpl) Inject

func (t *TracerImpl) Inject(ctx context.Context) context.Context

func (*TracerImpl) InjectW3CTraceContext

func (t *TracerImpl) InjectW3CTraceContext(ctx context.Context) map[string]string

func (*TracerImpl) StartSpan

func (t *TracerImpl) StartSpan(ctx context.Context, name, spanType string, opts ...StartSpanOption) (context.Context, Span)

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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