diff --git a/.env b/.env index 4f9e197189..27d87a47f6 100644 --- a/.env +++ b/.env @@ -9,7 +9,7 @@ OTEL_JAVA_AGENT_VERSION=2.23.0 OPENTELEMETRY_CPP_VERSION=1.24.0 # Dependent images -COLLECTOR_CONTRIB_IMAGE=ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.144.0 +COLLECTOR_CONTRIB_IMAGE=ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.145.0 FLAGD_IMAGE=ghcr.io/open-feature/flagd:v0.12.9 GRAFANA_IMAGE=grafana/grafana:12.3.1 JAEGERTRACING_IMAGE=jaegertracing/jaeger:2.12.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index ca1d9efc12..65dd9a8d6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,15 @@ the release. * [accounting] fix memory leak with dbcontext ([#2876](https://github.com/open-telemetry/opentelemetry-demo/pull/2876)) +* [chore] Upgrade OTel Collector to v0.145.0 with :warning: breaking change: + OTLP exporters renamed from `otlp` to `otlp_grpc/jaeger` and from + `otlphttp/prometheus` to `otlp_http/prometheus` + [#2942](https://github.com/open-telemetry/opentelemetry-demo/pull/2942) +* [collector] Use the + [`set_semconv_span_name()`](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor#set_semconv_span_name) + function to better handle the next.js issue + [High-cardinality HTTP span names #54694](https://github.com/vercel/next.js/issues/54694) + [#2942](https://github.com/open-telemetry/opentelemetry-demo/pull/2942) ## 2.2.0 diff --git a/src/otel-collector/otelcol-config.yml b/src/otel-collector/otelcol-config.yml index 81f2de4d66..480b58a612 100644 --- a/src/otel-collector/otelcol-config.yml +++ b/src/otel-collector/otelcol-config.yml @@ -121,7 +121,7 @@ receivers: enabled: true exporters: debug: - otlp_grpc: + otlp_grpc/jaeger: endpoint: "jaeger:4317" tls: insecure: true @@ -152,14 +152,51 @@ processors: spike_limit_percentage: 25 resourcedetection: detectors: [env, docker, system] - transform: + transform/sanitize_spans: error_mode: ignore trace_statements: - context: span statements: - # could be removed when https://github.com/vercel/next.js/pull/64852 is fixed upstream - - replace_pattern(name, "\\?.*", "") - - replace_match(name, "GET /api/products/*", "GET /api/products/{productId}") + # Sanitize spans to prevent span metrics cardinality explosion + # caused by non-compliant high cardinality span names: + # 1. Define missing http.route on key HTTP operations for meaningful operation names + # 2. Then normalize span names; http server spans lacking http.route default to operations "GET", "POST", etc. + + # FRONTEND SERVICE + + # Workaround for Next.js high cardinality span name issue: https://github.com/vercel/next.js/issues/54694 + - set(span.attributes["http.route"], "/api/cart") where + span.kind == SPAN_KIND_SERVER and + resource.attributes["service.name"] == "frontend" and + span.attributes["http.route"] == nil and + IsMatch(span.attributes["http.target"], "\\/api\\/cart") # e.g. # /api/cart + + - set(span.attributes["http.route"], "/api/checkout") where + span.kind == SPAN_KIND_SERVER and + resource.attributes["service.name"] == "frontend" and + span.attributes["http.route"] == nil and + IsMatch(span.attributes["http.target"], "\\/api\\/checkout") # e.g. # /api/checkout + + - set(span.attributes["http.route"], "/api/products/{productId}") where + span.kind == SPAN_KIND_SERVER and + resource.attributes["service.name"] == "frontend" and + span.attributes["http.route"] == nil and + IsMatch(span.attributes["http.target"], "\\/api\\/products\\/.*") # e.g. /api/products/1YMWWN1N4O + + - set(span.attributes["http.route"], "/api/recommendations") where + span.kind == SPAN_KIND_SERVER and + resource.attributes["service.name"] == "frontend" and + span.attributes["http.route"] == nil and + IsMatch(span.attributes["http.target"], "\\/api\\/recommendations") # e.g. # /api/recommendations?productIds=... + + - set(span.attributes["http.route"], "/api/data") where + span.kind == SPAN_KIND_SERVER and + resource.attributes["service.name"] == "frontend" and + span.attributes["http.route"] == nil and + IsMatch(span.attributes["http.target"], "\\/api\\/data.*") # e.g. # " /api/data?contextKeys=telescopes" or /api/data/?contextKeys=cameras + + # SANITIZE ALL SPAN NAMES TO PREVENT CARDINALITY EXPLOSION + - set_semconv_span_name("1.37.0", "original_span_name") connectors: spanmetrics: @@ -168,8 +205,8 @@ service: pipelines: traces: receivers: [otlp] - processors: [resourcedetection, memory_limiter, transform] - exporters: [otlp_grpc, debug, spanmetrics] + processors: [resourcedetection, memory_limiter, transform/sanitize_spans] + exporters: [otlp_grpc/jaeger, debug, spanmetrics] metrics: receivers: [docker_stats, httpcheck/frontend-proxy, hostmetrics, nginx, otlp, postgresql, redis, spanmetrics] processors: [resourcedetection, memory_limiter]