element-hq / element-hq/synapse

`LoggingContext.tag` being lost on metrics and traces

Open
#15,920 0 comments 0 reactions 0 assignees View on GitHub
A-Logging A-Metrics O-Uncommon S-Minor T-Defect Z-Dev-Wishlist
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

This issue has been migrated from [#15920](https://github.com/matrix-org/synapse/issues/15920).

---

*As discovered during the discussion in https://github.com/matrix-org/synapse/pull/15708#discussion_r1259027871,*

### Background

`LoggingContext.tag` was introduced to differentiate what kind of sync was happening in our metrics. The only place we populate it is for this use case even though it could be used generally:

https://github.com/matrix-org/synapse/blob/a4243183f0b500f9f30f2d24af19f30a99f65f63/synapse/handlers/sync.py#L348-L357

We also use it in the tracing with `SynapseTags.REQUEST_TAG` which says that it's ["used to distinguish full vs incremental syncs, etc"](https://github.com/matrix-org/synapse/blob/a4243183f0b500f9f30f2d24af19f30a99f65f63/synapse/logging/opentracing.py#L314-L315).

### Problem

If I look at the [Prometheus data](https://prometheus.matrix.org/graph?g0.expr=synapse_http_server_response_time_seconds_sum%7Btag%3D%22incremental_sync%22%7D&g0.tab=1&g0.stacked=0&g0.show_exemplars=0&g0.range_input=1h), I don't see any data for `matrix.org`. I only see it for one other instance we track which is running Synapse 1.83.0. Has it broken since then?

And if I look at the traces, `request_tag` is always set to the default empty string when I look at those `SyncRestServlet` traces (also checked `RoomInitialSyncRestServlet`).

It seems like the context is being lost somewhere.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.