-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce pprofile.AddAttribute helper (#12390)
#### Description This introduces the `pprofile.AddAttribute` helper method so profile extensions can modify attributes. Closes #12206 ``` BenchmarkAddAttribute BenchmarkAddAttribute/with_a_new_string_attribute BenchmarkAddAttribute/with_a_new_string_attribute-10 30461164 39.55 ns/op 32 B/op 2 allocs/op BenchmarkAddAttribute/with_an_existing_attribute BenchmarkAddAttribute/with_an_existing_attribute-10 30714298 39.44 ns/op 32 B/op 2 allocs/op BenchmarkAddAttribute/with_a_duplicate_attribute BenchmarkAddAttribute/with_a_duplicate_attribute-10 29132547 39.47 ns/op 32 B/op 2 allocs/op BenchmarkAddAttribute/with_a_hundred_attributes_to_loop_through BenchmarkAddAttribute/with_a_hundred_attributes_to_loop_through-10 6762793 176.8 ns/op 32 B/op 2 allocs/op ``` Those benchmarks kind of have an N+1 issue, where the method will take longer the more attributes there are. However, since the attribute table is a map, we can't go around with looping through it. I also had to use `FromRaw` and `AsRaw` in there, to properly handle `any` values. This currently doesn't support removing entries. But doing so would also have a non-trivial performance impact, since we'd have to loop through the `AttributeIndices` slice. --------- Co-authored-by: Tim Rühsen <[email protected]> Co-authored-by: Joshua MacDonald <[email protected]>
- Loading branch information
1 parent
e43c36c
commit 72a8471
Showing
3 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: enhancement | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) | ||
component: pdata/pprofile | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Introduce AddAttribute helper method to modify the content of attributable records | ||
|
||
# One or more tracking issues or pull requests related to the change | ||
issues: [12206] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: | ||
|
||
# Optional: The change log or logs in which this entry should be included. | ||
# e.g. '[user]' or '[user, api]' | ||
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [api] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters