diff --git a/.env b/.env index 03569c3acc..70797adb3b 100644 --- a/.env +++ b/.env @@ -3,7 +3,9 @@ IMAGE_VERSION=v1.1.0 IMAGE_NAME=ghcr.io/open-telemetry/demo # Collector -OTEL_EXPORTER_OTLP_ENDPOINT=http://otelcol:4317 +OTEL_COLLECTOR_HOST=otelcol +OTEL_COLLECTOR_PORT=4317 +OTEL_EXPORTER_OTLP_ENDPOINT=http://${OTEL_COLLECTOR_HOST}:${OTEL_COLLECTOR_PORT} OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=${OTEL_EXPORTER_OTLP_ENDPOINT} OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=${OTEL_EXPORTER_OTLP_ENDPOINT} PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4318/v1/traces diff --git a/CHANGELOG.md b/CHANGELOG.md index 814d942011..8228f5a744 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -150,3 +150,5 @@ significant modifications will be credited to OpenTelemetry Authors. ([#512](https://github.com/open-telemetry/opentelemetry-demo/pull/457)) * Added support for non-root containers ([#615](https://github.com/open-telemetry/opentelemetry-demo/pull/615)) +* Add tracing to Envoy (frontend-proxy) +([#613](https://github.com/open-telemetry/opentelemetry-demo/pull/613)) diff --git a/docker-compose.yml b/docker-compose.yml index ed242cb28e..92b6f8b69c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -326,6 +326,8 @@ services: - GRAFANA_SERVICE_HOST - JAEGER_SERVICE_PORT - JAEGER_SERVICE_HOST + - OTEL_COLLECTOR_HOST + - OTEL_COLLECTOR_PORT - ENVOY_PORT depends_on: - frontend diff --git a/docs/services/frontendproxy.md b/docs/services/frontendproxy.md new file mode 100644 index 0000000000..9eca9fe3d2 --- /dev/null +++ b/docs/services/frontendproxy.md @@ -0,0 +1,60 @@ +# Frontend Proxy(Envoy) + +The frontend proxy is used as a reverse proxy for user-facing web +interfaces such as the frontend, Jaeger, Grafana, load generator, +and feature flag service. + +## Enabling OpenTelemetry + +**NOTE: Only non-synthetic requests will trigger the envoy tracing.** + +In order to enable Envoy to produce spans whenever receiving a request, +the following configuration is required: + +```yaml +static_resources: + listeners: + - address: + socket_address: + address: 0.0.0.0 + port_value: ${ENVOY_PORT} + filter_chains: + - filters: + - name: envoy.filters.network.http_connection_manager + typed_config: + "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager + codec_type: AUTO + stat_prefix: ingress_http + tracing: + provider: + name: envoy.tracers.opentelemetry + typed_config: + "@type": type.googleapis.com/envoy.config.trace.v3.OpenTelemetryConfig + grpc_service: + envoy_grpc: + cluster_name: opentelemetry_collector + timeout: 0.250s + service_name: frontend-proxy + + clusters: + - name: opentelemetry_collector + type: STRICT_DNS + lb_policy: ROUND_ROBIN + typed_extension_protocol_options: + envoy.extensions.upstreams.http.v3.HttpProtocolOptions: + "@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions + explicit_http_config: + http2_protocol_options: {} + load_assignment: + cluster_name: opentelemetry_collector + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: ${OTEL_COLLECTOR_HOST} + port_value: ${OTEL_COLLECTOR_PORT} +``` + +Where `OTEL_COLLECTOR_HOST` and `OTEL_COLLECTOR_PORT` are passed via +environment variables. diff --git a/src/frontendproxy/envoy.tmpl.yaml b/src/frontendproxy/envoy.tmpl.yaml index 5ef71bdcb7..ab9f96ffa0 100644 --- a/src/frontendproxy/envoy.tmpl.yaml +++ b/src/frontendproxy/envoy.tmpl.yaml @@ -11,6 +11,16 @@ static_resources: "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager codec_type: AUTO stat_prefix: ingress_http + tracing: + provider: + name: envoy.tracers.opentelemetry + typed_config: + "@type": type.googleapis.com/envoy.config.trace.v3.OpenTelemetryConfig + grpc_service: + envoy_grpc: + cluster_name: opentelemetry_collector + timeout: 0.250s + service_name: frontend-proxy route_config: name: local_route virtual_hosts: @@ -38,6 +48,23 @@ static_resources: "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router clusters: + - name: opentelemetry_collector + type: STRICT_DNS + lb_policy: ROUND_ROBIN + typed_extension_protocol_options: + envoy.extensions.upstreams.http.v3.HttpProtocolOptions: + "@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions + explicit_http_config: + http2_protocol_options: {} + load_assignment: + cluster_name: opentelemetry_collector + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: ${OTEL_COLLECTOR_HOST} + port_value: ${OTEL_COLLECTOR_PORT} - name: frontend type: STRICT_DNS lb_policy: ROUND_ROBIN