Repository navigation
feat(observability): Add OpenTelemetry logs, metrics and traces with optional Sentry - #78
tintinhamans wants to merge 5 commits into
Conversation
|
This PR is doing a lot more than logging. Are you sure this PR is in line with the main branch? |
a9d22bb to
9ecd3cd
Compare
Was part of the stack before, made it based on main now. |
9ecd3cd to
73de6d3
Compare
Skyaero42
left a comment
There was a problem hiding this comment.
As far as I can tell, this is fine.
| { | ||
| public static class UserTokens | ||
| { | ||
| private static readonly ILogger s_log = AppLog.For(typeof(UserTokens)); |
There was a problem hiding this comment.
For the todo list: once these classes are non-static, logger should be injected through constructor.
|
I've asked Claude to do a review as well. I reviewed Services PR 78 and reported 10 findings; I wouldn't merge it as it stands. Telemetry is off by default, so the risk only starts once it's switched on, but several of the alerts the docs recommend would mislead. Fix before enabling telemetry:
Metrics that would mislead:
The other four are lower priority:
I checked the Sentry and MySqlConnector behaviour against their source at the pinned versions (6.8.0 and 2.6.2). The findings were not run or reproduced, because I did not build the PR. The review was done from the diff and a read-only clone of the PR head. Nothing was posted to GitHub. |
Moves logging to structured
ILoggereverywhere and adds OpenTelemetry logs, metrics and traces, exported over OTLP to a collector like Grafana Alloy. Sentry is optional and gets errors, plus logs and traces if enabled. Metrics only go over OTLP since Sentry 6.8 can't read .NET meters. Everything is off by default (OpenTelemetry:Enabled,Sentry:enabled), anddocs/observability.mdcovers config, the metric list and an Alloy example.Database, HTTP and runtime metrics come from the built-in MySqlConnector, ASP.NET Core, HttpClient and runtime meters. On top of that there are 14
genonline.*metrics worth alerting on: online players, active lobbies, auth attempts, WebSocket connections, failures and send queue depth, matchmaking queue, wait time and matches, background job failures and last success, external publication failures and backlog age, and security actions (rate limits, moderation, anti-cheat). Labels are small fixed sets, never player, lobby or match IDs.Spans never carry SQL, connection strings or database users, and outbound HTTP spans only keep scheme, host and port since the TURN key is in the Cloudflare path. EF's command events are ignored in the context options, so SQL can't be logged whatever the logging config says. Slow commands (
SlowDatabaseCommandMilliseconds, default 500) are logged with operation, duration and result only. Logs and traces do carry user, lobby and match IDs, so treat the collector and Sentry as holding player identifiers.Builds on #80 (MySqlConnector advisory bump), so its commit stays in the diff until it lands. Lands before #77 and #71–#75, which build on it.