Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FrontendProxy] Add tracing to Envoy #613

Merged
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ FRONTEND_ADDR=frontend:${FRONTEND_PORT}
# Envoy
FRONTEND_HOST=frontend
ENVOY_PORT=8080
OTEL_COLLECTOR_HOST=otelcol
OTEL_COLLECTOR_PORT=4317

# Redis
REDIS_PORT=6379
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,5 @@ significant modifications will be credited to OpenTelemetry Authors.
([#600](https://github.com/open-telemetry/opentelemetry-demo/pull/600))
* Add HTTP client instrumentation to shippingservice
([#610](https://github.com/open-telemetry/opentelemetry-demo/pull/610))
* Add tracing to Envoy (frontend-proxy)
([#613](https://github.com/open-telemetry/opentelemetry-demo/pull/613))
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ services:
- GRAFANA_SERVICE_HOST
- JAEGER_SERVICE_PORT
- JAEGER_SERVICE_HOST
- OTEL_COLLECTOR_HOST
puckpuck marked this conversation as resolved.
Show resolved Hide resolved
- OTEL_COLLECTOR_PORT
- ENVOY_PORT
- ENVOY_UID=0
depends_on:
Expand Down
58 changes: 58 additions & 0 deletions docs/services/frontendproxy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# 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

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.
27 changes: 27 additions & 0 deletions src/frontendproxy/envoy.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down