Tier2メトリクス(コマンド実行数・レイテンシ・エラー率)を追加 - #511
Open
takumi0213 wants to merge 1 commit into
Open
Conversation
sina-chan-monitoring側のF-1(expansion_candidates.md)に対応。 - metrics.py: sina_chan_commands_total / sina_chan_command_errors_total / sina_chan_command_latency_seconds を追加 - bot.py: on_command(開始時刻の保持)・on_command_completion(新設)・ on_command_error(エラー計上)にのみ計装を追加。各cogは変更なし hybrid_commandがslash/prefixどちらの呼び出し経路でも discord.ext.commandsの一元化イベント(command/command_completion/command_error)を 発火することをdiscord.py 2.7.1のソースで確認した上で設計。 純粋なapp_commands(shutdown等3件、discord.ext.commandsを経由しない)は対象外。
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.
📝 変更内容
sina-chan-monitoringリポジトリの拡張候補F-1(docs/expansion_candidates.md)に対応する変更です。既存のTier 1メトリクス(sina_chan_ready等)に加えて、コマンド単位の実行状況を可視化するためのメトリクスを追加します。metrics.py:sina_chan_commands_total(コマンド正常完了数)・sina_chan_command_errors_total(エラー数)・sina_chan_command_latency_seconds(実行時間)の3メトリクスを追加bot.py:on_command(開始時刻の保持を追加)・on_command_completion(新設)・on_command_error(エラー計上を追加)の3イベントにのみ計装コードを追加。各cog(cogs/配下)は一切変更していません👀 レビューしてほしい点
on_commandでctx.interactionによる早期リターンより前にctx._t2_start = time.monotonic()を置いている点(slash経由のhybrid_commandでも計測対象にするため、既存の早期リターンより前段に配置しています)on_command_errorでctx.commandがNoneになりうるケース(CommandNotFound等)へのフォールバック("(unknown)")app_commands.command/app_commands.context_menu(shutdown・message info・spread spoilerの3件)はdiscord.ext.commandsのイベントを経由しないため、今回のスコープ外としています💬 補足
ext/commands/hybrid.py・ext/commands/bot.py・ext/commands/core.py)を確認し、hybrid_commandがslash/prefixいずれの呼び出し経路でもcommand/command_completion/command_errorイベントを一元的に発火することを検証済みですctx.command is None時のフォールバック・レイテンシ計測の5パターン)で動作確認済みですGenerated by Claude Code