Skip to content

Read nf.container from NETFLIX_CONTAINER_NAME - #134

Merged
brharrington merged 1 commit into
mainfrom
nf-container-attribution
Oct 15, 2026
Merged

brharrington merged 1 commit into
mainfrom
nf-container-attribution

Conversation

@ecbadeaux

@ecbadeaux ecbadeaux commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Title: Read nf.container from NETFLIX_CONTAINER_NAME, and add NewConfigWithoutEnvTags

Summary

  • Container tag. nf.container is now read from NETFLIX_CONTAINER_NAME first, falling back to TITUS_CONTAINER_NAME. nf.process is unchanged and still comes from NETFLIX_PROCESS_NAME.
  • New constructor. NewConfigWithoutEnvTags is the same as NewConfigWithBuffer, but it does not add nf.container and nf.process 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.

NewConfigWithoutEnvTags: the environment tags are merged last into the extra common tags, and those are applied to every meter id, so they replace any tag with the same key on each 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. That process would stamp its own nf.container and nf.process on every metric it forwards, replacing the senders' values.
  • With the new constructor, those processes can leave the forwarded tags alone.

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
  • Same helper as before. It uses the existing addNonEmpty helper, which already accepts several variables. Values are trimmed and blank values are skipped, as before.
  • No change on Titus. While NETFLIX_CONTAINER_NAME is unset, the tags are exactly what they are today.
  • Existing constructors are unchanged. NewConfig and NewConfigWithBuffer still add the environment tags, and those still take precedence over extraCommonTags.
  • Internals. A private newConfig helper carries an includeEnvTags flag, and calculateExtraCommonTags skips the environment tags when it is false.

Docs

  • tagsFromEnvVars comment: lists the variables and the fallback.
  • NewConfig doc comment: says the environment tags take precedence over extraCommonTags, and points to NewConfigWithoutEnvTags.
  • NewConfigWithoutEnvTags doc comment: explains when to use it.
  • flushInterval comment on the new constructor: reads "used when bufferSize > 0; NewConfig uses 5 seconds". The existing "defaults to 5 seconds" comment on NewConfigWithBuffer isn't accurate, so I didn't copy it. I left that existing comment unchanged.

@brharrington brharrington changed the title Update Tag Attribution Read nf.container from NETFLIX_CONTAINER_NAME Oct 15, 2026
@brharrington
brharrington merged commit aa76146 into main Oct 15, 2026
2 checks passed
@brharrington
brharrington deleted the nf-container-attribution branch October 15, 2026 15:49
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.

2 participants