MCPcopy Index your code
hub / github.com/dagger/dagger / withEngine

Function withEngine

cmd/dagger/engine.go:80–170  ·  view source on GitHub ↗
(
	ctx context.Context,
	params client.Params,
	fn runClientCallback,
)

Source from the content-addressed store, hash-verified

78type runClientCallback func(context.Context, *client.Client) error
79
80func withEngine(
81 ctx context.Context,
82 params client.Params,
83 fn runClientCallback,
84) (rerr error) {
85 if !moduleNoURL {
86 if modRef, _ := getExplicitModuleSourceRef(); modRef != "" {
87 params.Module = modRef
88 }
89 }
90 return Frontend.Run(ctx, opts, func(ctx context.Context) (_ cleanups.CleanupF, rerr error) {
91 var cleanup cleanups.Cleanups
92
93 // Init tracing as early as possible and shutdown after the command
94 // completes, ensuring progress is fully flushed to the frontend.
95 ctx, cleanupTelemetry := initEngineTelemetry(ctx)
96
97 otel.SetErrorHandler(otel.ErrorHandlerFunc(func(err error) {
98 if opts.Debug {
99 slog.Error("failed to emit telemetry", "error", err)
100 }
101 Frontend.SetTelemetryError(err)
102 }))
103 cleanup.Add("close telemetry", func() error {
104 cleanupTelemetry(rerr)
105 return nil
106 })
107
108 if debugFlag {
109 params.LogLevel = slog.LevelDebug
110 }
111
112 if useCloudEngine {
113 params.RunnerHost = engine.DefaultCloudRunnerHost
114 } else if params.RunnerHost == "" {
115 params.RunnerHost = RunnerHost
116 }
117
118 if RunnerImageLoader != "" {
119 backend, err := imageload.GetBackend(RunnerImageLoader)
120 if err != nil {
121 return cleanup.Run, err
122 }
123 params.ImageLoaderBackend = backend
124 }
125
126 params.AllowedLLMModules = allowedLLMModules
127
128 params.CloudURLCallback = Frontend.SetCloudURL
129
130 params.EngineTrace = telemetry.SpanForwarder{
131 Processors: telemetry.SpanProcessors,
132 }
133 params.EngineLogs = telemetry.LogForwarder{
134 Processors: telemetry.LogProcessors,
135 }
136 params.EngineMetrics = telemetry.MetricExporters
137

Callers 15

up.goFile · 0.85
checks.goFile · 0.85
lock.goFile · 0.85
EngineSessionFunction · 0.85
shell.goFile · 0.85
call.goFile · 0.85
runFunction · 0.85
module.goFile · 0.85
modifyLocalModuleFunction · 0.85
optionalModCmdWrapperFunction · 0.85
generators.goFile · 0.85
config.goFile · 0.85

Calls 12

AddMethod · 0.95
ErrorFunction · 0.92
GetBackendFunction · 0.92
GetCloudAuthFunction · 0.92
ConnectFunction · 0.92
initEngineTelemetryFunction · 0.85
resolveLockModeFunction · 0.85
DaggerMethod · 0.80
RunMethod · 0.65
SetTelemetryErrorMethod · 0.65
SetClientMethod · 0.65

Tested by

no test coverage detected