Documentation
¶
Overview ¶
Package testotel provides test utilities for OpenTelemetry tracing tests. This is not internal for use in cmd/extproc/mainlib/main_test.go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RecordNewSpan ¶
func RecordNewSpan(t *testing.T, spanName string, opts ...oteltrace.SpanStartOption) tracetest.SpanStub
RecordNewSpan starts a new span with the given name and options and immediately ends it. Then, it returns the recorded span.
Types ¶
type MockSpan ¶
type MockSpan struct {
Resp *openai.ChatCompletionResponse
RespChunks []*openai.ChatCompletionResponseChunk
ErrorStatus int
ErrBody string
EndSpanCalled bool
}
MockSpan is a mock implementation of api.ChatCompletionSpan for testing purposes.
func (*MockSpan) EndSpanOnError ¶
EndSpanOnError implements api.ChatCompletionSpan.
func (*MockSpan) RecordResponse ¶
func (s *MockSpan) RecordResponse(resp *openai.ChatCompletionResponse)
RecordResponse implements api.ChatCompletionSpan.
func (*MockSpan) RecordResponseChunk ¶
func (s *MockSpan) RecordResponseChunk(resp *openai.ChatCompletionResponseChunk)
RecordResponseChunk implements api.ChatCompletionSpan.
type OTLPCollector ¶
type OTLPCollector struct {
// contains filtered or unexported fields
}
func StartOTLPCollector ¶
func StartOTLPCollector() *OTLPCollector
StartOTLPCollector starts a test OTLP collector server that receives trace data.
func (*OTLPCollector) Close ¶
func (o *OTLPCollector) Close()
Close shuts down the collector and cleans up resources.
func (*OTLPCollector) Env ¶
func (o *OTLPCollector) Env() []string
Env returns the environment variables needed to configure the OTLP collector.
func (*OTLPCollector) SetEnv ¶
func (o *OTLPCollector) SetEnv(setenv func(key string, value string))
SetEnv calls setenv for each environment variable in Env.
func (*OTLPCollector) TakeSpan ¶
func (o *OTLPCollector) TakeSpan() *tracev1.Span
TakeSpan returns a single span or nil if none were recorded.