Skip to content

Commit

Permalink
fix(query-engine-wasm): expand scope of prisma:engine:query span
Browse files Browse the repository at this point in the history
Expand the scope of the `prisma:engine:query` span to contain both the
request handler and the response serialization, identical to the
Node-API engine, preventing `prisma:engine:response_json_serialization`
from being orphaned outside the trace.

This is a follow up to #5089.
  • Loading branch information
aqrln committed Dec 16, 2024
1 parent 40232c9 commit 77a5386
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions query-engine/query-engine-wasm/src/wasm/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,24 +207,22 @@ impl QueryEngine {

let query = RequestBody::try_from_str(&body, engine.engine_protocol())?;

async move {
let span = tracing::info_span!(
"prisma:engine:query",
user_facing = true,
request_id = tracing::field::Empty,
);
let span = tracing::info_span!(
"prisma:engine:query",
user_facing = true,
request_id = tracing::field::Empty,
);

let traceparent = start_trace(&request_id, &trace, &span, &exporter).await?;
let traceparent = start_trace(&request_id, &trace, &span, &exporter).await?;

async move {
let handler = RequestHandler::new(engine.executor(), engine.query_schema(), engine.engine_protocol());
let response = handler
.handle(query, tx_id.map(TxId::from), traceparent)
.instrument(span)
.await;
let response = handler.handle(query, tx_id.map(TxId::from), traceparent).await;

let serde_span = tracing::info_span!("prisma:engine:response_json_serialization", user_facing = true);
Ok(serde_span.in_scope(|| serde_json::to_string(&response))?)
}
.instrument(span)
.await
}
.with_subscriber(dispatcher)
Expand Down

0 comments on commit 77a5386

Please sign in to comment.