server: add tracing for graphql handling
This commit is contained in:
@@ -9,6 +9,7 @@ use log::info;
|
||||
use notmuch::Notmuch;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::postgres::PgPool;
|
||||
use tracing::instrument;
|
||||
|
||||
use crate::{config::Config, newsreader, nm, tantivy::TantivyConnection, Query};
|
||||
|
||||
@@ -269,6 +270,7 @@ impl QueryRoot {
|
||||
build_info::build_info!(fn bi);
|
||||
Ok(shared::build_version(bi))
|
||||
}
|
||||
#[instrument(skip_all, fields(query=query))]
|
||||
async fn count<'ctx>(&self, ctx: &Context<'ctx>, query: String) -> Result<usize, Error> {
|
||||
let nm = ctx.data_unchecked::<Notmuch>();
|
||||
let pool = ctx.data_unchecked::<PgPool>();
|
||||
@@ -284,6 +286,7 @@ impl QueryRoot {
|
||||
Ok(total)
|
||||
}
|
||||
|
||||
#[instrument(skip_all, fields(query=query))]
|
||||
async fn search<'ctx>(
|
||||
&self,
|
||||
ctx: &Context<'ctx>,
|
||||
@@ -418,6 +421,7 @@ impl QueryRoot {
|
||||
.await?)
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
async fn tags<'ctx>(&self, ctx: &Context<'ctx>) -> FieldResult<Vec<Tag>> {
|
||||
let nm = ctx.data_unchecked::<Notmuch>();
|
||||
let pool = ctx.data_unchecked::<PgPool>();
|
||||
@@ -426,6 +430,7 @@ impl QueryRoot {
|
||||
tags.append(&mut nm::tags(nm, needs_unread)?);
|
||||
Ok(tags)
|
||||
}
|
||||
#[instrument(skip_all, fields(thread_id=thread_id))]
|
||||
async fn thread<'ctx>(&self, ctx: &Context<'ctx>, thread_id: String) -> Result<Thread, Error> {
|
||||
let nm = ctx.data_unchecked::<Notmuch>();
|
||||
let pool = ctx.data_unchecked::<PgPool>();
|
||||
@@ -500,6 +505,7 @@ async fn tantivy_search(
|
||||
pub struct Mutation;
|
||||
#[Object]
|
||||
impl Mutation {
|
||||
#[instrument(skip_all, fields(query, bool))]
|
||||
async fn set_read_status<'ctx>(
|
||||
&self,
|
||||
ctx: &Context<'ctx>,
|
||||
@@ -516,6 +522,7 @@ impl Mutation {
|
||||
nm::set_read_status(nm, &query, unread).await?;
|
||||
Ok(true)
|
||||
}
|
||||
#[instrument(skip_all, fields(query, tag))]
|
||||
async fn tag_add<'ctx>(
|
||||
&self,
|
||||
ctx: &Context<'ctx>,
|
||||
@@ -527,6 +534,7 @@ impl Mutation {
|
||||
nm.tag_add(&tag, &query)?;
|
||||
Ok(true)
|
||||
}
|
||||
#[instrument(skip_all, fields(query, tag))]
|
||||
async fn tag_remove<'ctx>(
|
||||
&self,
|
||||
ctx: &Context<'ctx>,
|
||||
@@ -548,6 +556,7 @@ impl Mutation {
|
||||
|
||||
Ok(true)
|
||||
}
|
||||
#[instrument(skip_all)]
|
||||
async fn refresh<'ctx>(&self, ctx: &Context<'ctx>) -> Result<bool, Error> {
|
||||
let nm = ctx.data_unchecked::<Notmuch>();
|
||||
let tantivy = ctx.data_unchecked::<TantivyConnection>();
|
||||
|
||||
Reference in New Issue
Block a user