MCPcopy Index your code
hub / github.com/docker/docker-agent / StartFallback

Function StartFallback

pkg/telemetry/genai/runtime.go:66–86  ·  view source on GitHub ↗

StartFallback begins a runtime.fallback span covering the whole fallback chain for one agent turn. Each per-model attempt produces its own `chat {model}` CLIENT child span (created by the provider decorator). Attributes set up front: primary model name, agent name, in-cooldown flag. The caller updat

(ctx context.Context, agentName, primaryModel string, inCooldown bool)

Source from the content-addressed store, hash-verified

64// flag. The caller updates final model / attempts / outcome through the
65// returned handle and calls End to flush.
66func StartFallback(ctx context.Context, agentName, primaryModel string, inCooldown bool) (context.Context, *FallbackSpan) {
67 tracer := otel.Tracer(instrumentationName)
68 attrs := []attribute.KeyValue{
69 attribute.String(AttrAgentNameRuntime, agentName),
70 attribute.Bool(AttrFallbackInCooldown, inCooldown),
71 }
72 if primaryModel != "" {
73 attrs = append(attrs, attribute.String(AttrFallbackPrimaryModel, primaryModel))
74 }
75 if conv, ok := conversationAttribute(ctx); ok {
76 attrs = append(attrs, conv)
77 }
78 ctx, span := tracer.Start(ctx, "runtime.fallback",
79 trace.WithSpanKind(trace.SpanKindInternal),
80 trace.WithAttributes(attrs...),
81 )
82 return ctx, &FallbackSpan{
83 span: span,
84 startedAt: time.Now(),
85 }
86}
87
88// IncrementAttempt counts one attempt against the chain. Called once per
89// (model × retry) iteration so the final span carries the total count.

Callers 1

executeMethod · 0.92

Calls 4

conversationAttributeFunction · 0.85
NowMethod · 0.80
StartMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected