Skip to content

Commit

Permalink
feat(kuma-cp): intOrString as decimal in the API (#5768)
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
  • Loading branch information
jakubdyszkiewicz authored Jan 20, 2023
1 parent 11015dc commit 00aefce
Show file tree
Hide file tree
Showing 27 changed files with 409 additions and 214 deletions.
19 changes: 19 additions & 0 deletions api/common/v1alpha1/decimal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package v1alpha1

import (
"errors"

"github.com/shopspring/decimal"
"k8s.io/apimachinery/pkg/util/intstr"
)

func NewDecimalFromIntOrString(intOrString intstr.IntOrString) (decimal.Decimal, error) {
switch intOrString.Type {
case intstr.Int:
return decimal.NewFromInt(int64(intOrString.IntVal)), nil
case intstr.String:
return decimal.NewFromString(intOrString.String())
default:
return decimal.Zero, errors.New("invalid IntOrString")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2679,29 +2679,38 @@ spec:
or not.
properties:
client:
anyOf:
- type: integer
- type: string
description: 'Target percentage of requests that will be force
traced if the ''x-client-trace-id'' header is set. Default:
100% Mirror of client_sampling in Envoy https://github.com/envoyproxy/envoy/blob/v1.22.0/api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto#L127-L133'
format: int32
type: integer
100% Mirror of client_sampling in Envoy https://github.com/envoyproxy/envoy/blob/v1.22.0/api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto#L127-L133
Either int or decimal represented as string.'
x-kubernetes-int-or-string: true
overall:
anyOf:
- type: integer
- type: string
description: 'Target percentage of requests will be traced
after all other sampling checks have been applied (client,
force tracing, random sampling). This field functions as
an upper limit on the total configured sampling rate. For
instance, setting client_sampling to 100% but overall_sampling
to 1% will result in only 1% of client requests with the
appropriate headers to be force traced. Default: 100% Mirror
of overall_sampling in Envoy https://github.com/envoyproxy/envoy/blob/v1.22.0/api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto#L142-L150'
format: int32
type: integer
of overall_sampling in Envoy https://github.com/envoyproxy/envoy/blob/v1.22.0/api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto#L142-L150
Either int or decimal represented as string.'
x-kubernetes-int-or-string: true
random:
anyOf:
- type: integer
- type: string
description: 'Target percentage of requests that will be randomly
selected for trace generation, if not requested by the client
or not forced. Default: 100% Mirror of random_sampling in
Envoy https://github.com/envoyproxy/envoy/blob/v1.22.0/api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto#L135-L140'
format: int32
type: integer
Envoy https://github.com/envoyproxy/envoy/blob/v1.22.0/api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto#L135-L140
Either int or decimal represented as string.'
x-kubernetes-int-or-string: true
type: object
tags:
description: Custom tags configuration. You can add custom tags
Expand Down Expand Up @@ -4309,18 +4318,18 @@ spec:
format: int32
type: integer
standardDeviationFactor:
anyOf:
- type: integer
- type: string
description: 'This factor is used to determine
the ejection threshold for success rate outlier
ejection. The ejection threshold is the difference
between the mean success rate, and the product
of this factor and the standard deviation
of the mean success rate: mean - (standard_deviation
* success_rate_standard_deviation_factor).
This factor is divided by a thousand to get
a double. That is, if the desired factor is
1.9, the runtime value should be 1900.'
format: int32
type: integer
Either int or decimal represented as string.'
x-kubernetes-int-or-string: true
type: object
totalFailures:
description: 'In the default mode (outlierDetection.splitExternalAndLocalErrors
Expand Down Expand Up @@ -4627,18 +4636,18 @@ spec:
format: int32
type: integer
standardDeviationFactor:
anyOf:
- type: integer
- type: string
description: 'This factor is used to determine
the ejection threshold for success rate outlier
ejection. The ejection threshold is the difference
between the mean success rate, and the product
of this factor and the standard deviation
of the mean success rate: mean - (standard_deviation
* success_rate_standard_deviation_factor).
This factor is divided by a thousand to get
a double. That is, if the desired factor is
1.9, the runtime value should be 1900.'
format: int32
type: integer
Either int or decimal represented as string.'
x-kubernetes-int-or-string: true
type: object
totalFailures:
description: 'In the default mode (outlierDetection.splitExternalAndLocalErrors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2679,29 +2679,38 @@ spec:
or not.
properties:
client:
anyOf:
- type: integer
- type: string
description: 'Target percentage of requests that will be force
traced if the ''x-client-trace-id'' header is set. Default:
100% Mirror of client_sampling in Envoy https://github.com/envoyproxy/envoy/blob/v1.22.0/api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto#L127-L133'
format: int32
type: integer
100% Mirror of client_sampling in Envoy https://github.com/envoyproxy/envoy/blob/v1.22.0/api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto#L127-L133
Either int or decimal represented as string.'
x-kubernetes-int-or-string: true
overall:
anyOf:
- type: integer
- type: string
description: 'Target percentage of requests will be traced
after all other sampling checks have been applied (client,
force tracing, random sampling). This field functions as
an upper limit on the total configured sampling rate. For
instance, setting client_sampling to 100% but overall_sampling
to 1% will result in only 1% of client requests with the
appropriate headers to be force traced. Default: 100% Mirror
of overall_sampling in Envoy https://github.com/envoyproxy/envoy/blob/v1.22.0/api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto#L142-L150'
format: int32
type: integer
of overall_sampling in Envoy https://github.com/envoyproxy/envoy/blob/v1.22.0/api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto#L142-L150
Either int or decimal represented as string.'
x-kubernetes-int-or-string: true
random:
anyOf:
- type: integer
- type: string
description: 'Target percentage of requests that will be randomly
selected for trace generation, if not requested by the client
or not forced. Default: 100% Mirror of random_sampling in
Envoy https://github.com/envoyproxy/envoy/blob/v1.22.0/api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto#L135-L140'
format: int32
type: integer
Envoy https://github.com/envoyproxy/envoy/blob/v1.22.0/api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto#L135-L140
Either int or decimal represented as string.'
x-kubernetes-int-or-string: true
type: object
tags:
description: Custom tags configuration. You can add custom tags
Expand Down Expand Up @@ -4309,18 +4318,18 @@ spec:
format: int32
type: integer
standardDeviationFactor:
anyOf:
- type: integer
- type: string
description: 'This factor is used to determine
the ejection threshold for success rate outlier
ejection. The ejection threshold is the difference
between the mean success rate, and the product
of this factor and the standard deviation
of the mean success rate: mean - (standard_deviation
* success_rate_standard_deviation_factor).
This factor is divided by a thousand to get
a double. That is, if the desired factor is
1.9, the runtime value should be 1900.'
format: int32
type: integer
Either int or decimal represented as string.'
x-kubernetes-int-or-string: true
type: object
totalFailures:
description: 'In the default mode (outlierDetection.splitExternalAndLocalErrors
Expand Down Expand Up @@ -4627,18 +4636,18 @@ spec:
format: int32
type: integer
standardDeviationFactor:
anyOf:
- type: integer
- type: string
description: 'This factor is used to determine
the ejection threshold for success rate outlier
ejection. The ejection threshold is the difference
between the mean success rate, and the product
of this factor and the standard deviation
of the mean success rate: mean - (standard_deviation
* success_rate_standard_deviation_factor).
This factor is divided by a thousand to get
a double. That is, if the desired factor is
1.9, the runtime value should be 1900.'
format: int32
type: integer
Either int or decimal represented as string.'
x-kubernetes-int-or-string: true
type: object
totalFailures:
description: 'In the default mode (outlierDetection.splitExternalAndLocalErrors
Expand Down
Loading

0 comments on commit 00aefce

Please sign in to comment.