3939from opentelemetry .proto .resource .v1 .resource_pb2 import (
4040 Resource as PB2Resource ,
4141)
42- from opentelemetry .sdk ._logs import LogData , LogLimits
42+ from opentelemetry .sdk ._logs import LogLimits
4343from opentelemetry .sdk ._logs import LogRecord as SDKLogRecord
4444from opentelemetry .sdk .resources import Resource as SDKResource
4545from opentelemetry .sdk .util .instrumentation import InstrumentationScope
@@ -54,7 +54,7 @@ def test_encode(self):
5454 def test_encode_no_body (self ):
5555 sdk_logs , expected_encoding = self .get_test_logs ()
5656 for log in sdk_logs :
57- log .log_record . body = None
57+ log .body = None
5858
5959 for resource_log in expected_encoding .resource_logs :
6060 for scope_log in resource_log .scope_logs :
@@ -66,7 +66,7 @@ def test_encode_no_body(self):
6666 def test_dropped_attributes_count (self ):
6767 sdk_logs = self ._get_test_logs_dropped_attributes ()
6868 encoded_logs = encode_logs (sdk_logs )
69- self .assertTrue (hasattr (sdk_logs [0 ]. log_record , "dropped_attributes" ))
69+ self .assertTrue (hasattr (sdk_logs [0 ], "dropped_attributes" ))
7070 self .assertEqual (
7171 # pylint:disable=no-member
7272 encoded_logs .resource_logs [0 ]
@@ -77,9 +77,8 @@ def test_dropped_attributes_count(self):
7777 )
7878
7979 @staticmethod
80- def _get_sdk_log_data () -> List [LogData ]:
81- log1 = LogData (
82- log_record = SDKLogRecord (
80+ def _get_sdk_log_data () -> List [SDKLogRecord ]:
81+ log1 = SDKLogRecord (
8382 timestamp = 1644650195189786880 ,
8483 observed_timestamp = 1644650195189786881 ,
8584 trace_id = 89564621134313219400156819398935297684 ,
@@ -93,14 +92,12 @@ def _get_sdk_log_data() -> List[LogData]:
9392 "resource_schema_url" ,
9493 ),
9594 attributes = {"a" : 1 , "b" : "c" },
96- ),
97- instrumentation_scope = InstrumentationScope (
98- "first_name" , "first_version"
99- ),
95+ instrumentation_scope = InstrumentationScope (
96+ "first_name" , "first_version"
97+ ),
10098 )
10199
102- log2 = LogData (
103- log_record = SDKLogRecord (
100+ log2 = SDKLogRecord (
104101 timestamp = 1644650249738562048 ,
105102 observed_timestamp = 1644650249738562049 ,
106103 trace_id = 0 ,
@@ -111,14 +108,12 @@ def _get_sdk_log_data() -> List[LogData]:
111108 body = "Cooper, this is no time for caution!" ,
112109 resource = SDKResource ({"second_resource" : "CASE" }),
113110 attributes = {},
114- ),
115- instrumentation_scope = InstrumentationScope (
116- "second_name" , "second_version"
117- ),
111+ instrumentation_scope = InstrumentationScope (
112+ "second_name" , "second_version"
113+ ),
118114 )
119115
120- log3 = LogData (
121- log_record = SDKLogRecord (
116+ log3 = SDKLogRecord (
122117 timestamp = 1644650427658989056 ,
123118 observed_timestamp = 1644650427658989057 ,
124119 trace_id = 271615924622795969659406376515024083555 ,
@@ -129,12 +124,10 @@ def _get_sdk_log_data() -> List[LogData]:
129124 body = "To our galaxy" ,
130125 resource = SDKResource ({"second_resource" : "CASE" }),
131126 attributes = {"a" : 1 , "b" : "c" },
132- ),
133- instrumentation_scope = None ,
134- )
127+ instrumentation_scope = None ,
128+ )
135129
136- log4 = LogData (
137- log_record = SDKLogRecord (
130+ log4 = SDKLogRecord (
138131 timestamp = 1644650584292683008 ,
139132 observed_timestamp = 1644650584292683009 ,
140133 trace_id = 212592107417388365804938480559624925555 ,
@@ -148,10 +141,9 @@ def _get_sdk_log_data() -> List[LogData]:
148141 "resource_schema_url" ,
149142 ),
150143 attributes = {"filename" : "model.py" , "func_name" : "run_method" },
151- ),
152- instrumentation_scope = InstrumentationScope (
153- "another_name" , "another_version"
154- ),
144+ instrumentation_scope = InstrumentationScope (
145+ "another_name" , "another_version"
146+ ),
155147 )
156148
157149 return [log1 , log2 , log3 , log4 ]
@@ -293,9 +285,8 @@ def get_test_logs(
293285 return sdk_logs , pb2_service_request
294286
295287 @staticmethod
296- def _get_test_logs_dropped_attributes () -> List [LogData ]:
297- log1 = LogData (
298- log_record = SDKLogRecord (
288+ def _get_test_logs_dropped_attributes () -> List [SDKLogRecord ]:
289+ log1 = SDKLogRecord (
299290 timestamp = 1644650195189786880 ,
300291 trace_id = 89564621134313219400156819398935297684 ,
301292 span_id = 1312458408527513268 ,
@@ -306,14 +297,12 @@ def _get_test_logs_dropped_attributes() -> List[LogData]:
306297 resource = SDKResource ({"first_resource" : "value" }),
307298 attributes = {"a" : 1 , "b" : "c" , "user_id" : "B121092" },
308299 limits = LogLimits (max_attributes = 1 ),
309- ),
310- instrumentation_scope = InstrumentationScope (
311- "first_name" , "first_version"
312- ),
313- )
300+ instrumentation_scope = InstrumentationScope (
301+ "first_name" , "first_version"
302+ ),
303+ )
314304
315- log2 = LogData (
316- log_record = SDKLogRecord (
305+ log2 = SDKLogRecord (
317306 timestamp = 1644650249738562048 ,
318307 trace_id = 0 ,
319308 span_id = 0 ,
@@ -323,10 +312,9 @@ def _get_test_logs_dropped_attributes() -> List[LogData]:
323312 body = "Cooper, this is no time for caution!" ,
324313 resource = SDKResource ({"second_resource" : "CASE" }),
325314 attributes = {},
326- ),
327- instrumentation_scope = InstrumentationScope (
328- "second_name" , "second_version"
329- ),
330- )
315+ instrumentation_scope = InstrumentationScope (
316+ "second_name" , "second_version"
317+ ),
318+ )
331319
332320 return [log1 , log2 ]
0 commit comments