Skip to content

feat: Explicitly define include/exclude attributes for views#4951

Open
thompson-tomo wants to merge 6 commits intoopen-telemetry:mainfrom
thompson-tomo:Exclude_Attributes
Open

feat: Explicitly define include/exclude attributes for views#4951
thompson-tomo wants to merge 6 commits intoopen-telemetry:mainfrom
thompson-tomo:Exclude_Attributes

Conversation

@thompson-tomo
Copy link
Copy Markdown
Contributor

@thompson-tomo thompson-tomo commented Mar 17, 2026

Fixes #

Changes

Explicitly define method to exclude metric attributes which was already mentioned functionality in the attributes property description in the spec. This exclude functionality was already defined in the stable declarative config. The include is added to avoid changing the behaviour of the existing property.

Discussed on slack -> https://cloud-native.slack.com/archives/C01N7PP1THC/p1773667594006789

For non-trivial changes, follow the change proposal process.

  • Related issues #
  • Related OTEP(s) #
  • Links to the prototypes (when adding or changing features)
  • CHANGELOG.md file updated for non-trivial changes
    • For trivial changes, include [chore] in the PR title to skip the changelog check
  • Spec compliance matrix updated if necessary

@thompson-tomo thompson-tomo requested review from a team as code owners March 17, 2026 05:18
`Attributes` (a list of [attribute keys](../common/README.md#attribute)) is
the recommended set of attribute keys to be used for the resulting metrics.

##### Instrument advisory parameter: `Exclude_Attributes`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need this in the API/advisory. if something should not be used, then instrumentation can not provide it at all.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't opt-in/deprecated attributes reside in this advisory? That way if stream config doesn't specify included/excluded attributes the advisory can be used to exclude them with 0 zero config.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opt-in attributes are not emitted by instrumentation (because SDK respects it) by default — they only appear when the user explicitly opts in via Views. So there's nothing to exclude in the zero-config case.

For exclude_attributes, the instrumentation library itself should stop emitting them (or the semantic conventions should guide the migration). The fix belongs at the instrumentation layer, not as an SDK-side exclude hint.

The existing Attributes (include) advisory already covers the zero-config story: the instrumentation author lists the recommended attribute keys, and anything not on that list is implicitly not recommended.

Copy link
Copy Markdown
Contributor

@dashpole dashpole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @cijothomas points out, this is already supported by the Attributes advisory parameter.

@cijothomas
Copy link
Copy Markdown
Member

Separately, I realized that Declarative Config already includes support for this - https://github.com/open-telemetry/opentelemetry-configuration/blob/main/schema/meter_provider.yaml#L605-L609 Spec wording is a bit hand-wavy/flexible, so I think it makes sense to make it more concrete.

@dashpole
Copy link
Copy Markdown
Contributor

That is part of the SDK's View, not part of the API.

@thompson-tomo thompson-tomo force-pushed the Exclude_Attributes branch 2 times, most recently from bcc605a to 2cbc29a Compare March 18, 2026 03:25
@thompson-tomo thompson-tomo changed the title feat: Explicitly define exclude attributes for metrics feat: Explicitly define include/exclude attributes for views Mar 18, 2026
@reyang
Copy link
Copy Markdown
Member

reyang commented Mar 18, 2026

@thompson-tomo is there an issue? We don't take new features unless there is an issue and the issue is triaged and accepted.

https://github.com/open-telemetry/opentelemetry-specification/blob/main/CONTRIBUTING.md#proposing-a-change

Copy link
Copy Markdown
Member

@reyang reyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thompson-tomo
Copy link
Copy Markdown
Contributor Author

@cijothomas / @dashpole I have descoped this PR to only touch the sdk view config.

This pr now bring across the definition from declarative config ie include & exclude of attributes. I have left the existing attribute.

@thompson-tomo
Copy link
Copy Markdown
Contributor Author

@reyang i was asked to raise a pr for this by a spec sponser @cijothomas as per https://cloud-native.slack.com/archives/C01N7PP1THC/p1773713324834269?thread_ts=1773667594.006789&channel=C01N7PP1THC&message_ts=1773713324.834269 hence I didn't think an issue was needed.

As identified by the sponser this functionality is actually already defined in stable declarative config so is it actually a new feature? And at the same time the spec already mentioned attributes can be excluded.

@reyang
Copy link
Copy Markdown
Member

reyang commented Mar 18, 2026

As identified by the sponser this functionality is actually already defined in stable declarative config so is it actually a new feature? And at the same time the spec already mentioned attributes can be excluded.

This is what I was using to determine for this PR:

  1. does this PR has "feat" in the title - if yes, I assume it is a feature
  2. does the changelog mention anything like "add" - if yes, I assume it is a feature

@thompson-tomo
Copy link
Copy Markdown
Contributor Author

Ok, I understand but in the case here it could just as easily be classified as a fix given that the spec itself mentions the ability to exclude attributes and it is in released stable declarative config. If you really want it could be classified as a corrective feature given it is fixing 2 things.

Anyway the issue is #4960

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.

4 participants