Skip to content

Commit 7a3c685

Browse files
author
Liudmila Molkova
committed
lint
1 parent c4791d2 commit 7a3c685

File tree

9 files changed

+23
-39
lines changed
  • instrumentation
    • opentelemetry-instrumentation-aio-pika
    • opentelemetry-instrumentation-botocore
    • opentelemetry-instrumentation-confluent-kafka/src/opentelemetry/instrumentation/confluent_kafka
    • opentelemetry-instrumentation-kafka-python/src/opentelemetry/instrumentation/kafka
    • opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy
    • opentelemetry-instrumentation-tornado/tests
  • util/opentelemetry-util-http/src/opentelemetry/util/http

9 files changed

+23
-39
lines changed

instrumentation/opentelemetry-instrumentation-aio-pika/src/opentelemetry/instrumentation/aio_pika/span_builder.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ def set_operation(self, operation: MessagingOperationValues):
4646

4747
def set_destination(self, destination: str):
4848
self._destination = destination
49-
if self._kind == SpanKind.PRODUCER:
50-
self._attributes[SpanAttributes.MESSAGING_DESTINATION_NAME] = destination
51-
else:
52-
self._attributes[SpanAttributes.MESSAGING_SOURCE_NAME] = destination
49+
self._attributes[SpanAttributes.MESSAGING_DESTINATION_NAME] = destination
5350

5451
def set_channel(self, channel: AbstractChannel):
5552
connection = channel.connection

instrumentation/opentelemetry-instrumentation-aio-pika/tests/test_callback_decorator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
class TestInstrumentedQueueAioRmq7(TestCase):
4242
EXPECTED_ATTRIBUTES = {
4343
SpanAttributes.MESSAGING_SYSTEM: MESSAGING_SYSTEM,
44-
SpanAttributes.MESSAGING_SOURCE_NAME: EXCHANGE_NAME,
44+
SpanAttributes.MESSAGING_DESTINATION_NAME: EXCHANGE_NAME,
4545
SpanAttributes.NET_PEER_NAME: SERVER_HOST,
4646
SpanAttributes.NET_PEER_PORT: SERVER_PORT,
4747
SpanAttributes.MESSAGING_MESSAGE_ID: MESSAGE_ID,
@@ -81,7 +81,7 @@ def test_decorate_callback(self):
8181
class TestInstrumentedQueueAioRmq8(TestCase):
8282
EXPECTED_ATTRIBUTES = {
8383
SpanAttributes.MESSAGING_SYSTEM: MESSAGING_SYSTEM,
84-
SpanAttributes.MESSAGING_SOURCE_NAME: EXCHANGE_NAME,
84+
SpanAttributes.MESSAGING_DESTINATION_NAME: EXCHANGE_NAME,
8585
SpanAttributes.NET_PEER_NAME: SERVER_HOST,
8686
SpanAttributes.NET_PEER_PORT: SERVER_PORT,
8787
SpanAttributes.MESSAGING_MESSAGE_ID: MESSAGE_ID,

instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/sqs.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,9 @@ def extract_attributes(self, attributes: _AttributeMapT):
3838
attributes[SpanAttributes.NET_PEER_NAME] = queue_host
3939
try:
4040
queue_name = queue_url.split("/")[-1]
41-
if self._call_context.operation == "ReceiveMessage":
42-
attributes[
43-
SpanAttributes.MESSAGING_SOURCE_NAME
44-
] = queue_name
45-
else:
46-
attributes[
47-
SpanAttributes.MESSAGING_DESTINATION_NAME
48-
] = queue_name
41+
attributes[
42+
SpanAttributes.MESSAGING_DESTINATION_NAME
43+
] = queue_name
4944

5045
except IndexError:
5146
_logger.error(

instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_sqs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def test_sqs_messaging_receive_message(self):
113113
span.attributes[SpanAttributes.NET_PEER_NAME], queue_host
114114
)
115115
self.assertEqual(
116-
span.attributes[SpanAttributes.MESSAGING_SOURCE_NAME],
116+
span.attributes[SpanAttributes.MESSAGING_DESTINATION_NAME],
117117
"test_queue_name",
118118
)
119119
self.assertEqual(

instrumentation/opentelemetry-instrumentation-confluent-kafka/src/opentelemetry/instrumentation/confluent_kafka/utils.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,7 @@ def _enrich_span(
9191
return
9292

9393
span.set_attribute(SpanAttributes.MESSAGING_SYSTEM, "kafka")
94-
if operation == MessagingOperationValues.RECEIVE:
95-
span.set_attribute(SpanAttributes.MESSAGING_SOURCE_NAME, topic)
96-
else:
97-
span.set_attribute(SpanAttributes.MESSAGING_DESTINATION_NAME, topic)
94+
span.set_attribute(SpanAttributes.MESSAGING_DESTINATION_NAME, topic)
9895

9996
if partition:
10097
span.set_attribute(

instrumentation/opentelemetry-instrumentation-kafka-python/src/opentelemetry/instrumentation/kafka/utils.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,13 @@ def _enrich_span(
126126
span,
127127
bootstrap_servers: List[str],
128128
topic: str,
129-
partition: int,
130-
consumer: bool,
129+
partition: int
131130
):
132131
if span.is_recording():
133132
span.set_attribute(SpanAttributes.MESSAGING_SYSTEM, "kafka")
134-
if consumer:
135-
span.set_attribute(SpanAttributes.MESSAGING_SOURCE_NAME, topic)
136-
else:
137-
span.set_attribute(
138-
SpanAttributes.MESSAGING_DESTINATION_NAME, topic
139-
)
133+
span.set_attribute(
134+
SpanAttributes.MESSAGING_DESTINATION_NAME, topic
135+
)
140136

141137
span.set_attribute(
142138
SpanAttributes.MESSAGING_KAFKA_DESTINATION_PARTITION, partition

instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,12 @@ def _get_attributes_from_cursor(vendor, cursor, attrs):
300300
is_unix_socket = info.host and info.host.startswith("/")
301301

302302
if is_unix_socket:
303+
attrs[
304+
SpanAttributes.NET_TRANSPORT
305+
] = NetTransportValues.OTHER.value
303306
attrs[
304307
SpanAttributes.NET_SOCK_FAMILY
305-
] = NetTransportValues.UNIX.value
308+
] = NetSockFamilyValues.UNIX.value
306309
if info.port:
307310
# postgresql enforces this pattern on all socket names
308311
attrs[SpanAttributes.NET_PEER_NAME] = os.path.join(
@@ -311,10 +314,7 @@ def _get_attributes_from_cursor(vendor, cursor, attrs):
311314
else:
312315
attrs[
313316
SpanAttributes.NET_TRANSPORT
314-
] = NetTransportValues.OTHER.value
315-
attrs[
316-
SpanAttributes.NET_SOCK_FAMILY
317-
] = NetSockFamilyValues.UNIX.value
317+
] = NetTransportValues.TCP_IP.value
318318

319319
attrs[SpanAttributes.NET_PEER_NAME] = info.host
320320
if info.port:

instrumentation/opentelemetry-instrumentation-tornado/tests/test_instrumentation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ def test_custom_response_headers_not_added_in_internal_span(self):
768768
),
769769
}
770770

771-
for s in spans:
772-
if s.kind == trace.SpanKind.INTERNAL:
771+
for span in spans:
772+
if span.kind == trace.SpanKind.INTERNAL:
773773
for key, _ in not_expected.items():
774-
self.assertNotIn(key, s.attributes)
774+
self.assertNotIn(key, span.attributes)

util/opentelemetry-util-http/src/opentelemetry/util/http/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,11 @@ def parse_http_host(host_port) -> Tuple[str, str]:
211211
def get_http_protocol_version(protocol_and_version) -> str:
212212
if protocol_and_version == "HTTP/1.1":
213213
return "1.1"
214-
elif protocol_and_version == "HTTP/1.0":
214+
if protocol_and_version == "HTTP/1.0":
215215
return "1.0"
216-
elif protocol_and_version == "HTTP/2":
216+
if protocol_and_version == "HTTP/2":
217217
return "2"
218-
else:
219-
return None
218+
return None
220219

221220

222221
def _parse_active_request_count_attrs(req_attrs):

0 commit comments

Comments
 (0)