diff --git a/kubernetes/elastic-helm/configmap-deployment.yaml b/kubernetes/elastic-helm/configmap-deployment.yaml index 742012f16c..5fff900ac6 100644 --- a/kubernetes/elastic-helm/configmap-deployment.yaml +++ b/kubernetes/elastic-helm/configmap-deployment.yaml @@ -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\\/[^\\/]+(\\/[^\\/]+)?)"), "upsert") + - set(name, attributes["short_url"]) resource: attributes: - key: deployment.environment @@ -70,6 +82,7 @@ data: - spanmetrics processors: - batch + - transform - resource receivers: - otlp diff --git a/src/otelcollector/otelcol-elastic-config.yaml b/src/otelcollector/otelcol-elastic-config.yaml index 2edc14bef0..2118a3cf9b 100644 --- a/src/otelcollector/otelcol-elastic-config.yaml +++ b/src/otelcollector/otelcol-elastic-config.yaml @@ -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: @@ -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\\/[^\\/]+(\\/[^\\/]+)?)"), "upsert") + - set(name, attributes["short_url"]) resource: attributes: - key: deployment.environment