Hi all,

I'd like to propose a small change to the Datadog HTTP metric reporter:
fall back to a `*DD_API_KEY*` environment variable when the `*apikey*`
configuration property is not set.

*Motivation*

For users running Flink on Kubernetes via the Flink Operator, the current
API-key configuration is hard to use securely. `flink-conf.yaml` is mounted
from a read-only ConfigMap, so injecting secrets via the existing
`FLINK_PROPERTIES` mechanism fails — the Docker entrypoint tries to append
to the read-only file and the pod crashes.

Reading the Datadog API key from an environment variable lets operators
inject it via the standard Kubernetes Secret + `envFrom` pattern (e.g.
through the External Secrets Operator), without any filesystem writes or
operator-side workarounds.

*Proposed behavior*

Resolution order in `*DatadogHttpReporterFactory#getApiKey*`:

   1. `DD_API_KEY` environment variable (if set and non-empty)
   2. `apikey` configuration property (if set and non-empty)
   3. null

The env var winning over config is deliberate: it lets operators override
config at deploy time without rewriting `flink-conf.yaml`, which is the
whole point of supporting env vars in this context. A prior reviewer (David
Radley) suggested this ordering on the PR, and I agree it's the right shape.

Fully backward compatible — existing deployments that only set `*apikey*`
continue to work unchanged.

*Scope*

The change is small: factory + tests + EN/ZH docs, ~140 LOC, no new
dependencies. Tests don't use Mockito or reflection (per Flink testing
guidelines) — env lookup is injected as a `Function<String, String>` and
tests pass a lambda.

*Jira*: https://issues.apache.org/jira/browse/FLINK-36456
*PR*: https://github.com/apache/flink/pull/27432

The PR has been open since January and I've been unable to get a
metrics-area committer's attention through the normal channels. Looking for
a thumbs-up here on the approach so review can proceed — happy to adjust
the design (e.g. flip the precedence, or scope the env var to a different
name) based on feedback.

Thanks,
Thieno

Reply via email to