Skip to content

feat: instrument command latency in Sentry#848

Open
ugcodrr wants to merge 8 commits into
mainfrom
observability/sentry-command-tracing
Open

feat: instrument command latency in Sentry#848
ugcodrr wants to merge 8 commits into
mainfrom
observability/sentry-command-tracing

Conversation

@ugcodrr

@ugcodrr ugcodrr commented May 12, 2026

Copy link
Copy Markdown
Member
  • migrate Sentry instrumentation to v10 Node SDK APIs
  • add command/request transactions with command metadata and memory usage attributes
  • centralize span lifecycle helpers in @statsify/logger
  • instrument key command latency paths: command execution, Discord replies, API/Hypixel fetches, Mongoose queries, render generation, and PNG encoding
  • Redis tracing limited to explicit leaderboard pipeline spans instead of wrapping every Redis command
  • upload @statsify/logger warn/error/fatal logs to Sentry only in production

@vercel

vercel Bot commented May 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
statsify Error Error Jun 16, 2026 8:34am

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 profilesSampleRate config 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();

@jacobk999 jacobk999 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a lot of weird code here overriding library functions which just seems like a bad idea. We don't need sentry traces for every redis command.

ugcodrr added 7 commits June 16, 2026 00:22
…observability with additional Sentry attributes

* Added endpoint and HTTP method data to HypixelService
* Included leaderboard type and fields in LeaderboardService
* Captured guild ID and user tier in CommandListener
* Implemented cache hit tracking in ApiService
* Enhanced logging with structured attributes in Logger
* Updated rendering functions to include width and height in Sentry data
@ugcodrr ugcodrr force-pushed the observability/sentry-command-tracing branch from d4aec77 to d49bf12 Compare June 16, 2026 06:42
Comment thread apps/discord-bot/src/lib/command.listener.ts Fixed
Comment thread apps/discord-bot/src/index.ts Fixed
Comment thread apps/discord-bot/src/index.ts Fixed
Comment thread packages/api-client/src/api.service.ts Fixed
Comment thread packages/discord/src/command/abstract-command.listener.ts Fixed
* Replace span finish calls with end for consistency
* Update Sentry integration methods for better performance
* Refactor command listener to use startInactiveSpan
* Improve error handling and context setting in commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants