Skip to content

Commit

Permalink
Add latency sampler action + err sampler action and adjust probabilis…
Browse files Browse the repository at this point in the history
…tic (#1281)

Co-authored-by: Tamir David <tamirdavid@Tamirs-MacBook-Pro.local>
  • Loading branch information
tamirdavid1 and Tamir David authored Jul 3, 2024
1 parent 5e8b167 commit 8840cac
Show file tree
Hide file tree
Showing 67 changed files with 3,780 additions and 80 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"program": "${workspaceFolder}/autoscaler",
"cwd": "${workspaceFolder}/autoscaler",
"env": {
"ODIGOS_VERSION": "v1.0.50"
"ODIGOS_VERSION": "v1.0.71"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ help: ## Display this help.

.PHONY: manifests
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) crd:allowDangerousTypes=true webhook paths="./..." output:crd:artifacts:config=config/crd/bases

.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
Expand Down
72 changes: 72 additions & 0 deletions api/actions/v1alpha1/errorsampler_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
Copyright 2022.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
"github.com/odigos-io/odigos/common"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// ErrorSamplerSpec defines the desired state of ErrorSampler action
type ErrorSamplerSpec struct {
ActionName string `json:"actionName,omitempty"`
Notes string `json:"notes,omitempty"`
Disabled bool `json:"disabled,omitempty"`
Signals []common.ObservabilitySignal `json:"signals"`

// Specifies the ratio of non-error traces to be sampled.
// +kubebuilder:validation:Required
FallbackSamplingRatio float64 `json:"fallback_sampling_ratio"`
}

// ErrorSamplerStatus defines the observed state of ErrorSampler action
type ErrorSamplerStatus struct {
// Represents the observations of a ErrorSampler's current state.
// Known .status.conditions.type are: "Available", "Progressing"
// +patchMergeKey=type
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
}

//+genclient
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:path=errorsamplers,scope=Namespaced,shortName=es

// ErrorSampler is the Schema for the ErrorSampler odigos action API
type ErrorSampler struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ErrorSamplerSpec `json:"spec,omitempty"`
Status ErrorSamplerStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// ErrorSamplerList contains a list of ErrorSampler
type ErrorSamplerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ErrorSampler `json:"items"`
}

func init() {
SchemeBuilder.Register(&ErrorSampler{}, &ErrorSamplerList{})
}
87 changes: 87 additions & 0 deletions api/actions/v1alpha1/latencysampler_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
Copyright 2022.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
"github.com/odigos-io/odigos/common"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// LatencySamplerSpec defines the desired state of LatencySampler action
type LatencySamplerSpec struct {
ActionName string `json:"actionName,omitempty"`
Notes string `json:"notes,omitempty"`
Disabled bool `json:"disabled,omitempty"`
Signals []common.ObservabilitySignal `json:"signals"`

// Specifies the list of endpoint filters to be applied for sampling
// +kubebuilder:validation:Required
EndpointsFilters []HttpRouteFilter `json:"endpoints_filters"`
}

type HttpRouteFilter struct {
// Specifies the http.route to be sampled
// +kubebuilder:validation:Required
HttpRoute string `json:"http_route"`
// Specifies the service to be sampled
// +kubebuilder:validation:Required
ServiceName string `json:"service_name"`
// Specifies the lower latency threshold in milliseconds; traces with latency equal to or exceeding this value will be considered for sampling.
// +kubebuilder:validation:Required
MinimumLatencyThreshold int `json:"minimum_latency_threshold"`
// Specifies the fallback sampling ratio to be applied in case service and endpoint filter match but the latency threshold is not met.
// +kubebuilder:validation:Required
FallbackSamplingRatio float64 `json:"fallback_sampling_ratio"`
}

// LatencySamplerStatus defines the observed state of LatencySampler action
type LatencySamplerStatus struct {
// Represents the observations of a LatencySampler's current state.
// Known .status.conditions.type are: "Available", "Progressing"
// +patchMergeKey=type
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
}

//+genclient
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:path=latencysamplers,scope=Namespaced,shortName=ls

// LatencySampler is the Schema for the LatencySampler odigos action API
type LatencySampler struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec LatencySamplerSpec `json:"spec,omitempty"`
Status LatencySamplerStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// LatencySamplerList contains a list of LatencySampler
type LatencySamplerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []LatencySampler `json:"items"`
}

func init() {
SchemeBuilder.Register(&LatencySampler{}, &LatencySamplerList{})
}
Loading

0 comments on commit 8840cac

Please sign in to comment.