Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sampler type
Browse files Browse the repository at this point in the history
Signed-off-by: Pavol Loffay <[email protected]>
pavolloffay committed Nov 9, 2021

Verified

This commit was signed with the committer’s verified signature.
citizenmatt Matt Ellis
1 parent 4769b17 commit ad2908c
Showing 5 changed files with 60 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apis/instrumentation/v1alpha1/instrumentation_types.go
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ type Sampler struct {
// The value can be for instance parentbased_always_on, parentbased_always_off, parentbased_traceidratio...
// +optional
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
Type string `json:"type,omitempty"`
Type SamplerType `json:"type,omitempty"`

// Argument defines sampler argument.
// The value depends on the sampler type.
40 changes: 40 additions & 0 deletions apis/instrumentation/v1alpha1/samplers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright The OpenTelemetry Authors
//
// 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

type (
// SamplerType represents sampler type.
// +kubebuilder:validation:Enum=always_on;always_off;traceidratio;parentbased_always_on;parentbased_always_off;parentbased_traceidratio;jaeger_remote;xray
SamplerType string
)

const (
// AlwaysOn represents AlwaysOnSampler.
AlwaysOn SamplerType = "always_on"
// AlwaysOff represents AlwaysOffSampler.
AlwaysOff SamplerType = "always_off"
// TraceIDRatio represents TraceIdRatioBased.
TraceIDRatio SamplerType = "traceidratio"
// ParentBasedAlwaysOn represents ParentBased(root=AlwaysOnSampler).
ParentBasedAlwaysOn SamplerType = "parentbased_always_on"
// ParentBasedAlwaysOff represents ParentBased(root=AlwaysOffSampler).
ParentBasedAlwaysOff SamplerType = "parentbased_always_off"
// ParentBasedTraceIDRatio represents ParentBased(root=TraceIdRatioBased).
ParentBasedTraceIDRatio SamplerType = "parentbased_traceidratio"
// JaegerRemote represents JaegerRemoteSampler.
JaegerRemote SamplerType = "jaeger_remote"
// XRay represents AWS X-Ray Centralized Sampling.
XRay SamplerType = "xray"
)
9 changes: 9 additions & 0 deletions bundle/manifests/opentelemetry.io_instrumentations.yaml
Original file line number Diff line number Diff line change
@@ -68,6 +68,15 @@ spec:
type:
description: Type defines sampler type. The value can be for instance
parentbased_always_on, parentbased_always_off, parentbased_traceidratio...
enum:
- always_on
- always_off
- traceidratio
- parentbased_always_on
- parentbased_always_off
- parentbased_traceidratio
- jaeger_remote
- xray
type: string
type: object
type: object
9 changes: 9 additions & 0 deletions config/crd/bases/opentelemetry.io_instrumentations.yaml
Original file line number Diff line number Diff line change
@@ -70,6 +70,15 @@ spec:
type:
description: Type defines sampler type. The value can be for instance
parentbased_always_on, parentbased_always_off, parentbased_traceidratio...
enum:
- always_on
- always_off
- traceidratio
- parentbased_always_on
- parentbased_always_off
- parentbased_traceidratio
- jaeger_remote
- xray
type: string
type: object
type: object
2 changes: 1 addition & 1 deletion pkg/instrumentation/sdk.go
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ func injectCommonSDKConfig(otelinst v1alpha1.Instrumentation, pod corev1.Pod) co
if idxSamplerArg == -1 {
container.Env = append(container.Env, corev1.EnvVar{
Name: envOTELTracesSampler,
Value: otelinst.Spec.Sampler.Type,
Value: string(otelinst.Spec.Sampler.Type),
})
if otelinst.Spec.Sampler.Argument != "" {
container.Env = append(container.Env, corev1.EnvVar{

0 comments on commit ad2908c

Please sign in to comment.