Skip to content

Conversation

laurit
Copy link
Contributor

@laurit laurit commented Sep 5, 2025

#14342 requires adding attributes to metrics that are not added to the span. While this could be overcome by modifying the spec to add these attributes to the span too in my opinion it really is a shortcoming of our current api.

@laurit laurit requested a review from a team as a code owner September 5, 2025 09:19
Copy link
Member

@jaydeluca jaydeluca left a comment

Choose a reason for hiding this comment

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

nice

* Add an {@link AttributesExtractor} to the given {@link InstrumenterBuilder} that provides
* attributes that are passed to the {@link OperationListener}s. This can be used to add
* attributes to the metrics without adding them to the span. To add attributes to the span use
* {@link InstrumenterBuilder#addAttributesExtractor(AttributesExtractor)}.
Copy link
Member

Choose a reason for hiding this comment

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

do you think this is worth documenting here or here too, or would it be better to wait until we decide to make it not experimental?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we can wait with this. Firstly need to decide whether we want to add something like this at all.

@trask
Copy link
Member

trask commented Sep 5, 2025

It's been an intentional decision in semantic conventions that the attributes on metrics should be a subset of the attributes on spans (where they both measure the same thing). Have you seen other cases where this would be helpful?

@laurit
Copy link
Contributor Author

laurit commented Sep 6, 2025

It's been an intentional decision in semantic conventions that the attributes on metrics should be a subset of the attributes on spans (where they both measure the same thing).

I wasn't aware that metrics attributes should be a subset of span attributes. Since the intention is that instrumentation api can be used outside of this project we also need to consider whether this could be useful for others.

* attributes to the metrics without adding them to the span. To add attributes to the span use
* {@link InstrumenterBuilder#addAttributesExtractor(AttributesExtractor)}.
*/
public static <REQUEST, RESPONSE> void addOperationAttributesExtractor(
Copy link
Member

Choose a reason for hiding this comment

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

based on the general name (operation), I think I'd expect these attributes to be stamped onto both spans and metrics?

maybe OperationListenerMetrics? to be clear that these are only passed to OperationListeners

(if I read it right)

@laurit laurit force-pushed the operation-attibutes branch from 6639c2c to 1651163 Compare September 17, 2025 07:32
@laurit laurit enabled auto-merge (squash) September 17, 2025 07:33
@laurit laurit merged commit 6fc2783 into open-telemetry:main Sep 17, 2025
89 checks passed
@laurit laurit deleted the operation-attibutes branch September 17, 2025 08:43
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.

3 participants