Add spans for parse_incoming/gen_event_id for alloc instruments

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2026-03-10 07:09:41 +00:00
parent cd66cd843b
commit 3ceeb8655f
2 changed files with 24 additions and 0 deletions

View File

@@ -7,6 +7,14 @@ use crate::{Result, debug_error, err, matrix::room_version};
///
/// Returns a tuple of the new `EventId` and the PDU as a `BTreeMap<String,
/// CanonicalJsonValue>`.
#[tracing::instrument(
name = "gen_event_id",
level = "debug",
skip_all,
fields(
len = pdu.get().len(),
)
)]
pub fn gen_event_id_canonical_json(
pdu: &RawJsonValue,
room_version_id: &RoomVersionId,
@@ -23,6 +31,14 @@ pub fn gen_event_id_canonical_json(
/// Generates a correct eventId for the PDU. For v1/v2 incoming PDU's the
/// value's event_id is passed through. For all outgoing PDU's and for v3+
/// incoming PDU's it is generated.
#[tracing::instrument(
level = "debug",
skip_all,
fields(
members = value.len(),
room_version = ?room_version_id,
)
)]
pub fn gen_event_id(
value: &CanonicalJsonObject,
room_version_id: &RoomVersionId,

View File

@@ -5,6 +5,14 @@ use tuwunel_core::{Result, err, implement, matrix::event::gen_event_id, result::
type Parsed = (OwnedRoomId, OwnedEventId, CanonicalJsonObject);
#[implement(super::Service)]
#[tracing::instrument(
name = "parse_incoming",
level = "trace",
skip_all,
fields(
len = pdu.get().len(),
)
)]
pub async fn parse_incoming_pdu(&self, pdu: &RawJsonValue) -> Result<Parsed> {
let value: CanonicalJsonObject = serde_json::from_str(pdu.get()).map_err(|e| {
err!(BadServerResponse(debug_error!("Error parsing incoming event: {e} {pdu:#?}")))