Skip to content

feat: optimize observability logic with internal enablement flags#15

Merged
appleboy merged 2 commits intomainfrom
bench
Feb 15, 2026
Merged

feat: optimize observability logic with internal enablement flags#15
appleboy merged 2 commits intomainfrom
bench

Conversation

@appleboy
Copy link
Owner

  • 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>
Copilot AI review requested due to automatic review settings February 15, 2026 06:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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>
@appleboy appleboy merged commit b6a7e9c into main Feb 15, 2026
16 of 20 checks passed
@appleboy appleboy deleted the bench branch February 15, 2026 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants