{"record":{"id":"681524b6a2611f58","repo":"dagger/dagger","slug":"flush-telemetry-w","errorCode":null,"errorMessage":"flush telemetry: %w","messagePattern":"flush telemetry: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/server/session.go","lineNumber":2951,"sourceCode":"func (srv *Server) FlushSessionTelemetry(ctx context.Context) error {\n\tclient, err := srv.clientFromContext(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn client.daggerSession.FlushTelemetry(ctx, \"FlushSessionTelemetry API\")\n}\n\nfunc (srv *Server) ClientTelemetry(ctx context.Context, sessID, clientID string) (*clientdb.DB, error) {\n\tclient, err := srv.clientFromIDs(sessID, clientID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// Flush ALL clients in the session, not just the requested one.\n\t// Spans from nested clients may still be buffered in their\n\t// BatchSpanProcessor. A session-wide flush ensures the span tree\n\t// is complete before captureLogs walks it via SelectLogsBeneathSpan.\n\tif err := client.daggerSession.FlushTelemetry(ctx, \"ClientTelemetry API\"); err != nil {\n\t\treturn nil, fmt.Errorf(\"flush telemetry: %w\", err)\n\t}\n\treturn client.TelemetryDB(ctx)\n}\n\n// Return a client connected to a cloud engine. If bool return is false, the local engine should be used. Session attachables for the returned client will be proxied back to the calling client.\nfunc (srv *Server) CloudEngineClient(\n\tctx context.Context,\n\tmodule string,\n\tfunction string,\n\texecCmd []string,\n) (*engineclient.Client, bool, error) {\n\tparentClient, err := srv.nonModuleParentClient(ctx)\n\tif err != nil {\n\t\treturn nil, false, err\n\t}\n\tparentCallerCtx := engine.ContextWithClientMetadata(ctx, parentClient.clientMetadata)\n\tparentSession, err := parentClient.engineUtilClient.GetSessionCaller(parentCallerCtx)\n\tif err != nil {","sourceCodeStart":2933,"sourceCodeEnd":2969,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/engine/server/session.go#L2933-L2969","documentation":"The ClientTelemetry API flushes ALL clients in the session (so buffered spans from nested clients are complete before captureLogs walks the span tree) and wraps any flush failure from daggerSession.FlushTelemetry as \"flush telemetry: %w\".","triggerScenarios":"Calling the ClientTelemetry API when the session-wide BatchSpanProcessor flush fails — e.g. the telemetry export pipeline/shutdown path errors, or the context is cancelled mid-flush.","commonSituations":"Capturing telemetry/logs right after a command completes while span export to the backend is slow or failing; network issues reaching the telemetry sink; context cancelled during a long-running session teardown.","solutions":["Read the wrapped cause (%w) to see the underlying flush/export failure and fix it (network, auth, sink)","Retry the ClientTelemetry call after a short delay so the span processor can drain","Avoid cancelling the parent context before telemetry capture completes; keep the session alive until capture finishes"],"exampleFix":"// before\ndb, err := client.ClientTelemetry(ctx)\n// after\ndb, err := client.ClientTelemetry(ctx)\nif err != nil && strings.Contains(err.Error(), \"flush telemetry\") {\n\ttime.Sleep(500 * time.Millisecond)\n\tdb, err = client.ClientTelemetry(ctx)\n}","handlingStrategy":"retry","validationCode":"// no pre-check possible; ensure session still active and context not cancelled\nif ctx.Err() != nil { return ctx.Err() }","typeGuard":null,"tryCatchPattern":"db, err := client.ClientTelemetry(ctx)\nif err != nil && strings.Contains(err.Error(), \"flush telemetry\") {\n\t// inspect wrapped cause, retry once after delay\n}","preventionTips":["Don't cancel the context before telemetry capture","Keep the session alive until spans are flushed","Retry transient flush failures with backoff"],"tags":["telemetry","flush","spans"],"backgroundTag":"telemetry-flush-failed","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}