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

Method TrackServerStart

pkg/telemetry/telemetry_test.go:295–314  ·  view source on GitHub ↗

TrackServerStart immediately sends telemetry for server startup, then runs the server function (test-only method) This is for long-running commands that may never exit (api, mcp, etc.)

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

Source from the content-addressed store, hash-verified

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.)
295func (tc *Client) TrackServerStart(ctx context.Context, commandInfo CommandInfo, fn func(context.Context) error) error {
296 if !tc.enabled {
297 return fn(ctx)
298 }
299
300 ctx = WithClient(ctx, tc)
301
302 // Send startup event immediately
303 startupEvent := CommandEvent{
304 Action: commandInfo.Action,
305 Args: commandInfo.Args,
306 Success: true, // We assume startup succeeds if we reach this point
307 }
308
309 // Send the startup telemetry event immediately
310 tc.Track(ctx, &startupEvent)
311
312 // Now run the server function (which may run indefinitely)
313 return fn(ctx)
314}
315
316// TestAllEventTypes tests all possible telemetry events with mock HTTP client
317func TestAllEventTypes(t *testing.T) {

Callers 1

TestTrackServerStartFunction · 0.80

Calls 2

TrackMethod · 0.95
WithClientFunction · 0.85

Tested by

no test coverage detected