4545from opentelemetry .proto .resource .v1 .resource_pb2 import (
4646 Resource as PB2Resource ,
4747)
48- from opentelemetry .sdk ._logs import LogData , LogLimits
48+ from opentelemetry .sdk ._logs import LogLimits
4949from opentelemetry .sdk ._logs import LogRecord as SDKLogRecord
5050from opentelemetry .sdk .resources import Resource as SDKResource
5151from opentelemetry .sdk .util .instrumentation import InstrumentationScope
@@ -88,7 +88,7 @@ def test_dropped_attributes_count(self):
8888 )
8989
9090 @staticmethod
91- def _get_sdk_log_data () -> List [LogData ]:
91+ def _get_sdk_log_data () -> List [SDKLogRecord ]:
9292 ctx_log1 = set_span_in_context (
9393 NonRecordingSpan (
9494 SpanContext (
@@ -99,35 +99,31 @@ def _get_sdk_log_data() -> List[LogData]:
9999 )
100100 )
101101 )
102- log1 = LogData (
103- log_record = SDKLogRecord (
104- timestamp = 1644650195189786880 ,
105- observed_timestamp = 1644650195189786881 ,
106- context = ctx_log1 ,
107- severity_text = "WARN" ,
108- severity_number = SeverityNumber .WARN ,
109- body = "Do not go gentle into that good night. Rage, rage against the dying of the light" ,
110- resource = SDKResource (
111- {"first_resource" : "value" },
112- "resource_schema_url" ,
113- ),
114- attributes = {"a" : 1 , "b" : "c" },
102+ log1 = SDKLogRecord (
103+ timestamp = 1644650195189786880 ,
104+ observed_timestamp = 1644650195189786881 ,
105+ context = ctx_log1 ,
106+ severity_text = "WARN" ,
107+ severity_number = SeverityNumber .WARN ,
108+ body = "Do not go gentle into that good night. Rage, rage against the dying of the light" ,
109+ resource = SDKResource (
110+ {"first_resource" : "value" },
111+ "resource_schema_url" ,
115112 ),
113+ attributes = {"a" : 1 , "b" : "c" },
116114 instrumentation_scope = InstrumentationScope (
117115 "first_name" , "first_version"
118116 ),
119117 )
120118
121- log2 = LogData (
122- log_record = SDKLogRecord (
123- timestamp = 1644650249738562048 ,
124- observed_timestamp = 1644650249738562049 ,
125- severity_text = "WARN" ,
126- severity_number = SeverityNumber .WARN ,
127- body = "Cooper, this is no time for caution!" ,
128- resource = SDKResource ({"second_resource" : "CASE" }),
129- attributes = {},
130- ),
119+ log2 = SDKLogRecord (
120+ timestamp = 1644650249738562048 ,
121+ observed_timestamp = 1644650249738562049 ,
122+ severity_text = "WARN" ,
123+ severity_number = SeverityNumber .WARN ,
124+ body = "Cooper, this is no time for caution!" ,
125+ resource = SDKResource ({"second_resource" : "CASE" }),
126+ attributes = {},
131127 instrumentation_scope = InstrumentationScope (
132128 "second_name" , "second_version"
133129 ),
@@ -143,17 +139,15 @@ def _get_sdk_log_data() -> List[LogData]:
143139 )
144140 )
145141 )
146- log3 = LogData (
147- log_record = SDKLogRecord (
148- timestamp = 1644650427658989056 ,
149- observed_timestamp = 1644650427658989057 ,
150- context = ctx_log3 ,
151- severity_text = "DEBUG" ,
152- severity_number = SeverityNumber .DEBUG ,
153- body = "To our galaxy" ,
154- resource = SDKResource ({"second_resource" : "CASE" }),
155- attributes = {"a" : 1 , "b" : "c" },
156- ),
142+ log3 = SDKLogRecord (
143+ timestamp = 1644650427658989056 ,
144+ observed_timestamp = 1644650427658989057 ,
145+ context = ctx_log3 ,
146+ severity_text = "DEBUG" ,
147+ severity_number = SeverityNumber .DEBUG ,
148+ body = "To our galaxy" ,
149+ resource = SDKResource ({"second_resource" : "CASE" }),
150+ attributes = {"a" : 1 , "b" : "c" },
157151 instrumentation_scope = None ,
158152 )
159153
@@ -167,20 +161,18 @@ def _get_sdk_log_data() -> List[LogData]:
167161 )
168162 )
169163 )
170- log4 = LogData (
171- log_record = SDKLogRecord (
172- timestamp = 1644650584292683008 ,
173- observed_timestamp = 1644650584292683009 ,
174- context = ctx_log4 ,
175- severity_text = "INFO" ,
176- severity_number = SeverityNumber .INFO ,
177- body = "Love is the one thing that transcends time and space" ,
178- resource = SDKResource (
179- {"first_resource" : "value" },
180- "resource_schema_url" ,
181- ),
182- attributes = {"filename" : "model.py" , "func_name" : "run_method" },
164+ log4 = SDKLogRecord (
165+ timestamp = 1644650584292683008 ,
166+ observed_timestamp = 1644650584292683009 ,
167+ context = ctx_log4 ,
168+ severity_text = "INFO" ,
169+ severity_number = SeverityNumber .INFO ,
170+ body = "Love is the one thing that transcends time and space" ,
171+ resource = SDKResource (
172+ {"first_resource" : "value" },
173+ "resource_schema_url" ,
183174 ),
175+ attributes = {"filename" : "model.py" , "func_name" : "run_method" },
184176 instrumentation_scope = InstrumentationScope (
185177 "another_name" , "another_version"
186178 ),
@@ -196,17 +188,15 @@ def _get_sdk_log_data() -> List[LogData]:
196188 )
197189 )
198190 )
199- log5 = LogData (
200- log_record = SDKLogRecord (
201- timestamp = 1644650584292683009 ,
202- observed_timestamp = 1644650584292683010 ,
203- context = ctx_log5 ,
204- severity_text = "INFO" ,
205- severity_number = SeverityNumber .INFO ,
206- body = {"error" : None , "array_with_nones" : [1 , None , 2 ]},
207- resource = SDKResource ({}),
208- attributes = {},
209- ),
191+ log5 = SDKLogRecord (
192+ timestamp = 1644650584292683009 ,
193+ observed_timestamp = 1644650584292683010 ,
194+ context = ctx_log5 ,
195+ severity_text = "INFO" ,
196+ severity_number = SeverityNumber .INFO ,
197+ body = {"error" : None , "array_with_nones" : [1 , None , 2 ]},
198+ resource = SDKResource ({}),
199+ attributes = {},
210200 instrumentation_scope = InstrumentationScope (
211201 "last_name" , "last_version"
212202 ),
@@ -222,20 +212,18 @@ def _get_sdk_log_data() -> List[LogData]:
222212 )
223213 )
224214 )
225- log6 = LogData (
226- log_record = SDKLogRecord (
227- timestamp = 1644650584292683022 ,
228- observed_timestamp = 1644650584292683022 ,
229- context = ctx_log6 ,
230- severity_text = "ERROR" ,
231- severity_number = SeverityNumber .ERROR ,
232- body = "This instrumentation scope has a schema url" ,
233- resource = SDKResource (
234- {"first_resource" : "value" },
235- "resource_schema_url" ,
236- ),
237- attributes = {"filename" : "model.py" , "func_name" : "run_method" },
215+ log6 = SDKLogRecord (
216+ timestamp = 1644650584292683022 ,
217+ observed_timestamp = 1644650584292683022 ,
218+ context = ctx_log6 ,
219+ severity_text = "ERROR" ,
220+ severity_number = SeverityNumber .ERROR ,
221+ body = "This instrumentation scope has a schema url" ,
222+ resource = SDKResource (
223+ {"first_resource" : "value" },
224+ "resource_schema_url" ,
238225 ),
226+ attributes = {"filename" : "model.py" , "func_name" : "run_method" },
239227 instrumentation_scope = InstrumentationScope (
240228 "scope_with_url" ,
241229 "scope_with_url_version" ,
@@ -253,20 +241,18 @@ def _get_sdk_log_data() -> List[LogData]:
253241 )
254242 )
255243 )
256- log7 = LogData (
257- log_record = SDKLogRecord (
258- timestamp = 1644650584292683033 ,
259- observed_timestamp = 1644650584292683033 ,
260- context = ctx_log7 ,
261- severity_text = "FATAL" ,
262- severity_number = SeverityNumber .FATAL ,
263- body = "This instrumentation scope has a schema url and attributes" ,
264- resource = SDKResource (
265- {"first_resource" : "value" },
266- "resource_schema_url" ,
267- ),
268- attributes = {"filename" : "model.py" , "func_name" : "run_method" },
244+ log7 = SDKLogRecord (
245+ timestamp = 1644650584292683033 ,
246+ observed_timestamp = 1644650584292683033 ,
247+ context = ctx_log7 ,
248+ severity_text = "FATAL" ,
249+ severity_number = SeverityNumber .FATAL ,
250+ body = "This instrumentation scope has a schema url and attributes" ,
251+ resource = SDKResource (
252+ {"first_resource" : "value" },
253+ "resource_schema_url" ,
269254 ),
255+ attributes = {"filename" : "model.py" , "func_name" : "run_method" },
270256 instrumentation_scope = InstrumentationScope (
271257 "scope_with_attributes" ,
272258 "scope_with_attributes_version" ,
@@ -285,21 +271,17 @@ def _get_sdk_log_data() -> List[LogData]:
285271 )
286272 )
287273 )
288- log8 = LogData (
289- log_record = SDKLogRecord (
290- timestamp = 1644650584292683044 ,
291- observed_timestamp = 1644650584292683044 ,
292- context = ctx_log8 ,
293- severity_text = "INFO" ,
294- severity_number = SeverityNumber .INFO ,
295- body = "Test export of extended attributes" ,
296- resource = SDKResource ({}),
297- attributes = {
298- "extended" : {
299- "sequence" : [{"inner" : "mapping" , "none" : None }]
300- }
301- },
302- ),
274+ log8 = SDKLogRecord (
275+ timestamp = 1644650584292683044 ,
276+ observed_timestamp = 1644650584292683044 ,
277+ context = ctx_log8 ,
278+ severity_text = "INFO" ,
279+ severity_number = SeverityNumber .INFO ,
280+ body = "Test export of extended attributes" ,
281+ resource = SDKResource ({}),
282+ attributes = {
283+ "extended" : {"sequence" : [{"inner" : "mapping" , "none" : None }]}
284+ },
303285 instrumentation_scope = InstrumentationScope (
304286 "extended_name" , "extended_version"
305287 ),
@@ -601,7 +583,7 @@ def get_test_logs(
601583 return sdk_logs , pb2_service_request
602584
603585 @staticmethod
604- def _get_test_logs_dropped_attributes () -> List [LogData ]:
586+ def _get_test_logs_dropped_attributes () -> List [SDKLogRecord ]:
605587 ctx_log1 = set_span_in_context (
606588 NonRecordingSpan (
607589 SpanContext (
@@ -612,34 +594,30 @@ def _get_test_logs_dropped_attributes() -> List[LogData]:
612594 )
613595 )
614596 )
615- log1 = LogData (
616- log_record = SDKLogRecord (
617- timestamp = 1644650195189786880 ,
618- context = ctx_log1 ,
619- severity_text = "WARN" ,
620- severity_number = SeverityNumber .WARN ,
621- body = "Do not go gentle into that good night. Rage, rage against the dying of the light" ,
622- resource = SDKResource ({"first_resource" : "value" }),
623- attributes = {"a" : 1 , "b" : "c" , "user_id" : "B121092" },
624- limits = LogLimits (max_attributes = 1 ),
625- ),
597+ log1 = SDKLogRecord (
598+ timestamp = 1644650195189786880 ,
599+ context = ctx_log1 ,
600+ severity_text = "WARN" ,
601+ severity_number = SeverityNumber .WARN ,
602+ body = "Do not go gentle into that good night. Rage, rage against the dying of the light" ,
603+ resource = SDKResource ({"first_resource" : "value" }),
604+ attributes = {"a" : 1 , "b" : "c" , "user_id" : "B121092" },
605+ limits = LogLimits (max_attributes = 1 ),
626606 instrumentation_scope = InstrumentationScope (
627607 "first_name" , "first_version"
628608 ),
629609 )
630610 ctx_log2 = set_span_in_context (
631611 NonRecordingSpan (SpanContext (0 , 0 , False ))
632612 )
633- log2 = LogData (
634- log_record = SDKLogRecord (
635- timestamp = 1644650249738562048 ,
636- context = ctx_log2 ,
637- severity_text = "WARN" ,
638- severity_number = SeverityNumber .WARN ,
639- body = "Cooper, this is no time for caution!" ,
640- resource = SDKResource ({"second_resource" : "CASE" }),
641- attributes = {},
642- ),
613+ log2 = SDKLogRecord (
614+ timestamp = 1644650249738562048 ,
615+ context = ctx_log2 ,
616+ severity_text = "WARN" ,
617+ severity_number = SeverityNumber .WARN ,
618+ body = "Cooper, this is no time for caution!" ,
619+ resource = SDKResource ({"second_resource" : "CASE" }),
620+ attributes = {},
643621 instrumentation_scope = InstrumentationScope (
644622 "second_name" , "second_version"
645623 ),
0 commit comments