Skip to content

Attribute groups in schema v2#933

Merged
jerbly merged 10 commits intoopen-telemetry:mainfrom
lmolkova:attribute-groups-v2
Oct 8, 2025
Merged

Attribute groups in schema v2#933
jerbly merged 10 commits intoopen-telemetry:mainfrom
lmolkova:attribute-groups-v2

Conversation

@lmolkova
Copy link
Member

@lmolkova lmolkova commented Sep 12, 2025

Implements #824 (comment)

TODO:

  • changelog
  • tests
  • JSON schema and doc

Semconv PR to update http and DB: open-telemetry/semantic-conventions@main...lmolkova:semantic-conventions:schema-v2-http-db

Example

  - id: attributes.db.client.authority
    visibility: internal
    attributes:
      - ref: server.address
        brief: Name of the database host.
      - ref: server.port
        requirement_level:
          conditionally_required: If using a port other than the default port for this DBMS and if `server.address` is set.
metrics:
  - name: db.client.operation.duration
    ...
    attributes:
      - ref_group: attributes.db.client.query
      - ref_group: attributes.db.client.response
      - ref_group: attributes.db.client.authority
      - ref_group: attributes.db.client.network
      - ref_group: attributes.db.client.operation
      - ref: db.system.name
        requirement_level: required
      - ref: db.stored_procedure.name
        requirement_level:
          recommended: If operation applies to a specific stored procedure.
...

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

clippy found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@lmolkova lmolkova force-pushed the attribute-groups-v2 branch 2 times, most recently from 752c9f1 to 2db3a6e Compare September 12, 2025 15:45
@codecov
Copy link

codecov bot commented Sep 22, 2025

Codecov Report

❌ Patch coverage is 94.48819% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.3%. Comparing base (8e36299) to head (820fcc6).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/weaver_semconv/src/v2/attribute_group.rs 84.0% 4 Missing ⚠️
crates/weaver_resolved_schema/src/registry.rs 0.0% 1 Missing ⚠️
crates/weaver_resolver/src/registry.rs 98.2% 1 Missing ⚠️
crates/weaver_semconv/src/v2/mod.rs 93.3% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #933     +/-   ##
=======================================
+ Coverage   78.0%   78.3%   +0.3%     
=======================================
  Files         76      77      +1     
  Lines       6021    6121    +100     
=======================================
+ Hits        4699    4796     +97     
- Misses      1322    1325      +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lmolkova lmolkova marked this pull request as ready for review September 22, 2025 23:15
@lmolkova lmolkova requested a review from a team as a code owner September 22, 2025 23:15
Copy link
Contributor

@thompson-tomo thompson-tomo left a comment

Choose a reason for hiding this comment

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

I also might have missed it but are we emitting public attribute groups as a part of the resolved schema and can they be distinguished from internal?


A public attribute group definition consists of the following properties:

- `id` - Required. Uniquely identifies the attribute group.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we not call this key and then generate an id for the group?

This key should also be included in the resolved schema as a property of the attribute on a signal when it is a public group otherwise empty. This is to help with documentation.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't understand the proposal. This is a group id, key is used for attributes themselves, id matches today's structure and would be more intuitive than key.

Public group ids would eventually be available on via lineage in the resolved schema after we figure out how lineage should work in v2 (#933 (comment))

Copy link
Contributor

@thompson-tomo thompson-tomo Sep 27, 2025

Choose a reason for hiding this comment

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

I see it as the same as attributes as you define a key which you then use to reference it from within an attributes array. Whereas an id should be unique across signals which is why id is usually prefixed with the signal type.

If it is more intuitive then it should be the same for attributes given they aim for the same thing which is adding 1 or more attributes to a signal.

I agree lineage could be made to work but it currently doesn't work. we would need to ensure that it can be distinguished from simply coming from the registry. This is so we can link from a span to the public group definition which can provide additional details about sourcing the values for instance.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't agree that attributes are the same as attribute groups. Also I don't see how renaming id to key makes anything better.

Copy link
Contributor

Choose a reason for hiding this comment

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

For me It is all about how it would be used.

Let's think about some of the use cases where an identifying label for a group could/would be used:

  • rendering a title of the group in docs. Currently string manipulation is done
  • Rendered in attribute tables on signals so link to group can be implemented.
  • Added on signal definitions to add the attributes
  • Code generating methods to add the groups to signals

Hence considering the above and that id's are implicitly used for internal linking, we should either add a name alongside the id with both being user defined or internally generate the id based on the key and type.

@lmolkova
Copy link
Member Author

I also might have missed it but are we emitting public attribute groups as a part of the resolved schema and can they be distinguished from internal?

yes, please take a look at the syntax doc.

Copy link
Contributor

@lquerel lquerel left a comment

Choose a reason for hiding this comment

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

LGTM

@thompson-tomo
Copy link
Contributor

thompson-tomo commented Sep 27, 2025

I also might have missed it but are we emitting public attribute groups as a part of the resolved schema and can they be distinguished from internal?
yes, please take a look at the syntax doc.

Isn't the syntax document describing what a user writes (un-resolved), whereas the resolved is what is emitted by Weaver? In effect shouldn't we have the visibility field included in https://github.com/open-telemetry/weaver/blob/561ff28a4e3e81f9175457cda7bf63199b59fd5b/crates/weaver_resolved_schema/src/registry.rs

Also doesn't your comment in #933 (comment) confirm that groups are no longer present?

@lmolkova
Copy link
Member Author

I also might have missed it but are we emitting public attribute groups as a part of the resolved schema and can they be distinguished from internal?
yes, please take a look at the syntax doc.

Isn't the syntax document describing what a user writes (un-resolved), whereas the resolved is what is emitted by Weaver? In effect shouldn't we have the visibility field included in https://github.com/open-telemetry/weaver/blob/561ff28a4e3e81f9175457cda7bf63199b59fd5b/crates/weaver_resolved_schema/src/registry.rs

Also doesn't your comment in #933 (comment) confirm that groups are no longer present?

this PR does not implement resolved schema v2 - it does not exist yet, @jsuereth is working on it. After this PR v2 internal groups are do not appear in the resolve schema. public groups do. All v1 groups appear. It's still an intermediate state

@jerbly jerbly merged commit 8462991 into open-telemetry:main Oct 8, 2025
24 checks passed
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.

5 participants