The worker-boundary catch set ERROR with no message and no exception event, leaving those spans with zero diagnostic content. Record the exception and a status message, and stamp HTTP <status> on the 5xx path.
Unified · Split
| @@ -172,11 +172,18 @@ const cloudflareHandler: ExportedHandler<Env> = { · 171 unmodified lines | ||
| 172 | 172 | const response = await mcpAgentHandler(new Request(forwarded, { headers }), env, ctx); |
| 173 | 173 | span.setAttribute(ATTR_HTTP_RESPONSE_STATUS_CODE, response.status); |
| 174 | 174 | if (response.status >= 500) { |
| 175 | − span.setStatus({ code: SpanStatusCode.ERROR }); | |
| 175 | + span.setStatus({ code: SpanStatusCode.ERROR, message: `HTTP ${response.status}` }); | |
| 176 | 176 | } |
| 177 | 177 | return response; |
| 178 | 178 | } catch (err) { |
| 179 | − span.setStatus({ code: SpanStatusCode.ERROR }); | |
| 179 | + // Record the exception itself, not just the status bit: without it | |
| 180 | + // these spans are ERROR with zero diagnostic content. | |
| 181 | + // oxlint-disable-next-line executor/no-instanceof-error, executor/no-unknown-error-message -- adapter boundary: Cloudflare's fetch callback throws untyped; normalized only for the OTel span record, the original error is rethrown below | |
| 182 | + const cause = err instanceof Error ? err : String(err); | |
| 183 | + span.recordException(cause); | |
| 184 | + // oxlint-disable-next-line executor/no-unknown-error-message -- adapter boundary: same normalization as the recordException line above | |
| 185 | + const message = typeof cause === "string" ? cause : cause.message; | |
| 186 | + span.setStatus({ code: SpanStatusCode.ERROR, message }); | |
| 180 | 187 | // oxlint-disable-next-line executor/no-try-catch-or-throw -- adapter boundary; preserve original error to Cloudflare runtime |
| 181 | 188 | throw err; |
| 182 | 189 | } finally { |
| @@ -237,11 +244,18 @@ const cloudflareHandler: ExportedHandler<Env> = { · 54 unmodified lines | ||
| 237 | 244 | const response = await fetchHandler(request, env, ctx); |
| 238 | 245 | span.setAttribute(ATTR_HTTP_RESPONSE_STATUS_CODE, response.status); |
| 239 | 246 | if (response.status >= 500) { |
| 240 | − span.setStatus({ code: SpanStatusCode.ERROR }); | |
| 247 | + span.setStatus({ code: SpanStatusCode.ERROR, message: `HTTP ${response.status}` }); | |
| 241 | 248 | } |
| 242 | 249 | return response; |
| 243 | 250 | } catch (err) { |
| 244 | − span.setStatus({ code: SpanStatusCode.ERROR }); | |
| 251 | + // Record the exception itself, not just the status bit: without it | |
| 252 | + // these spans are ERROR with zero diagnostic content. | |
| 253 | + // oxlint-disable-next-line executor/no-instanceof-error, executor/no-unknown-error-message -- adapter boundary: Cloudflare's fetch callback throws untyped; normalized only for the OTel span record, the original error is rethrown below | |
| 254 | + const cause = err instanceof Error ? err : String(err); | |
| 255 | + span.recordException(cause); | |
| 256 | + // oxlint-disable-next-line executor/no-unknown-error-message -- adapter boundary: same normalization as the recordException line above | |
| 257 | + const message = typeof cause === "string" ? cause : cause.message; | |
| 258 | + span.setStatus({ code: SpanStatusCode.ERROR, message }); | |
| 245 | 259 | // oxlint-disable-next-line executor/no-try-catch-or-throw -- adapter boundary; preserve original error to Cloudflare runtime |
| 246 | 260 | throw err; |
| 247 | 261 | } finally { |