Commit 0df8771
authored
Only log unknown attributes if debug is enabled (#184)
Using
[`timeit.Timer.repeat`](https://docs.python.org/3/library/timeit.html),
I found that `_logger.log` could add a lot of slowness, even if it does
not log. It seems to caused by the fact that calling `log` checks if
`isInstance`, and that slows things down. Adding this logic feels
redundant, but the data suggests it is a good idea.
Testing done (10000 iterations, 10 repeats):
* Always call _log_unknown_attribute
* Average: '1.2189'
* Repeat results: ['1.2502', '1.2157', '1.2180', '1.2184', '1.2127',
'1.2176', '1.2141', '1.2187', '1.2104', '1.2136'])
* Wrap _log_unknown_attribute with if _logger.isEnabledFor(DEBUG):
* Average: '0.3957'
* Repeat results: ['0.4270', '0.3732', '0.4228', '0.3735', '0.3726',
'0.3919', '0.3820', '0.3768', '0.4235', '0.4140'])
Suggests 4x perf hit, in worse case scenario
By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.1 parent 26e62a6 commit 0df8771
File tree
1 file changed
+2
-1
lines changed- aws-opentelemetry-distro/src/amazon/opentelemetry/distro
1 file changed
+2
-1
lines changedLines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
376 | | - | |
| 376 | + | |
| 377 | + | |
0 commit comments