File tree Expand file tree Collapse file tree
opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222import threading
2323import traceback
2424import warnings
25- from dataclasses import dataclass
25+ from dataclasses import dataclass , field
2626from os import environ
2727from threading import Lock
2828from time import time_ns
@@ -165,6 +165,7 @@ class ReadableLogRecord:
165165 log_record : LogRecord
166166 resource : Resource
167167 instrumentation_scope : InstrumentationScope | None = None
168+ limits : LogLimits | None = None
168169
169170 @property
170171 def dropped_attributes (self ) -> int :
@@ -185,11 +186,9 @@ class ReadWriteLogRecord:
185186 log_record : LogRecord
186187 resource : Resource | None = Resource .create ({})
187188 instrumentation_scope : InstrumentationScope | None = None
188- limits : LogLimits | None = None
189+ limits : LogLimits = field ( default_factory = LogLimits )
189190
190191 def __post_init__ (self ):
191- if self .limits is None :
192- self .limits = LogLimits ()
193192 self .log_record .attributes = BoundedAttributes (
194193 maxlen = self .limits .max_attributes ,
195194 attributes = self .log_record .attributes
@@ -264,13 +263,11 @@ def _from_api_log_record(
264263 record : LogRecord ,
265264 resource : Resource ,
266265 instrumentation_scope : InstrumentationScope | None = None ,
267- limits : LogLimits | None = None ,
268266 ) -> ReadWriteLogRecord :
269267 return cls (
270268 log_record = record ,
271269 resource = resource ,
272270 instrumentation_scope = instrumentation_scope ,
273- limits = limits ,
274271 )
275272
276273
Original file line number Diff line number Diff line change @@ -128,6 +128,7 @@ def on_emit(self, log_record: ReadWriteLogRecord):
128128 log_record = log_record .log_record ,
129129 resource = log_record .resource ,
130130 instrumentation_scope = log_record .instrumentation_scope ,
131+ limits = log_record .limits ,
131132 )
132133 self ._exporter .export ((readable_log_record ,))
133134 except Exception : # pylint: disable=broad-exception-caught
@@ -202,6 +203,7 @@ def on_emit(self, log_record: ReadWriteLogRecord) -> None:
202203 log_record = log_record .log_record ,
203204 resource = log_record .resource ,
204205 instrumentation_scope = log_record .instrumentation_scope ,
206+ limits = log_record .limits ,
205207 )
206208 return self ._batch_processor .emit (readable_log_record )
207209
You can’t perform that action at this time.
0 commit comments