File tree 2 files changed +14
-11
lines changed
src/opentelemetry/sdk/_logs/_internal
2 files changed +14
-11
lines changed Original file line number Diff line number Diff line change 54
54
55
55
_DEFAULT_OTEL_ATTRIBUTE_COUNT_LIMIT = 128
56
56
_ENV_VALUE_UNSET = ""
57
+ _PRIVATE_RECORD_ATTRS = {
58
+ "args" ,
59
+ "msg" ,
60
+ "message" ,
61
+ "stack_info" ,
62
+ "exc_info" ,
63
+ "exc_text" ,
64
+ }
57
65
58
66
59
67
class LogLimits :
@@ -412,26 +420,22 @@ def __init__(
412
420
self ,
413
421
level = logging .NOTSET ,
414
422
logger_provider = None ,
423
+ exclude_attributes = None ,
415
424
) -> None :
416
425
super ().__init__ (level = level )
417
426
self ._logger_provider = logger_provider or get_logger_provider ()
418
427
self ._logger = get_logger (
419
428
__name__ , logger_provider = self ._logger_provider
420
429
)
430
+ if exclude_attributes is None :
431
+ exclude_attributes = set ()
432
+ self .exclude_attributes = _PRIVATE_RECORD_ATTRS | exclude_attributes
421
433
422
- @staticmethod
423
- def _get_attributes (record : logging .LogRecord ) -> Attributes :
424
- private_record_attrs = (
425
- "args" ,
426
- "msg" ,
427
- "stack_info" ,
428
- "exc_info" ,
429
- "exc_text" ,
430
- )
434
+ def _get_attributes (self , record : logging .LogRecord ) -> Attributes :
431
435
attributes = {
432
436
k : v
433
437
for k , v in vars (record ).items ()
434
- if k not in private_record_attrs
438
+ if k not in self . exclude_attributes
435
439
}
436
440
if record .exc_info :
437
441
exc_type = ""
Original file line number Diff line number Diff line change @@ -216,7 +216,6 @@ def test_original_record_args_are_retained(self):
216
216
self .assertEqual (
217
217
set (log_record .attributes ),
218
218
{
219
- "message" ,
220
219
"created" ,
221
220
"filename" ,
222
221
"funcName" ,
You can’t perform that action at this time.
0 commit comments