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

feat: add tail sampling for traces #467

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,40 @@ otelcol.processor.transform "default" {
}
}


{{- if and .Values.traces.enabled .Values.traces.receiver.tailsampling.policies }}
Lp-Francois marked this conversation as resolved.
Show resolved Hide resolved
otelcol.processor.tail_sampling "default" {
{{- range $policy := .Values.traces.receiver.tailsampling.policies }}
policy {
name = {{ $policy.name | quote }}
type = {{ $policy.type | quote }}
{{- if and (eq $policy.type "latency") (hasKey $policy "latency") }}
latency = {
threshold_ms = {{ $policy.latency.thresholdMs | int }},
}
{{- end }}

{{- if and (eq $policy.type "string_attribute") (hasKey $policy "stringAttribute") }}
stringAttribute = {
key = {{ $policy.stringAttribute.key | quote }}
values = [
{{- range $value := $policy.stringAttribute.values }}
{{ $value }},
{{- end }}
]
enabled_regex_matching = {{ $policy.stringAttribute.enabledRegexMatching | default true }}
Lp-Francois marked this conversation as resolved.
Show resolved Hide resolved
invert_match = {{ $policy.stringAttribute.invertMatch | default false }}
}
{{- end }}
}
{{- end }}

output {
traces = [otelcol.processor.batch.batch_processor.input]
}
}
{{- end }}

otelcol.processor.filter "default" {
error_mode = "ignore"

Expand Down
42 changes: 42 additions & 0 deletions examples/tail-sampling/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Tail sampling

This example contains an example of [tail sampling](https://grafana.com/docs/grafana-cloud/monitor-applications/application-observability/setup/sampling/tail/).

```yaml
cluster:
name: tail-sampling-test

externalServices:
prometheus:
host: https://prometheus.example.com
basicAuth:
username: 12345
password: "It's a secret to everyone"
loki:
host: https://loki.example.com
basicAuth:
username: 12345
password: "It's a secret to everyone"
tempo:
host: https://tempo.example.com
basicAuth:
username: 12345
password: "It's a secret to everyone"

metrics:
enabled: false

logs:
enabled: false

traces:
enabled: true
receiver:
tailsampling:
policies:
- name: all_traces_above_500
type: latency
latency:
thresholdMs: 500

```
34 changes: 34 additions & 0 deletions examples/tail-sampling/events.alloy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

135 changes: 135 additions & 0 deletions examples/tail-sampling/logs.alloy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading