Skip to content

Commit 2e2acce

Browse files
committed
rfc: Opinionated OpenTelemetry Operator Sampling CR
Signed-off-by: Benedikt Bongartz <[email protected]>
1 parent cf9f890 commit 2e2acce

File tree

2 files changed

+140
-0
lines changed

2 files changed

+140
-0
lines changed
101 KB
Loading

docs/rfcs/opinionated_sampling_cr.md

+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# Opinionated OpenTelemetry Operator Sampling CR
2+
3+
**Status:** [*Draft* | *Accepted*]
4+
5+
**Author:** Benedikt Bongartz, [email protected]
6+
7+
**Date:** 20.9.2024
8+
9+
## Objective
10+
11+
By today there is an ongoing discussion about whether and how the collector CR could be split into several components. This would hopefully not only reduce the complexity of some CRs, but also help to manage access to certain collector parts for certain users. As this turned out to be more complicated than expected, and there are some non-trivial setups, it might make sense to experiment with some opinionated CRs for specific use cases. ([#1477](https://github.com/open-telemetry/opentelemetry-operator/pull/1477), [#1906](https://github.com/open-telemetry/opentelemetry-operator/pull/1906)) Based on feedback from a FOSDEM talk on sampling and Kubecon tutorials, we noticed a request for a sampling CR.
12+
13+
The introduction of this CRD is intended to significantly simplify trace sampling in a kubernetes enviroment.
14+
15+
## Summary
16+
17+
Provide a sampler CR in v1alpha1 that can be used to simplify the sampling of traces in kubernetes.
18+
19+
## Goals and non-goals
20+
21+
**Goals**
22+
- Provide an opinionated CR to simply sampling configuration in distributed environments
23+
- Allow managing access using RBAC to different parts of the collector configuration
24+
- Adapt the collector setup based on sampling strategy
25+
- Secure the communication between collector components by default
26+
27+
**Non-Goals**
28+
- Solving the generic OpenTelemetryCollector CR split
29+
- Allow extra processing steps within the CR
30+
- Auto scaling he setup (might be a future goal)
31+
32+
## Use cases for proposal
33+
34+
### CASE 1
35+
36+
As a cluster administrator I want to reduce the amount of traffic caused by generating telemetry data.
37+
38+
### CASE 2
39+
40+
As a cluster administrator I want to be in control of the collector resources while allowing a user to change sampling policies.
41+
42+
### CASE 3
43+
44+
As a user I want to be able to filter relevant data without much specific open telemetry knowledge.
45+
46+
## Struct Design
47+
48+
This proposal introduces a new CR which serve as an abstraction setting up an opentelemetry collector based sampling layer. Similar to the following figure.
49+
50+
![sampling arch](./images/arch_sampling_crd.png)
51+
52+
This custom resource creates an environment that allows us to apply e.g. tailbased sampling in a distributed environment. The operator takes care of creating an optional otel LB service and sampling instances similar to the figure shown above.
53+
54+
LB instances will be pre-configured to distribute traces based on a given routing key like the traceID to the sampler instances.
55+
56+
A policy is used to define which telemetry data should be sampled. Available policies can be found in the tailbased sampling description.
57+
58+
```yaml
59+
---
60+
apiVersion: opentelemetry.io/v1alpha1
61+
kind: Sampler
62+
metadata:
63+
name: example-sampler
64+
spec:
65+
# Policies taken into account when making a sampling decision.
66+
policies:
67+
- name: "retain-error-policy"
68+
type: status_code,
69+
status_codes: [ERROR, UNSET]
70+
# RoutingKey describes how traffic to be sampled is distributed. It can be 'traceid' or 'service'.
71+
# Default is 'traceid'.
72+
routingKey: traceid
73+
# DecisionWait defines the time to wait before making a sampling decision.
74+
# Default is 30s, specified in nanoseconds (30s = 30000000000ns).
75+
decision_wait: 30000000000
76+
# NumTraces defines the number of traces kept in memory.
77+
# Default is 5000.
78+
num_traces: 5000
79+
# ExpectedNewTracesPerSec defines the expected number of new traces per second.
80+
# Helps allocate memory structures. Default is 5000.
81+
expected_new_traces_per_sec: 5000
82+
# DecisionCache defines the settings for the decision cache.
83+
# This allows sampling decisions to be cached to avoid re-processing traces.
84+
decision_cache:
85+
# SampledCacheSize configures the amount of trace IDs to be kept in an LRU
86+
# cache, persisting the "keep" decisions for traces that may have already
87+
# been released from memory.
88+
# By default, the size is 0 and the cache is inactive.
89+
# If using, configure this as much higher than num_traces so decisions for
90+
# trace IDs are kept longer than the span data for the trace.
91+
sampled_cache_size: 10000
92+
# Components defines the template of all requirements to configure scheduling
93+
# of all components to be deployed.
94+
components:
95+
loadbalancer:
96+
# Defines if the component is managed by the operator
97+
managementState: managed
98+
resources: # Resource requests and limits
99+
limits:
100+
cpu: "500m"
101+
memory: "512Mi"
102+
requests:
103+
cpu: "200m"
104+
memory: "256Mi"
105+
# Node selection for component placement
106+
nodeSelector:
107+
environment: "production"
108+
# Number of load balancer replicas (optional)
109+
replicas: 2
110+
111+
sampler:
112+
# Component managed by the operator
113+
managementState: managed
114+
# Number of sampler replicas (optional)
115+
replicas: 3
116+
117+
# Telemetry settings for the sampler system (currently empty).
118+
telemetry:
119+
# telemetry configuration goes here (e.g., serviceMonitor or spanMetrics)
120+
...
121+
122+
# Exporter configuration. Only OTLP exporter supported.
123+
exporter:
124+
# OTLP exporter endpoint
125+
endpoint: "jaeger:4317"
126+
```
127+
128+
## Rollout Plan
129+
130+
1. Introduction of the CRD in v1alpha1.
131+
2. First controller implementation.
132+
3. Implementation of e2e tests.
133+
4. CRD becomes part of the operator bundle.
134+
135+
## Limitations
136+
137+
1. Initially, there is no TLS support for incoming, internal and outgoing connections.
138+
2. The input and output format is exclusively OTLP.
139+
3. Policies are initially part of the sampling CR and cannot be configured independently of the sampler setup.
140+

0 commit comments

Comments
 (0)