envoyproxy / envoyproxy/envoy

OpenTelemetry tracer does not expand variables in `initial_metadata`

Open
#25,073 2 comments 0 reactions 0 assignees View on GitHub
area/docs area/grpc enhancement no stalebot
Dominant language
C++
Stars
28.9k
Forks
5.6k
Avg merge
1d 20h
Merged PRs (30d)
437

Description

*Title*: OpenTelemetry tracer does not expand variables in `initial_metadata`

*Description*:
Envoy version 1.24.1. I am trying to use the OpenTelemetry tracer (https://www.envoyproxy.io/docs/envoy/v1.24.1/api-v3/config/trace/v3/opentelemetry.proto).

In the configuration I am trying to set an access_token to be used with the outgoing request. If I hard code the token, the request works fine, but trying to use any format specifiers does not work. The format specifier is treated as a literal string.

The docs for GrpcService (https://www.envoyproxy.io/docs/envoy/v1.24.1/api-v3/config/core/v3/grpc_service.proto#envoy-v3-api-msg-config-core-v3-grpcservice) allow setting `initial_metadata`, which is a `HeaderValue` (https://www.envoyproxy.io/docs/envoy/v1.24.1/api-v3/config/core/v3/base.proto#envoy-v3-api-msg-config-core-v3-headervalue).

The docs for that say:

![image](https://user-images.githubusercontent.com/509887/213788040-ca96bad0-fee6-4655-86d6-eea2cad59d0f.png)

Which goes to the format specifier docs: https://www.envoyproxy.io/docs/envoy/v1.24.1/configuration/observability/access_log/usage#config-access-log-format

The one I want to use is:

%ENVIRONMENT(X):Z%
Environment value of environment variable X. If no valid environment variable X, ‘-‘ symbol will be used. Z is an optional parameter denoting string truncation up to Z characters long.

The string value does not seem to be expanded, instead it is sent directly. So what it actually sends is the actualy percent enclosed string. e.g.

```
"%ENVIRONMENT(LIGHTSTEP_ACCESS_TOKEN)%"
```

This is also true if I try: `%HOSTNAME%`.

*Repro steps*:

This is the config I am using.

```
tracing:
provider:
name: envoy.tracers.opentelemetry
typed_config:
"@type": type.googleapis.com/envoy.config.trace.v3.OpenTelemetryConfig
grpc_service:
envoy_grpc:
cluster_name: lightstep_opentelemetry
initial_metadata:
- key: lightstep-access-token
value: "%ENVIRONMENT(LIGHTSTEP_ACCESS_TOKEN)%"
# value: "%HOSTNAME%" (also does not work)
service_name: envoy-edge
verbose: true
```

The access token actually sent to the backend is: `%ENVIRONMENT(LIGHTSTEP_ACCESS_TOKEN)%`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.