feat: add noop client implementation - #1365
Conversation
4337b6c to
415d82c
Compare
415d82c to
18b7a4a
Compare
18b7a4a to
94121a8
Compare
59c6bdc to
095e3a7
Compare
095e3a7 to
7ecc977
Compare
7ecc977 to
8fc2ecf
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
There are 3 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8fc2ecf. Configure here.
| func (client *Client) Recover(err any, hint *EventHint, scope EventModifier) *EventID { | ||
| if !client.IsEnabled() { | ||
| return nil | ||
| } |
There was a problem hiding this comment.
Disabled Recover skips panic recovery
Medium Severity
Recover returns immediately when the client is disabled, before calling recover(). Direct use as a panic handler with a noop client therefore leaves the original panic unrecovered. RecoverWithContext does not have this early return, so the two APIs now behave inconsistently for disabled clients.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 8fc2ecf. Configure here.
This PR changes the client boundaries so that we always return a non nil client.
8fc2ecf to
d7d23ee
Compare
| func (l *layer) Client() *Client { | ||
| l.mu.RLock() | ||
| defer l.mu.RUnlock() | ||
| return l.client | ||
| return normalizeClient(l.client) |
There was a problem hiding this comment.
Bug: The logrus integration's check customHub.Client() != nil always passes now, as Client() returns a NoopClient instead of nil, causing logs to be silently discarded instead of falling back to the default hub.
Severity: HIGH
Suggested Fix
Update the check in logrus/logrusentry.go:161 to use the IsEnabled() method instead of a != nil check on the client. The condition should be changed from customHub.Client() != nil to customHub.Client().IsEnabled(). This will correctly determine if the client is a real, functioning client or a NoopClient, restoring the intended fallback behavior.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: hub.go#L51-L54
Potential issue: The `hub.Client()` method was changed to always return a non-nil
client, specifically a `NoopClient` when no real client is configured. However, the
`logrus` integration at `logrus/logrusentry.go:161` was not updated. It still uses
`customHub.Client() != nil` to decide whether to use a custom hub. This check now always
evaluates to true. Consequently, if a custom hub lacks a real client, the system no
longer falls back to the default hub. Instead, it uses the custom hub with its
`NoopClient`, which silently discards all logs, leading to telemetry loss in certain
configurations like multi-tenant setups.
Also affects:
logrus/logrusentry.go:161


Description
This adds the Client interface and noop and default client implementations for the SDK. This better aligns the behavior with the current client spec and removes the need to always nil check any client.
Issues
Changelog Entry Instructions
To add a custom changelog entry, uncomment the section above. Supports:
For more details: custom changelog entries
Reminders
feat:,fix:,ref:,meta:)