Commit effa3dd
authored
opentelemetry-sdk: remove copy on span instantiation (#5272)
* opentelemetry-sdk: remove copy on span instantiation
This copy isn't necessary as the init method of the BoundedAttributes (inside the span's init method) already iterates through and copies all the attributes in a new Dict. Ran some benchmarks before and after the change with:
```
pytest opentelemetry-sdk/benchmarks/trace/test_benchmark_trace.py::test_start_span_with_attributes \
--memray --trace-python-allocators --benchmark-disable -v
```
The following table shows the before and after change savings:
| attrs | Before (KiB) | After (KiB) | Saved (KiB) |
|------:|-------------:|------------:|------------:|
| 0 | 7.5 | 7.3 | 0.2 |
| 1 | 8.3 | 8.1 | 0.2 |
| 10 | 11.3 | 11.3 | 0.0 |
| 50 | 15.8 | 14.3 | 1.5 |
| 128 | 28.0 | 24.8 | 3.2 |
Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
* add changelog
Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
---------
Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>1 parent ed622c3 commit effa3dd
3 files changed
Lines changed: 13 additions & 1 deletion
File tree
- .changelog
- opentelemetry-sdk
- benchmarks/trace
- src/opentelemetry/sdk/trace
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
48 | 59 | | |
49 | 60 | | |
50 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1256 | 1256 | | |
1257 | 1257 | | |
1258 | 1258 | | |
1259 | | - | |
| 1259 | + | |
1260 | 1260 | | |
1261 | 1261 | | |
1262 | 1262 | | |
| |||
0 commit comments