[meshkit] fix: disable tracing when no endpoint configured, suppress repeated export-failure logs - #1070
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughTracing configuration adds explicit disabling, treats an empty endpoint as a no-op, and suppresses repeated OpenTelemetry export failures. Tests verify nil-provider and error behavior across enabled and disabled configurations. ChangesTracing configuration
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tracing/tracing_test.go`:
- Around line 20-24: Extend the tracing test table with an enabled configuration
using Enabled: &trueVal and a nonempty Endpoint, expecting no error and a
non-nil provider. Update the test execution logic to shut down the returned
provider for this case while preserving existing assertions for other
configurations.
In `@tracing/tracing.go`:
- Around line 40-50: The global suppressRepeatedExportErrors handler must only
deduplicate OTLP exporter failures and must not replace or suppress unrelated
OpenTelemetry errors. Update the SetErrorHandler integration around
suppressRepeatedExportErrors to retain and delegate to the previously configured
handler for non-export errors, while preserving first-error-only logging for the
exporter path.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 6d3c729c-3b73-4657-b14d-92726441f35f
📒 Files selected for processing (2)
tracing/tracing.gotracing/tracing_test.go
c0c37ad to
eb3e30e
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tracing/tracing_test.go`:
- Around line 77-99: Update the InitTracer test setup to capture the existing
global tracer provider, error handler, and text map propagator before calling
InitTracer, then register t.Cleanup to restore all three values after each test
case. Keep the existing provider assertions and shutdown behavior unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 3defec3e-c008-4ca7-ab8f-8ab6b46f522f
📒 Files selected for processing (2)
tracing/tracing.gotracing/tracing_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
- tracing/tracing.go
…xport-failure logs Signed-off-by: Uzair Hameed <uzairhameed98@gmail.com>
eb3e30e to
d13464b
Compare
|
@uzairhameed there is an earlier PR on this same topic. Please reconcile. |
Yes, I reviewed the earlier PR and shared my feedback during the development meeting on July 14. You can refer to the meeting recording from 51:00–58:00. Lee gave me the go-ahead to work on this and suggested that I coordinate with the original PR author. However, as you can see, they haven't been active on this issue since January, so I proceeded with the implementation. |
|
Closing this in favor of a re-scoped PR, per feedback to keep this fix |
Fixes: #894
Summary
This PR makes two related fixes to
tracing/tracing.go:Treats a missing/empty endpoint as implicitly disabled tracing: Previously,
InitTracerreturned a hard error ifEndpointwas empty, even when tracing was never intended to be used. Now, if no endpoint is configured (or tracing is explicitly disabled via a newEnabled *boolfield),InitTracerreturnsnil, nil— a clean no-op, not an error.Suppresses repeated identical export-failure logs : when an endpoint is configured but unreachable (e.g. collector down, wrong address, not yet started), the OTLP exporter retries indefinitely, and previously logged a failure on every retry (~every 10-15s). This adds an error handler (via
otel.SetErrorHandler) that logs the first failure once, then suppresses further identical failures, without affecting the underlying retry behavior itself.Any previously registered OTel error handler is preserved and still invoked, so this doesn't silently override unrelated error handling that may already be in place.Why
Meshery Server was logging repeated "connection refused" errors when no trace collector was configured, because it kept trying to reach a default.
OTLP address. Investigation showed this had two separate causes:
main.go/Makefile defaults, but the same protection was never added at the meshkit layer, so any other meshkit consumer remained exposed to it.Known limitation
otel.SetErrorHandleronly exposes a failure hook, not a success hook. This still resolves the reported issue (no more infinite log spam) but is noted here as a possible future improvement (e.g. wrapping the exporter directly to detect successful exports).Testing
Added unit tests covering: explicit disable, missing endpoint (no-op, not an error), and explicit enable with no endpoint (still a no-op).
Verified live, against a real collector:
make serverwith noOTEL_CONFIGalready logs cleanly ("tracing disabled"), unaffected by this change.meshery.server.mp4
tracing.logs.mp4
meshery-serverappear correctly in Jaeger's UI. Then stopped Jaeger again and confirmed no renewed log spam occurs (consistent with the known limitation noted above, suppression persists rather than resetting on recovery).tracing.fix.mp4
Related
Companion Helm chart change (exposes
OTEL_CONFIGinvalues.yaml):meshery/meshery#20898
Signed commits
Summary by CodeRabbit
Summary by CodeRabbit
New Features
enabledoption to explicitly turn tracing on or off via YAML/JSON configuration.Bug Fixes
Tests