Skip to content

Commit

Permalink
feat: set span name as shorten url path
Browse files Browse the repository at this point in the history
  • Loading branch information
rogercoll committed Aug 23, 2024
1 parent ee4ea21 commit 6a62c0a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 13 additions & 0 deletions kubernetes/elastic-helm/configmap-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ data:
extensions:
processors:
batch: {}
# Transforming span names for easier identification. See: https://github.com/open-telemetry/opentelemetry-demo/issues/1676
transform:
error_mode: ignore
trace_statements:
- context: span
conditions:
- IsString(attributes["http.url"])
statements:
- merge_maps(attributes, URL(attributes["http.url"]), "upsert")
# This pattern should correctly capture the first one or two segments of a URL and assign them to the short_url named group.
- merge_maps(attributes, ExtractPatterns(attributes["url.path"], "^(?P<short_url>\\/[^\\/]+(\\/[^\\/]+)?)"), "upsert")
- set(name, attributes["short_url"])
resource:
attributes:
- key: deployment.environment
Expand Down Expand Up @@ -70,6 +82,7 @@ data:
- spanmetrics
processors:
- batch
- transform
- resource
receivers:
- otlp
Expand Down
5 changes: 4 additions & 1 deletion src/otelcollector/otelcol-elastic-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ exporters:

processors:
batch:
# Transforming span names for easier identification. See: https://github.com/open-telemetry/opentelemetry-demo/issues/1676
transform:
error_mode: ignore
trace_statements:
Expand All @@ -23,7 +24,9 @@ processors:
- IsString(attributes["http.url"])
statements:
- merge_maps(attributes, URL(attributes["http.url"]), "upsert")
- set(name, attributes["url.path"])
# This pattern should correctly capture the first one or two segments of a URL and assign them to the short_url named group.
- merge_maps(attributes, ExtractPatterns(attributes["url.path"], "^(?P<short_url>\\/[^\\/]+(\\/[^\\/]+)?)"), "upsert")
- set(name, attributes["short_url"])
resource:
attributes:
- key: deployment.environment
Expand Down

0 comments on commit 6a62c0a

Please sign in to comment.