Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve resource.Quantity to float conversion for SLOs #1308

Merged
merged 1 commit into from
Jul 23, 2024

Conversation

levan-m
Copy link
Contributor

@levan-m levan-m commented Jul 23, 2024

What does this PR do?

CONS-6488

Quantity.AsApproximateFloat64 does some math to convert Quantity to float64 needed for SLO API input so some floats may appear with additional decimals. Instead we convert Quantity to Decimal string and then parse as float. This may still have edge cases were string representation doesn't have exact float64 so conversion isn't 1-to-1.

This impl ignores string to float parsing errors, assuming decimal string obtain from Quantity would be valid.

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

Minimum Agent Versions

Are there minimum versions of the Datadog Agent and/or Cluster Agent required?

  • Agent: vX.Y.Z
  • Cluster Agent: vX.Y.Z

Describe your test plan

  1. Enabled SLO CRD using datadogSLOEnabled
  2. Apply SLO manifest and confirm in the app number match (to see warningThreshold clone the SLO in UI)
apiVersion: datadoghq.com/v1alpha1
kind: DatadogSLO
metadata:
  name: test-slo
  namespace: system
spec:
  description: Error SLO for test-xyz
  name: Error SLO for test-xyz
  query:
    denominator: sum:trace.pyramid.request.hits{service:test-xyz, env:test}.as_count()
    numerator: sum:trace.pyramid.request.hits{service:test-xyz, env:test}.as_count()
      - sum:trace.pyramid.request.errors{service:test-xyz, env:test}.as_count()
  tags:
  - integration:kubernetes
  - service:test-xyz
  - env:test
  - team:sre
  - generated:kubernetes
  targetThreshold: "0.001"
  warningThreshold: "99.999"
  timeframe: 7d
  type: metric

Tested on user-reported combinations

* "99.95" produces 99.95%
* "99.99" produces "error updating SLO" in k8s
* "99.990" produces "error updating SLO" in k8s
* "99.991" produces 99.991%
* 99950m produces 99.95%
* 99990m produces "error updating SLO" in k8s

Checklist

  • PR has at least one valid label: bug, enhancement, refactoring, documentation, tooling, and/or dependencies
  • PR has a milestone or the qa/skip-qa label

@levan-m levan-m added the bug Something isn't working label Jul 23, 2024
@levan-m levan-m added this to the v1.8.0 milestone Jul 23, 2024
@levan-m levan-m requested a review from a team as a code owner July 23, 2024 17:43
@codecov-commenter
Copy link

codecov-commenter commented Jul 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.21%. Comparing base (1c66029) to head (f7cdd02).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1308   +/-   ##
=======================================
  Coverage   55.20%   55.21%           
=======================================
  Files         247      247           
  Lines       28383    28384    +1     
=======================================
+ Hits        15670    15671    +1     
  Misses      11827    11827           
  Partials      886      886           
Flag Coverage Δ
unittests 55.21% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
controllers/datadogslo/slo.go 61.38% <100.00%> (+0.38%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1c66029...f7cdd02. Read the comment docs.

@levan-m levan-m merged commit f1898dc into main Jul 23, 2024
21 checks passed
@levan-m levan-m deleted the levan-m/slo-float-conversion branch July 23, 2024 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants