Conversation
Owner
appleboy
commented
Feb 15, 2026
- Add internal optimization flags to detect if metrics, tracer, or logger are enabled
- Update code paths to use these flags, conditionally invoking metrics, tracing, and logging logic only when enabled
- Add a new test file to verify observability flag behavior and configuration
- Ensure tracing, metrics, and logging components are not called when explicitly disabled
- Add internal optimization flags to detect if metrics, tracer, or logger are enabled - Update code paths to use these flags, conditionally invoking metrics, tracing, and logging logic only when enabled - Add a new test file to verify observability flag behavior and configuration - Ensure tracing, metrics, and logging components are not called when explicitly disabled Signed-off-by: appleboy <appleboy.tw@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request introduces performance optimizations for observability components by adding internal boolean flags that detect whether metrics, tracer, or logger components are enabled. The optimization conditionally invokes observability methods only when the respective component is not a no-op implementation, avoiding unnecessary interface method call overhead.
Changes:
- Added three internal boolean flags (metricsEnabled, tracerEnabled, loggerEnabled) to the Client struct
- Implemented type assertion-based detection during client initialization to set these flags
- Updated all observability call sites to check flags before invoking methods
- Added comprehensive tests to verify flag detection and conditional behavior
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| retry.go | Added internal optimization flags to Client struct, implemented flag detection in NewClient using type assertions against nop implementations, and wrapped all observability method calls with conditional checks based on these flags |
| observability_flags_test.go | New test file that verifies flag detection for different configurations (default, all disabled, individual components) and includes a test to ensure tracer is not called when disabled |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Update test to simulate server failure and trigger client retry logic - Add assertions to explicitly check observability flags are disabled - Enhance verification to ensure tracer is not called during retries or failures Signed-off-by: appleboy <appleboy.tw@gmail.com>
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.