Repository navigation
[SPARK-59949] Record the operator.sdk controller execution histograms with sub-second precision - #949
Open
sankalpsthakur wants to merge 1 commit into
Conversation
…ms with sub-second precision Time the controller executions with Clock.nanoTime() and record the duration in nanoseconds in histograms whose names end with nanos, so that PrometheusPullModelHandler exports them in seconds. The histograms were updated with whole seconds, so an execution under one second recorded 0.
This branch has not been deployed
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.
What changes were proposed in this pull request?
This PR records the controller execution histograms of
OperatorJosdkMetricsin nanoseconds instead of whole seconds.timeControllerExecutionmeasures the duration withClock.nanoTime()and records it once per execution in both the cluster-wide and the namespaced histogram.nanos, e.g.sparkapplication.sparkappreconciler.reconcile.both.nanosandsparkapplication.sparkappreconciler.reconcile.failure.nanos, soPrometheusPullModelHandlerexports them in seconds asoperator_sdk_sparkapplication_sparkappreconciler_reconcile_both_secondsetc., likekubernetes_client_http_response_latency_seconds.OperatorJosdkMetricsgets a package-private constructor taking aClock, for tests, followingSummingHistogram(Reservoir)of [SPARK-59935] Fix Prometheus_sumand quantiles of histograms and timers #922.Why are the changes needed?
timeControllerExecutionupdated its histograms withTimeUnit.MILLISECONDS.toSeconds(...), so the elapsed time was truncated to whole seconds and a reconciliation under one second, which most are, recorded0. The quantiles of these histograms were mostly0, and their Prometheus_sum(#922) undercounted. This is there since SPARK-48984 (0.1.0).Does this PR introduce any user-facing change?
Yes. Compared to 1.0.0, the
operator.sdkcontroller execution histograms are renamed with ananossuffix, e.g.operator_sdk_sparkapplication_sparkappreconciler_reconcile_both_secondsinstead ofoperator_sdk_sparkapplication_sparkappreconciler_reconcile_bothin Prometheus, and their values are in seconds with sub-second precision instead of whole seconds. The migration guide is updated.How was this patch tested?
Updated and new test cases:
OperatorJosdkMetricsTest.testTimeControllerExecutiontimes the executions with aManualClockand asserts that a 10 ms success and a 5 ms failure are recorded as10000000and5000000nanoseconds under the new names, instead of sleeping for a second.PrometheusPullModelHandlerTest.testFormatMetricsSnapshotIncludesControllerExecutionHistogramInSecondsasserts that such a histogram is exported as..._reconcile_both_secondswith0.01as its median and_sum.Nothing was built or run locally; validation is the GitHub Actions run on this PR.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 5.5)