Name the shared executor, plugin, engine, and MCP server assembly steps so the post-auth execution gap is visible in traces.
Unified · Split
| @@ -271,7 +271,9 @@ export class McpSessionDOSqlite extends McpAgentSessionDOBase<Env, CloudSessionD · 270 unmodified lines | ||
| 271 | 271 | // Build the description here so `executor.connections.list()` stays under |
| 272 | 272 | // the DO startup span and the MCP SDK receives a concrete string instead |
| 273 | 273 | // of invoking `engine.getDescription` across its async boundary. |
| 274 | − const description = yield* buildExecuteDescription(executor); | |
| 274 | + const description = yield* buildExecuteDescription(executor).pipe( | |
| 275 | + Effect.withSpan("mcp.execute.description.build"), | |
| 276 | + ); | |
| 275 | 277 | const sessionElicitationMode = sessionMeta.elicitationMode ?? "model"; |
| 276 | 278 | const mcpServer = yield* createExecutorMcpServer({ |
| 277 | 279 | engine, |
| @@ -188,8 +188,11 @@ export const makeExecutionStackMiddleware = < · 187 unmodified lines | ||
| 188 | 188 | // provider carried one. Absent slug -> the service stays unprovided and |
| 189 | 189 | // the URL falls back to its bare, client-canonicalized form. |
| 190 | 190 | const { executor, engine } = yield* resolved.organizationSlug !== undefined |
| 191 | − ? stack.pipe(Effect.provideService(RequestOrgSlug, { slug: resolved.organizationSlug })) | |
| 192 | − : stack; | |
| 191 | + ? stack.pipe( | |
| 192 | + Effect.provideService(RequestOrgSlug, { slug: resolved.organizationSlug }), | |
| 193 | + Effect.withSpan("executor.stack.http.resolve"), | |
| 194 | + ) | |
| 195 | + : stack.pipe(Effect.withSpan("executor.stack.http.resolve")); | |
| 193 | 196 | return yield* httpEffect.pipe( |
| 194 | 197 | Effect.provideService(AuthContext, auth), |
| 195 | 198 | Effect.provideService(ExecutorService, executor), |
| @@ -108,13 +108,19 @@ export const makeExecutionStack = < · 107 unmodified lines | ||
| 108 | 108 | organizationId, |
| 109 | 109 | organizationName, |
| 110 | 110 | { plugins: { mcpResource: options?.mcpResource } }, |
| 111 | + ).pipe(Effect.withSpan("executor.stack.scoped_executor")); | |
| 112 | + const codeExecutor = yield* CodeExecutorProvider.asEffect().pipe( | |
| 113 | + Effect.withSpan("executor.stack.code_executor"), | |
| 111 | 114 | ); |
| 112 | − const codeExecutor = yield* CodeExecutorProvider; | |
| 113 | − const { decorate } = yield* EngineDecorator; | |
| 114 | − const engine = decorate(createExecutionEngine({ executor, codeExecutor }), { | |
| 115 | − accountId, | |
| 116 | − organizationId, | |
| 117 | − organizationName, | |
| 118 | − }); | |
| 115 | + const { decorate } = yield* EngineDecorator.asEffect().pipe( | |
| 116 | + Effect.withSpan("executor.stack.decorator"), | |
| 117 | + ); | |
| 118 | + const engine = yield* Effect.sync(() => | |
| 119 | + decorate(createExecutionEngine({ executor, codeExecutor }), { | |
| 120 | + accountId, | |
| 121 | + organizationId, | |
| 122 | + organizationName, | |
| 123 | + }), | |
| 124 | + ).pipe(Effect.withSpan("executor.stack.engine.init")); | |
| 119 | 125 | return { executor, engine }; |
| 120 | − }); | |
| 126 | + }).pipe(Effect.withSpan("executor.stack.build")); | |
| @@ -42,6 +42,7 @@ export const makeMcpBuildServer = · 41 unmodified lines | ||
| 42 | 42 | makeExecutionStack(principal.accountId, principal.organizationId, principal.organizationName, { |
| 43 | 43 | mcpResource: options?.resource, |
| 44 | 44 | }).pipe( |
| 45 | + Effect.withSpan("mcp.execution_stack.build"), | |
| 45 | 46 | Effect.map(({ engine }) => engine), |
| 46 | 47 | // Pin browser-handoff URLs to the principal's org slug when present; |
| 47 | 48 | // absent slug leaves the service unprovided and the URL stays bare. |
| @@ -52,6 +53,7 @@ export const makeMcpBuildServer = · 4 unmodified lines | ||
| 52 | 53 | Effect.mapError((cause) => new McpEngineBuildError({ cause })), |
| 53 | 54 | Effect.flatMap((engine) => |
| 54 | 55 | createExecutorMcpServer({ engine, ...(options ?? {}) }).pipe( |
| 56 | + Effect.withSpan("mcp.server.create"), | |
| 55 | 57 | Effect.map((mcpServer) => ({ mcpServer, engine })), |
| 56 | 58 | ), |
| 57 | 59 | ), |
| @@ -210,9 +210,13 @@ export const makeScopedExecutor = < · 209 unmodified lines | ||
| 210 | 210 | options?: { readonly plugins?: PluginsProviderContext }, |
| 211 | 211 | ): Effect.Effect<Executor<TPlugins>, StorageFailure, DbProvider | PluginsProvider | HostConfig> => |
| 212 | 212 | Effect.gen(function* () { |
| 213 | − const { db, blobs } = yield* DbProvider; | |
| 214 | − const { plugins: pluginsFactory } = yield* PluginsProvider; | |
| 215 | − const config = yield* HostConfig; | |
| 213 | + const { db, blobs } = yield* DbProvider.asEffect().pipe( | |
| 214 | + Effect.withSpan("executor.stack.db_provider"), | |
| 215 | + ); | |
| 216 | + const { plugins: pluginsFactory } = yield* PluginsProvider.asEffect().pipe( | |
| 217 | + Effect.withSpan("executor.stack.plugins_provider"), | |
| 218 | + ); | |
| 219 | + const config = yield* HostConfig.asEffect().pipe(Effect.withSpan("executor.stack.host_config")); | |
| 216 | 220 | // Explicit config wins; otherwise fall back to the request origin if a host |
| 217 | 221 | // provided one (HTTP middleware / MCP session DO). Stays `undefined` for |
| 218 | 222 | // non-request callers — `coreTools.webBaseUrl` is optional and only the |
| @@ -248,7 +252,9 @@ export const makeScopedExecutor = < · 29 unmodified lines | ||
| 248 | 252 | oauthCallbackPath: config.oauthCallbackPath, |
| 249 | 253 | }); |
| 250 | 254 | |
| 251 | − const plugins = pluginsFactory(options?.plugins); | |
| 255 | + const plugins = yield* Effect.sync(() => pluginsFactory(options?.plugins)).pipe( | |
| 256 | + Effect.withSpan("executor.plugins.init"), | |
| 257 | + ); | |
| 252 | 258 | const hostedHttpOptions = { |
| 253 | 259 | allowLocalNetwork: config.allowLocalNetwork, |
| 254 | 260 | }; |
| @@ -274,7 +280,7 @@ export const makeScopedExecutor = < · 19 unmodified lines | ||
| 274 | 280 | orgSlug, |
| 275 | 281 | includeProviders: config.exposeCredentialProviders ?? true, |
| 276 | 282 | }, |
| 277 | − }); | |
| 283 | + }).pipe(Effect.withSpan("executor.stack.create_executor")); | |
| 278 | 284 | // The seam erases the plugin tuple type; the caller re-narrows via the |
| 279 | 285 | // `TPlugins` phantom. Runtime shape is identical to a typed |
| 280 | 286 | // `createExecutor({ plugins })` call. |