sankalpsthakur opened a new pull request, #949:
URL: https://github.com/apache/spark-kubernetes-operator/pull/949

   ### What changes were proposed in this pull request?
   
   This PR records the controller execution histograms of 
`OperatorJosdkMetrics` in nanoseconds instead of whole seconds.
   
   - `timeControllerExecution` measures the duration with `Clock.nanoTime()` 
and records it once per execution in both the cluster-wide and the namespaced 
histogram.
   - The histogram names end with `nanos`, e.g. 
`sparkapplication.sparkappreconciler.reconcile.both.nanos` and 
`sparkapplication.sparkappreconciler.reconcile.failure.nanos`, so 
`PrometheusPullModelHandler` exports them in seconds as 
`operator_sdk_sparkapplication_sparkappreconciler_reconcile_both_seconds` etc., 
like `kubernetes_client_http_response_latency_seconds`.
   - `OperatorJosdkMetrics` gets a package-private constructor taking a 
`Clock`, for tests, following `SummingHistogram(Reservoir)` of #922.
   - The migration guide gets an item for the renamed metrics.
   
   ### Why are the changes needed?
   
   `timeControllerExecution` updated its histograms with 
`TimeUnit.MILLISECONDS.toSeconds(...)`, so the elapsed time was truncated to 
whole seconds and a reconciliation under one second, which most are, recorded 
`0`. The quantiles of these histograms were mostly `0`, 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](https://github.com/apache/spark-kubernetes-operator/releases/tag/1.0.0),
 the `operator.sdk` controller execution histograms are renamed with a `nanos` 
suffix, e.g. 
`operator_sdk_sparkapplication_sparkappreconciler_reconcile_both_seconds` 
instead of `operator_sdk_sparkapplication_sparkappreconciler_reconcile_both` in 
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.testTimeControllerExecution` times the 
executions with a `ManualClock` and asserts that a 10 ms success and a 5 ms 
failure are recorded as `10000000` and `5000000` nanoseconds under the new 
names, instead of sleeping for a second.
   - 
`PrometheusPullModelHandlerTest.testFormatMetricsSnapshotIncludesControllerExecutionHistogramInSeconds`
 asserts that such a histogram is exported as `..._reconcile_both_seconds` with 
`0.01` as 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)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to