Commit 749f997
Introduce pprofile.PutAttribute helper (#12798)
#### 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
---------
Co-authored-by: Damien Mathieu <[email protected]>1 parent d1a4411 commit 749f997
File tree
3 files changed
+209
-28
lines changed- .chloggen
- pdata/pprofile
3 files changed
+209
-28
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
36 | | - | |
| 34 | + | |
37 | 35 | | |
38 | 36 | | |
39 | 37 | | |
| |||
66 | 64 | | |
67 | 65 | | |
68 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
16 | 46 | | |
17 | 47 | | |
18 | 48 | | |
| |||
44 | 74 | | |
45 | 75 | | |
46 | 76 | | |
47 | | - | |
| 77 | + | |
48 | 78 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
58 | 102 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 103 | + | |
65 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
66 | 108 | | |
67 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
68 | 123 | | |
69 | | - | |
70 | | - | |
71 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
72 | 140 | | |
73 | | - | |
74 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
75 | 156 | | |
76 | 157 | | |
77 | 158 | | |
| |||
94 | 175 | | |
95 | 176 | | |
96 | 177 | | |
97 | | - | |
| 178 | + | |
98 | 179 | | |
99 | 180 | | |
100 | 181 | | |
| |||
124 | 205 | | |
125 | 206 | | |
126 | 207 | | |
127 | | - | |
| 208 | + | |
128 | 209 | | |
129 | 210 | | |
130 | 211 | | |
| |||
157 | 238 | | |
158 | 239 | | |
159 | 240 | | |
160 | | - | |
| 241 | + | |
161 | 242 | | |
162 | 243 | | |
163 | 244 | | |
| |||
0 commit comments