Allow each signal API to be thoroughly disabled#1785
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1785 +/- ##
==========================================
+ Coverage 62.99% 63.36% +0.37%
==========================================
Files 157 159 +2
Lines 3448 3502 +54
Branches 352 370 +18
==========================================
+ Hits 2172 2219 +47
Misses 1179 1179
- Partials 97 104 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| /** | ||
| * Whether the tracing API is enabled. Toggle with using [setTracingEnabled] | ||
| */ | ||
| @Volatile |
There was a problem hiding this comment.
Is there a need to make these volatile?
There was a problem hiding this comment.
I suppose its creation and consumption are all done on the main thread, and this object is thrown away after the SDK is initialized, so I can remove this if you feel it makes things slightly more convoluted.
There was a problem hiding this comment.
Yeah. I don't see a reason why making it thread-safe, at least not now. Plus, if it were needed, then I think we should apply the same safety guards to the rest of the config options. But for now I think it's better to keep it simple.
|
Related to #1776 |
| fun disableTracing(disable: Boolean) { | ||
| rumConfig.setTracingEnabled(!disable) | ||
| } |
There was a problem hiding this comment.
I think these would benefit from not allowing the inverse logic, especially when they are enabled by default.
| fun disableTracing(disable: Boolean) { | |
| rumConfig.setTracingEnabled(!disable) | |
| } | |
| fun disableTracing() { | |
| rumConfig.setTracingEnabled(false) | |
| } |
| fun disableLogging(disable: Boolean) { | ||
| rumConfig.setLoggingEnabled(!disable) | ||
| } |
There was a problem hiding this comment.
| fun disableLogging(disable: Boolean) { | |
| rumConfig.setLoggingEnabled(!disable) | |
| } | |
| fun disableLogging() { | |
| rumConfig.setLoggingEnabled(false) | |
| } |
| fun disableMetrics(disable: Boolean) { | ||
| rumConfig.setMetricsEnabled(!disable) | ||
| } |
There was a problem hiding this comment.
| fun disableMetrics(disable: Boolean) { | |
| rumConfig.setMetricsEnabled(!disable) | |
| } | |
| fun disableMetrics() { | |
| rumConfig.setMetricsEnabled(false) | |
| } |
| } | ||
|
|
||
| /** | ||
| * Disable logging in the SDK by providing no-op implementations that don't incur overhead even if instrumentation emits logs |
There was a problem hiding this comment.
Maybe we also mention that this silences events too?
| if (rumConfig.tracingEnabled) { | ||
| addSpanExporterCustomizer { | ||
| createSpanExporter(cfg.exportConfig.spansEndpoint()) | ||
| } | ||
| } | ||
| if (rumConfig.loggingEnabled) { | ||
| addLogRecordExporterCustomizer { | ||
| createLogExporter(cfg.exportConfig.logsEndpoint()) | ||
| } | ||
| } | ||
| if (rumConfig.metricsEnabled) { | ||
| addMetricExporterCustomizer { | ||
| createMetricExporter(cfg.exportConfig.metricsEndpoint()) | ||
| } | ||
| } |
There was a problem hiding this comment.
One interesting edge case of this is that if (for some reason) telemetry data was left on disk, and, after an upgrade, one of the signals was no longer turned on, we wouldn't have an exporter to handle that data on disk. Presumably we would read it and export it to a noop, effectively losing it.
I think I'm fine with that, but just wanted to make a note of it in case it hadn't been considered.
| ) | ||
|
|
||
| server.awaitLogRequest { findLog(it) } | ||
| assertEquals(0, server.traceRequestCount()) |
There was a problem hiding this comment.
Prefer fluent assertj assertions.
| assertEquals(0, server.traceRequestCount()) | |
| assertThat(server.traceRequestCount()).isZero() |
| } | ||
| assertTraceRequestReceived(traceRequest) | ||
| server.awaitTraceRequest { findSpan(it) } | ||
| assertEquals(0, server.logRequestCount()) |
There was a problem hiding this comment.
| assertEquals(0, server.logRequestCount()) | |
| assertThat(server.logRequestCount()).isZero() |
| fun setTracingEnabled(enabled: Boolean): OtelRumConfig { | ||
| tracingEnabled = enabled | ||
| return this | ||
| } | ||
|
|
||
| /** | ||
| * Enables or disables the logging API for the SDK. When disabled, the SDK will provide no-op implementations to instrumentation | ||
| * that use this API. | ||
| */ | ||
| fun setLoggingEnabled(enabled: Boolean): OtelRumConfig { | ||
| loggingEnabled = enabled | ||
| return this | ||
| } | ||
|
|
||
| /** | ||
| * Enables or disables the metrics API for the SDK. When disabled, the SDK will provide no-op implementations to instrumentation | ||
| * that use this API. | ||
| */ | ||
| fun setMetricsEnabled(enabled: Boolean): OtelRumConfig { | ||
| metricsEnabled = enabled | ||
| return this | ||
| } |
There was a problem hiding this comment.
I think my preference would be to have these as disable methods with no arg, since the default is enabled.
| private val openTelemetrySdk: OpenTelemetrySdk, | ||
| override val openTelemetry: OpenTelemetry, |
breedx-splk
left a comment
There was a problem hiding this comment.
Left some comments, but it's looking mostly good to me! Thanks for picking this up.
Add the ability to disable each signal API via the config DSL that provides a no-op provider instead of just not configuring any processors. This eliminates the overhead of instrumentation that are still configured but whose telemetry doesn't ever get recorded and sent.