Skip to content

profiles: avoid 'optional' keyword usage #659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 12, 2025

Conversation

jhalliday
Copy link
Contributor

Prefer reference tables with an explicit null/unused entry at index=0, rather than 'optional' pointers into the tables.

Following discussion in the profiling SIG, we note that other OpenTelemetry signal types don't use 'optional' protobuf fields and, whilst the Dictionary lookup tables pattern in the profile signal type require some form of 'null pointer' value for indicating unset indexes into the tables, the string_table convention inherited from pprof prefers table[0] = "" i.e. treats a 0 value pointer as null.

In the interest of improving consistency with other signal types and within the profiling signal itself, we therefore make mapping and link tables/references follow the same convention of having an explicit 'not used' default value as the first element in the dictionary table.

Note that I've chosen to not update the docs for the other dictionary tables to require the same use of the [0] slot, as at present no _index fields optionally reference into them, so I'm treating it as unnecessary at this time. However, it can be argued that greater clarity and consistency would be achieved by making the convention universal in anticipation before adoption becomes widespread and it gets harder to change.

@jhalliday jhalliday requested review from a team as code owners May 19, 2025 12:03
@jhalliday
Copy link
Contributor Author

@open-telemetry/profiling-maintainers

@felixge
Copy link
Member

felixge commented May 20, 2025

Thanks for the PR 🙇

Note that I've chosen to not update the docs for the other dictionary tables to require the same use of the [0] slot, as at present no _index fields optionally reference into them, so I'm treating it as unnecessary at this time. However, it can be argued that greater clarity and consistency would be achieved by making the convention universal in anticipation before adoption becomes widespread and it gets harder to change.

I'm in favor of considering this.

Copy link
Contributor

@florianl florianl left a comment

Choose a reason for hiding this comment

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

Thanks for working on this 🙏

incorporate review feedback.
@felixge
Copy link
Member

felixge commented Jun 12, 2025

@tigrannajaryan can you help us find a spec approver?

@jsuereth
Copy link
Contributor

jsuereth commented Jun 12, 2025

Note that I've chosen to not update the docs for the other dictionary tables to require the same use of the [0] slot, as at present no _index fields optionally reference into them, so I'm treating it as unnecessary at this time. However, it can be argued that greater clarity and consistency would be achieved by making the convention universal in anticipation before adoption becomes widespread and it gets harder to change.

@jhalliday can you open an issue for doing this work so it's not lost?

@tigrannajaryan tigrannajaryan merged commit 29ad186 into open-telemetry:main Jun 12, 2025
27 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants