Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2c0a974
Router fails to start if using OTEL variables.
OriginLeon Feb 23, 2026
6681ed9
New changes
OriginLeon Feb 24, 2026
9a410be
Fixing fmt and clippy runs
OriginLeon Feb 24, 2026
e8c309d
Changeset
OriginLeon Feb 24, 2026
1f9e8bf
Merge branch 'dev' into marcelo/ROUTER-1609
OriginLeon Feb 25, 2026
14ed5ef
Update .changesets/feat_marcelo_router_1609.md
OriginLeon Feb 26, 2026
cc596f4
Block Router startup for certain OTEL environment variables
OriginLeon Feb 26, 2026
b594c12
Suggestions for #8915 (#8924)
carodewig Feb 26, 2026
071b724
Merge branch 'dev' into marcelo/ROUTER-1609
OriginLeon Feb 26, 2026
906c5d6
Update graphos-reporting.mdx
OriginLeon Feb 26, 2026
88d3de3
Update OTLP documentation with environment variable warnings
OriginLeon Feb 26, 2026
42a8612
Update OTLP documentation with environment variable warnings
OriginLeon Feb 26, 2026
8f5a006
Update otlp.mdx
OriginLeon Feb 26, 2026
eab74ae
Update warning to caution in OTLP documentation
OriginLeon Feb 26, 2026
e8d0e04
Change warning tag to caution in OTLP documentation
OriginLeon Feb 26, 2026
cac51ba
Change Warning to Caution in GraphOS Reporting
OriginLeon Feb 26, 2026
7383fa1
docs: apply 18 AI review suggestions across 3 files
apollo-librarian[bot] Feb 27, 2026
443103d
Update version references from v2.12.0 to v2.13.0
OriginLeon Feb 27, 2026
96085e4
Update version references in OTLP documentation
OriginLeon Feb 27, 2026
d89efa7
Update version references for Apollo Router telemetry
OriginLeon Feb 27, 2026
51a0fbe
docs: apply 7 AI review suggestions across 3 files
apollo-librarian[bot] Feb 27, 2026
9f113aa
Improving docs update as per review suggestions
OriginLeon Feb 27, 2026
283d478
docs: apply 9 AI review suggestions across 3 files
apollo-librarian[bot] Feb 27, 2026
8cb82bc
Merge branch 'dev' into marcelo/ROUTER-1609
OriginLeon Feb 27, 2026
b84124a
extract caution into shared component and edit wording
mabuyo Feb 27, 2026
e7c35f0
docs: apply 3 AI review suggestions across 1 file
apollo-librarian[bot] Mar 2, 2026
18852cb
Merge branch 'dev' into marcelo/ROUTER-1609
OriginLeon Mar 2, 2026
1ab09a4
Merge branch 'dev' into marcelo/ROUTER-1609
OriginLeon Mar 3, 2026
bd8bb14
Merge branch 'dev' into marcelo/ROUTER-1609
OriginLeon Mar 4, 2026
b346bc4
Merge branch 'dev' into marcelo/ROUTER-1609
OriginLeon Mar 4, 2026
575f52d
Merge branch 'dev' into marcelo/ROUTER-1609
OriginLeon Mar 11, 2026
4cfbefd
Merge branch 'dev' into marcelo/ROUTER-1609
OriginLeon Mar 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changesets/feat_marcelo_router_1609.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### Block Router startup when certain OTEL environment variables are set (PR #8915)

The Apollo Router will now *fail to start* if any of the following OpenTelemetry (OTEL) keyword environment variables are set:
• OTEL_EXPORTER_OTLP_ENDPOINT
• OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
• OTEL_EXPORTER_OTLP_METRICS_ENDPOINT
Comment thread
OriginLeon marked this conversation as resolved.

Using these variables *is not supported by the Router* since it can override or interfere with its built-in telemetry configuration, leading to unexpected behavior.

Previously, the Router emitted a warning when OTEL_EXPORTER_OTLP_ENDPOINT was present. With this change, *startup is now blocked* to prevent unintended telemetry configuration conflicts.

If your deployment defines any of these environment variables (for example, through base container images, platform defaults, or infrastructure tooling), they must be removed before starting the Router.
73 changes: 65 additions & 8 deletions apollo-router/src/executable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ pub(crate) static APOLLO_ROUTER_HOT_RELOAD_CLI: AtomicBool = AtomicBool::new(fal
const INITIAL_UPLINK_POLL_INTERVAL: Duration = Duration::from_secs(10);
const INITIAL_OCI_POLL_INTERVAL: Duration = Duration::from_secs(30);

const FORBIDDEN_OTEL_VARS: [&str; 3] = [
"OTEL_EXPORTER_OTLP_ENDPOINT",
"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT",
"OTEL_EXPORTER_OTLP_METRICS_ENDPOINT",
];

/// Subcommands
#[derive(Subcommand, Debug)]
enum Commands {
Expand Down Expand Up @@ -286,6 +292,10 @@ impl Opt {
fn err_require_opt(env_var: &str) -> anyhow::Error {
anyhow!("Use of Apollo Graph OS requires setting the {env_var} environment variable")
}

fn prohibit_env_vars(env_vars: &[&'static str]) -> Result<(), anyhow::Error> {
reject_environment_variables(&env_variables_set(env_vars))
}
}

/// This is the main router entrypoint.
Expand Down Expand Up @@ -475,6 +485,9 @@ impl Executable {
// Enable hot reload when dev mode is enabled
opt.hot_reload = opt.hot_reload || opt.dev;

// ROUTER-1609: prevent router from starting if OTEL environment variables are set.
Opt::prohibit_env_vars(&FORBIDDEN_OTEL_VARS)?;

let configuration = match (config, opt.config_path.as_ref()) {
(Some(_), Some(_)) => {
return Err(anyhow!(
Expand Down Expand Up @@ -738,14 +751,6 @@ impl Executable {
);
}

// Warn users that OTEL_EXPORTER_OTLP_ENDPOINT takes precedence over default configurations
// and may override trace export to Apollo Studio
if std::env::var("OTEL_EXPORTER_OTLP_ENDPOINT").is_ok() {
tracing::warn!(
"The OTEL_EXPORTER_OTLP_ENDPOINT environment variable is set. This takes precedence over default configurations and may override trace export to Apollo Studio."
);
}

let router = RouterHttpServer::builder()
.is_telemetry_disabled(opt.anonymous_telemetry_disabled)
.configuration(configuration)
Expand All @@ -768,6 +773,27 @@ fn graph_os() -> bool {
&& crate::services::APOLLO_GRAPH_REF.lock().is_some()
}

/// Of the environment variable names provided, return a list of those which are set in the environment.
fn env_variables_set(variables: &[&'static str]) -> Vec<&'static str> {
variables
.iter()
.filter(|v| !matches!(std::env::var(v), Err(std::env::VarError::NotPresent)))
.cloned()
.collect()
}

/// Return an error if the list of environment variables provided is not empty
fn reject_environment_variables(variables: &[&str]) -> Result<(), anyhow::Error> {
if variables.is_empty() {
Ok(())
} else {
Err(anyhow!(
"the following environment variables must not be set: {}",
variables.join(", ")
))
}
}

fn setup_panic_handler() {
// Redirect panics to the logs.
let backtrace_env = std::env::var("RUST_BACKTRACE");
Expand Down Expand Up @@ -796,6 +822,8 @@ fn setup_panic_handler() {
#[cfg(test)]
mod tests {
use crate::executable::add_log_filter;
use crate::executable::env_variables_set;
use crate::executable::reject_environment_variables;

#[test]
fn simplest_logging_modifications() {
Expand Down Expand Up @@ -1033,4 +1061,33 @@ mod tests {
);
}
}

#[test]
fn it_observes_environment_variables() {
const VALID_ENV_VAR: &str = "CARGO_HOME";

// if we're running tests, we should have a CARGO_HOME env variable present
assert!(std::env::var(VALID_ENV_VAR).is_ok());

// make sure the env_variables_set function can see that, both alone and in a list
assert!(env_variables_set(&[VALID_ENV_VAR]).contains(&VALID_ENV_VAR));
assert!(
env_variables_set(&[VALID_ENV_VAR, "ANOTHER_ENV_VARIABLE"]).contains(&VALID_ENV_VAR)
);

// make sure the env_variables_set variable doesn't find not-present environment variables
assert!(env_variables_set(&["AN_EXTREMELY_UNLIKELY_TO_BE_SET_VARIABLE"]).is_empty());
}

#[test]
fn it_returns_an_error_when_env_variable_provided() {
assert!(reject_environment_variables(&[]).is_ok());

let err = reject_environment_variables(&["env1"]).unwrap_err();
assert!(err.to_string().contains("env1"));

let err = reject_environment_variables(&["env1", "env2"]).unwrap_err();
assert!(err.to_string().contains("env1"));
assert!(err.to_string().contains("env2"));
}
}
15 changes: 15 additions & 0 deletions docs/shared/otel-envvars-caution.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Caution>

The following OpenTelemetry (OTEL) environment variables will override router's built-in telemetry configuration:

Check notice on line 3 in docs/shared/otel-envvars-caution.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/shared/otel-envvars-caution.mdx#L3

**Framing**: Use reader-centric language by adding "your" to clarify ownership of the router. **Products and Features**: Use an article before a component of a product like 'router's built-in telemetry configuration'. **Verb Tense and Voice**: Use present tense instead of future tense. ```suggestion The following OpenTelemetry (OTEL) environment variables will override your router's built-in telemetry configuration: ```

- `OTEL_EXPORTER_OTLP_ENDPOINT`

Check warning on line 5 in docs/shared/otel-envvars-caution.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/shared/otel-envvars-caution.mdx#L5

**Structural Elements**: Use hyphens (-) instead of asterisks for unordered list bullets. ```suggestion - `OTEL_EXPORTER_OTLP_ENDPOINT` ```
- `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`

Check warning on line 6 in docs/shared/otel-envvars-caution.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/shared/otel-envvars-caution.mdx#L6

**Structural Elements**: Use hyphens (-) instead of asterisks for unordered list bullets. ```suggestion - `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` ```
- `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT`

Check warning on line 7 in docs/shared/otel-envvars-caution.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/shared/otel-envvars-caution.mdx#L7

**Structural Elements**: Use hyphens (-) instead of asterisks for unordered list bullets. ```suggestion - `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` ```

In Apollo Router v2.12.0 and earlier, these variables will override router's telemetry settings and may cause traces or metrics to be sent to an unintended destination.

Check warning on line 9 in docs/shared/otel-envvars-caution.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/shared/otel-envvars-caution.mdx#L9

**Framing**: Use reader-centric language ("your") and more direct phrasing. **Products and Features**: Use an article before a component of a product like 'router's telemetry settings'. **Text Formatting**: Use plain text for version numbers, not code font. **Verb Tense and Voice**: Use present tense instead of future tense. **Word and Symbol Usage**: Avoid 'may'; use 'can' for capability or 'might' for potential occurrence. ```suggestion In Apollo Router v2.12.0 and earlier, these variables override your router's telemetry settings and may cause traces or metrics to be sent to an unintended destination. ```

<br/><br/>

In Apollo Router v2.13.0 and later, your router will not start if any of these variables are set. Remove them from your environment before launching.

Check warning on line 13 in docs/shared/otel-envvars-caution.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/shared/otel-envvars-caution.mdx#L13

**Products and Features**: Avoid using possessives like 'your' before a standalone product name. **Text Formatting**: Use plain text for version numbers, not code font. **Verb Tense and Voice**: Use present tense instead of future tense. **Voice**: Use authoritative and encouraging language to prescribe the correct action. **Word and Symbol Usage**: Use dictionary-valid contractions like 'won't' for better readability. ```suggestion In Apollo Router v2.13.0 and later, the router will not start if any of these variables are set. Remove them from your environment before launching. ```

</Caution>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ redirectFrom:
- /graphos/routing/graphos-reporting
---

import OTelEnvVarsCaution from '../../../../shared/otel-envvars-caution.mdx';

The GraphOS Router and Apollo Router Core can report operation usage metrics to [GraphOS](/graphos/) that you can then visualize in GraphOS Studio. These metrics also enable powerful GraphOS features like [schema checks](/graphos/delivery/schema-checks/).

## Enabling usage reporting
Expand Down Expand Up @@ -67,11 +69,7 @@ telemetry:
sampler: 0.01
```

<Note>

If your environment defines `OTEL_EXPORTER_OTLP_ENDPOINT` or `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`, they take precedence over your Router settings and may send traces to a different destination. Verify whether these variables are set and unset them if needed. For details, see the [OTLP exporter documentation](/router/configuration/telemetry/exporters/tracing/otlp).

</Note>
<OTelEnvVarsCaution />

## Reporting field-level traces

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ redirectFrom:
---
import BatchProcessorPreamble from '../../../../../../shared/batch-processor-preamble.mdx';
import BatchProcessorRef from '../../../../../../shared/batch-processor-ref.mdx';
import OTelEnvVarsCaution from '../../../../../../shared/otel-envvars-caution.mdx';

Enable and configure the [OpenTelemetry Protocol (OTLP)](https://www.opentelemetry.io/) exporter for metrics in the GraphOS Router or Apollo Router Core.

Expand Down Expand Up @@ -69,11 +70,7 @@ Defaults to:
* http://127.0.0.1:4317 for gRPC
* http://127.0.0.1:4318 for HTTP

<Note>

If your environment sets `OTEL_EXPORTER_OTLP_ENDPOINT` or `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT`, these variables take precedence over the `endpoint` configured in your `router.yaml`. If metrics aren't appearing at your expected endpoint, check if these environment variables are set and unset them if necessary.

</Note>
<OTelEnvVarsCaution />

### `grpc`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ redirectFrom:
---
import BatchProcessorPreamble from '../../../../../../shared/batch-processor-preamble.mdx';
import BatchProcessorRef from '../../../../../../shared/batch-processor-ref.mdx';
import OTelEnvVarsCaution from '../../../../../../shared/otel-envvars-caution.mdx';

Enable and configure the [OpenTelemetry Protocol (OTLP)](https://github.com/open-telemetry/opentelemetry-proto/blob/main/docs/specification.md) exporter for tracing in the GraphOS Router or Apollo Router Core.

Expand Down Expand Up @@ -65,11 +66,7 @@ Specify only the base URL in the endpoint parameter. The router automatically ad

</Note>

<Note>

If your environment sets `OTEL_EXPORTER_OTLP_ENDPOINT` or `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`, these variables take precedence over the `endpoint` configured in your `router.yaml`. If traces aren't appearing at your expected endpoint, check if these environment variables are set and unset them if necessary.

</Note>
<OTelEnvVarsCaution />

### `grpc`
Settings specific to the gRPC protocol for setting a custom SSL certificate, domain name, and metadata.
Expand Down
Loading