MCPcopy
hub / github.com/docker/docker-agent / TrackCommand

Method TrackCommand

pkg/telemetry/telemetry_test.go:272–291  ·  view source on GitHub ↗

Test-only methods - these wrap command execution with telemetry for testing purposes TrackCommand wraps command execution with telemetry (test-only method)

(ctx context.Context, commandInfo CommandInfo, fn func(context.Context) error)

Source from the content-addressed store, hash-verified

270
271// TrackCommand wraps command execution with telemetry (test-only method)
272func (tc *Client) TrackCommand(ctx context.Context, commandInfo CommandInfo, fn func(context.Context) error) error {
273 if !tc.enabled {
274 return fn(ctx)
275 }
276
277 ctx = WithClient(ctx, tc)
278
279 // Send telemetry event immediately (optimistic approach)
280 commandEvent := CommandEvent{
281 Action: commandInfo.Action,
282 Args: commandInfo.Args,
283 Success: true, // Assume success - we're tracking user intent, not outcome
284 }
285
286 // Send the telemetry event immediately
287 tc.Track(ctx, &commandEvent)
288
289 // Now run the command function
290 return fn(ctx)
291}
292
293// TrackServerStart immediately sends telemetry for server startup, then runs the server function (test-only method)
294// This is for long-running commands that may never exit (api, mcp, etc.)

Callers 2

TestCommandTrackingFunction · 0.80

Calls 2

TrackMethod · 0.95
WithClientFunction · 0.85

Tested by

no test coverage detected