Skip to content

Introduce pprofile.PutAttribute helper #12798

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 13 commits into from
May 23, 2025

Conversation

rockdaboot
Copy link
Contributor

@rockdaboot rockdaboot commented Apr 3, 2025

Description

This introduces the pprofile.PutAttribute() helper method so profile extensions can modify attributes.

It replaces the yet unused pprofile.AddAttribute() function, as Add doesn't resonate well with the pcommon.Map Put* functions.

Additionally, the PutAttributes() helper takes into account the map k/v nature of attributes, while AddAttributes() didn't do this.

Testing

goos: linux
goarch: amd64
pkg: go.opentelemetry.io/collector/pdata/pprofile
cpu: 12th Gen Intel(R) Core(TM) i7-12800H
                                                          │   old.txt   │      new.txt       │
                                                          │   sec/op    │   sec/op     vs base   │
AddAttribute/with_a_new_string_attribute-20                 27.66n ± 3%
AddAttribute/with_an_existing_attribute-20                  27.18n ± 4%
AddAttribute/with_a_duplicate_attribute-20                  27.18n ± 2%
AddAttribute/with_a_hundred_attributes_to_loop_through-20   103.0n ± 4%
PutAttribute/with_a_new_string_attribute-20                               27.71n ± 2%
PutAttribute/with_an_existing_attribute-20                                28.14n ± 1%
PutAttribute/with_a_duplicate_attribute-20                                28.14n ± 2%
PutAttribute/with_a_hundred_attributes_to_loop_through-20                 28.15n ± 2%
geomean                                                     38.08n        28.04n       ? ¹ ²
¹ benchmark set differs from baseline; geomeans may not be comparable
² ratios must be >0 to compute geomean

                                                          │  old.txt   │      new.txt      │
                                                          │    B/op    │    B/op     vs base   │
AddAttribute/with_a_new_string_attribute-20                 16.00 ± 0%
AddAttribute/with_an_existing_attribute-20                  16.00 ± 0%
AddAttribute/with_a_duplicate_attribute-20                  16.00 ± 0%
AddAttribute/with_a_hundred_attributes_to_loop_through-20   16.00 ± 0%
PutAttribute/with_a_new_string_attribute-20                              16.00 ± 0%
PutAttribute/with_an_existing_attribute-20                               16.00 ± 0%
PutAttribute/with_a_duplicate_attribute-20                               16.00 ± 0%
PutAttribute/with_a_hundred_attributes_to_loop_through-20                16.00 ± 0%
geomean                                                     16.00        16.00       ? ¹ ²
¹ benchmark set differs from baseline; geomeans may not be comparable
² ratios must be >0 to compute geomean

                                                          │  old.txt   │      new.txt      │
                                                          │ allocs/op  │ allocs/op   vs base   │
AddAttribute/with_a_new_string_attribute-20                 1.000 ± 0%
AddAttribute/with_an_existing_attribute-20                  1.000 ± 0%
AddAttribute/with_a_duplicate_attribute-20                  1.000 ± 0%
AddAttribute/with_a_hundred_attributes_to_loop_through-20   1.000 ± 0%
PutAttribute/with_a_new_string_attribute-20                              1.000 ± 0%
PutAttribute/with_an_existing_attribute-20                               1.000 ± 0%
PutAttribute/with_a_duplicate_attribute-20                               1.000 ± 0%
PutAttribute/with_a_hundred_attributes_to_loop_through-20                1.000 ± 0%
geomean                                                     1.000        1.000       ? ¹ ²
¹ benchmark set differs from baseline; geomeans may not be comparable
² ratios must be >0 to compute geomean

See also #12390

@github-actions github-actions bot requested review from bogdandrutu and dmitryax April 3, 2025 14:59
@rockdaboot rockdaboot force-pushed the profiles-PutAttributes branch from 58245f3 to f5c3129 Compare April 3, 2025 15:00
Copy link

codecov bot commented Apr 3, 2025

Codecov Report

Attention: Patch coverage is 70.58824% with 15 lines in your changes missing coverage. Please review.

Project coverage is 91.58%. Comparing base (a867641) to head (c0079f8).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pdata/pprofile/attributes.go 70.58% 10 Missing and 5 partials ⚠️

❌ Your patch status has failed because the patch coverage (70.58%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12798      +/-   ##
==========================================
- Coverage   91.61%   91.58%   -0.04%     
==========================================
  Files         505      505              
  Lines       28424    28475      +51     
==========================================
+ Hits        26042    26078      +36     
- Misses       1873     1883      +10     
- Partials      509      514       +5     

☔ 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.

@rockdaboot rockdaboot marked this pull request as ready for review April 3, 2025 15:22
@rockdaboot rockdaboot requested review from mx-psi, dmathieu and a team as code owners April 3, 2025 15:22
@dmathieu
Copy link
Member

dmathieu commented Apr 7, 2025

Additionally, the PutAttributes() helper takes into account the map k/v nature of attributes, while AddAttributes() didn't do this.

Could you describe that a bit more? (maybe in the changelog?) I find the motivation for this change hard to figure out.

@rockdaboot rockdaboot requested a review from dmathieu April 7, 2025 10:11
@rockdaboot rockdaboot requested a review from dmathieu April 14, 2025 10:06
@rockdaboot
Copy link
Contributor Author

@bogdandrutu @dmitryax Can you please take a look?

@rockdaboot
Copy link
Contributor Author

@bogdandrutu Are there any further concerns or can you merge this, please?

@mx-psi
Copy link
Member

mx-psi commented May 20, 2025

@bogdandrutu @dmitryax I will merge this by EOW if you do not object before then

@mx-psi mx-psi added this pull request to the merge queue May 23, 2025
Merged via the queue into open-telemetry:main with commit 749f997 May 23, 2025
55 of 56 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