feat: instrument command latency in Sentry#848
Open
ugcodrr wants to merge 5 commits into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
e949805 to
a3c95c2
Compare
5be690c to
8b360d8
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds standardized Sentry latency instrumentation across the API, Discord bot, rendering, Redis, Mongo/Mongoose, and outbound HTTP/Discord reply paths.
Changes:
- Adds shared Sentry span helpers and memory usage tagging in
@statsify/logger. - Instruments command execution, Discord replies, API/Hypixel fetches, Redis commands, Mongoose queries, JSX rendering, and PNG encoding.
- Adds Sentry profiling configuration/dependencies and
profilesSampleRateconfig support.
Reviewed changes
Copilot reviewed 24 out of 27 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
.gitmodules |
No-op formatting/newline change for private assets submodule URL. |
config.schema.js |
Adds default sentry.profilesSampleRate. |
pnpm-lock.yaml |
Updates lockfile for profiling/logger dependencies and transitive changes. |
apps/api/package.json |
Adds Sentry profiling dependency. |
apps/api/src/index.ts |
Enables profiling and Mongoose query instrumentation during API startup. |
apps/api/src/hypixel/hypixel.service.ts |
Wraps Hypixel HTTP calls in Sentry spans. |
apps/api/src/leaderboards/leaderboard.service.ts |
Replaces manual Redis spans with shared span helper. |
apps/api/src/redis/redis.utils.ts |
Instruments Redis commands by wrapping sendCommand. |
apps/api/src/sentry/index.ts |
Exports Mongoose instrumentation helper. |
apps/api/src/sentry/mongoose.ts |
Adds explicit Mongoose query/aggregate span instrumentation. |
apps/discord-bot/package.json |
Adds Sentry profiling dependency. |
apps/discord-bot/src/index.ts |
Enables profiling and configurable trace/profile sampling. |
apps/discord-bot/src/lib/command.listener.ts |
Starts command-level Sentry transactions with command metadata. |
apps/discord-bot/src/commands/base.hypixel-command.ts |
Tags base Hypixel commands with an observability group. |
apps/discord-bot/src/commands/ratios/ratios.command.tsx |
Tags ratios command with an observability group. |
packages/api-client/package.json |
Adds logger dependency for shared span helpers. |
packages/api-client/src/api.service.ts |
Wraps Statsify API requests in Sentry spans. |
packages/discord/src/command/abstract-command.listener.ts |
Wraps command execution in spans and records memory usage. |
packages/discord/src/command/command.interface.ts |
Adds command-level observability group option. |
packages/discord/src/command/command.resolvable.ts |
Stores command metadata group on resolvables. |
packages/discord/src/interaction/interaction.ts |
Instruments Discord REST replies with sanitized route names. |
packages/discord/src/services/paginate.service.ts |
Formatting-only change around PNG buffer generation. |
packages/logger/src/index.ts |
Adds shared Sentry span lifecycle helpers. |
packages/rendering/package.json |
Adds logger dependency for rendering instrumentation. |
packages/rendering/src/canvas.ts |
Instruments PNG canvas encoding globally. |
packages/rendering/src/jsx/render.ts |
Uses shared helpers for JSX render spans. |
packages/util/src/config.ts |
Adds profilesSampleRate to typed config. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| const transaction = Sentry.startTransaction({ name: commandName, op: "command" }); | ||
| const [name, ...subcommandParts] = commandName.split(" "); | ||
| const group = parentCommand.group ?? command.group ?? "unknown"; |
Comment on lines
161
to
164
| if (err instanceof Message) { | ||
| await context.reply(err); | ||
| setSentryMemoryUsage(transaction); | ||
| transaction?.finish(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
command.total,command.execute,hypixel.fetch,redis.get,redis.write,redis.command,mongo.query,render.generate,png.encode, anddiscord.reply@statsify/loggerso spans are finished consistently on success and failuremongo.queryspansCanvas#toBuffer("png")once in@statsify/renderingso all rendered command PNG encodes emitpng.encodediscord.replyspansprofilesSampleRateNotes
redis.get; known writes useredis.write; unknown Redis commands fall back toredis.commandwith the concrete command name in span data..DS_Store; it was not staged or pushed.Verification
pnpm --filter @statsify/logger test:typespnpm --filter @statsify/rendering test:typespnpm --filter @statsify/api-client test:typespnpm --filter @statsify/discord test:typespnpm --filter api test:typespnpm --filter discord-bot test:typespnpm --filter @statsify/util test:typespnpm --filter @statsify/logger lintpnpm --filter @statsify/rendering lintpnpm --filter @statsify/api-client lintpnpm --filter @statsify/discord lintpnpm --filter api lintpnpm --filter discord-bot lintpnpm --filter @statsify/util lint