Skip to content

Commit

Permalink
fix(mongodb-query-connector): add missing span for aggregate (prisma#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aqrln authored Oct 7, 2024
1 parent 031f4d3 commit 00f0d73
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::{constants::*, output_meta, query_builder::MongoReadQueryBuilder, val
use connector_interface::*;
use mongodb::{bson::Document, ClientSession, Database};
use query_structure::{prelude::*, Filter, QueryArguments};
use tracing::{info_span, Instrument};

pub async fn aggregate<'conn>(
database: &Database,
Expand All @@ -16,11 +17,17 @@ pub async fn aggregate<'conn>(
let is_group_by = !group_by.is_empty();
let coll = database.collection(model.db_name());

let span = info_span!(
"prisma:engine:db_query",
user_facing = true,
"db.statement" = &format_args!("db.{}.aggregate(*)", coll.name())
);

let query = MongoReadQueryBuilder::from_args(query_arguments)?
.with_groupings(group_by, &selections, having)?
.build()?;

let docs = query.execute(coll, session).await?;
let docs = query.execute(coll, session).instrument(span).await?;

if is_group_by && docs.is_empty() {
Ok(vec![])
Expand Down

0 comments on commit 00f0d73

Please sign in to comment.