Skip to content

Update tag attribution - #143

Merged
ecbadeaux merged 1 commit into
mainfrom
nf-container-attribution
Oct 17, 2026
Merged

ecbadeaux merged 1 commit into
mainfrom
nf-container-attribution

Conversation

@ecbadeaux

@ecbadeaux ecbadeaux commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Title: Read NETFLIX_CONTAINER_NAME and NETFLIX_PROCESS_NAME, and add an includeEnvTags option to Config

Summary

  • nf.container: read from NETFLIX_CONTAINER_NAME first, falling back to TITUS_CONTAINER_NAME.
  • nf.process: read from NETFLIX_PROCESS_NAME first, falling back to TITUS_PROCESS_NAME, which is now deprecated. Before this change, only TITUS_PROCESS_NAME was read.
  • New Config parameter: includeEnvTags, which defaults to true. When it is false, neither tag is added from the environment.

Why

NETFLIX_CONTAINER_NAME: TITUS_CONTAINER_NAME exists only on Titus, so containers on other platforms get no nf.container tag today. NETFLIX_CONTAINER_NAME is a platform-neutral variable that holds the container's name (the Kubernetes container name). Reading it first, with the Titus variable as the fallback, adds coverage for other platforms and leaves Titus unchanged.

NETFLIX_PROCESS_NAME: every other spectator client (Java, Go, Python, JavaScript) reads nf.process from NETFLIX_PROCESS_NAME. This change makes C++ consistent with them. TITUS_PROCESS_NAME is kept as a fallback, so existing setups keep working.

includeEnvTags: the environment tags are applied to every meter id with MeterId::WithTags, which replaces any tag with the same key on the meter.

  • That is correct for an application reporting its own metrics.
  • It is wrong for a process that reports metrics on behalf of other containers or processes, such as a relay or an agent. For example, atlas-system-agent's pod monitor sets a per-container nf.container on each meter, and the agent's own container name would replace it.
  • Passing false leaves those tags alone. Tags passed in extraTags are still added.

Behavior

NETFLIX_CONTAINER_NAME TITUS_CONTAINER_NAME nf.container
app main app
unset, empty or blank main main
app unset app
unset unset not added

nf.process follows the same rules, with NETFLIX_PROCESS_NAME first and TITUS_PROCESS_NAME as the fallback.

  • Precedence is unchanged. The environment tags are still applied after the passed-in tags, so they win on a key collision.
  • Values are stored untrimmed, as before. A new AddFirstNonEmpty helper replaces the two getenv blocks.
  • Source compatible. Existing Config(writerConfig) and Config(writerConfig, extraTags) calls compile unchanged. Callers do need to rebuild, because the constructor's signature changed.

Behavior change: an application whose environment has NETFLIX_PROCESS_NAME set now gets that value as nf.process. If it also sets TITUS_PROCESS_NAME, the NETFLIX_PROCESS_NAME value wins. Applications that set only TITUS_PROCESS_NAME see no change.

Docs

libs/config/README.md:

  • Documents both variables and their fallbacks, and marks TITUS_PROCESS_NAME as deprecated.
  • Explains the precedence over extraTags.
  • Says to set NETFLIX_PROCESS_NAME separately for each process, and lists the allowed characters.
  • Documents the includeEnvTags option, with an example.
  • Fixes "there" to "their".

libs/config/config.h: a comment on the constructor explains includeEnvTags.

@ecbadeaux
ecbadeaux merged commit 59b087c into main Oct 17, 2026
1 check passed
@ecbadeaux
ecbadeaux deleted the nf-container-attribution branch October 17, 2026 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant