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-extras.yaml b/src/otelcollector/otelcol-elastic-config-extras.yaml index 530d47ad15..275146f136 100644 --- a/src/otelcollector/otelcol-elastic-config-extras.yaml +++ b/src/otelcollector/otelcol-elastic-config-extras.yaml @@ -10,13 +10,13 @@ service: pipelines: traces: receivers: [otlp] - processors: [batch] + processors: [batch,transform, resource] exporters: [spanmetrics, otlp/elastic] metrics: receivers: [otlp, spanmetrics] - processors: [batch] + processors: [batch, resource] exporters: [otlp/elastic] logs: receivers: [otlp] - processors: [batch] + processors: [batch, resource] exporters: [otlp/elastic] diff --git a/src/otelcollector/otelcol-elastic-config.yaml b/src/otelcollector/otelcol-elastic-config.yaml index 63ec2b97bd..2118a3cf9b 100644 --- a/src/otelcollector/otelcol-elastic-config.yaml +++ b/src/otelcollector/otelcol-elastic-config.yaml @@ -2,7 +2,9 @@ receivers: otlp: protocols: grpc: + endpoint: ${env:OTEL_COLLECTOR_HOST}:${env:OTEL_COLLECTOR_PORT_GRPC} http: + endpoint: ${env:OTEL_COLLECTOR_HOST}:${env:OTEL_COLLECTOR_PORT_HTTP} cors: allowed_origins: - "http://*" @@ -13,6 +15,23 @@ 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: + - 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 + value: "opentelemetry-demo" + action: upsert connectors: spanmetrics: