Skip to content

Commit 1347b0d

Browse files
committed
remove changes not from this issue
1 parent ebe92be commit 1347b0d

File tree

3 files changed

+32
-31
lines changed

3 files changed

+32
-31
lines changed

instrumentation/opentelemetry-instrumentation-aiokafka/src/opentelemetry/instrumentation/aiokafka/utils.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import asyncio
4+
import json
45
from logging import getLogger
56
from typing import (
67
TYPE_CHECKING,
@@ -212,7 +213,7 @@ def _enrich_base_span(
212213
messaging_attributes.MESSAGING_SYSTEM,
213214
messaging_attributes.MessagingSystemValues.KAFKA.value,
214215
)
215-
span.set_attribute(server_attributes.SERVER_ADDRESS, bootstrap_servers)
216+
span.set_attribute(server_attributes.SERVER_ADDRESS, json.dumps(bootstrap_servers))
216217
span.set_attribute(messaging_attributes.MESSAGING_CLIENT_ID, client_id)
217218
span.set_attribute(messaging_attributes.MESSAGING_DESTINATION_NAME, topic)
218219

@@ -253,7 +254,7 @@ def _enrich_send_span(
253254
span.set_attribute(messaging_attributes.MESSAGING_OPERATION_NAME, "send")
254255
span.set_attribute(
255256
messaging_attributes.MESSAGING_OPERATION_TYPE,
256-
messaging_attributes.MessagingOperationTypeValues.SEND.value,
257+
messaging_attributes.MessagingOperationTypeValues.PUBLISH.value,
257258
)
258259

259260

@@ -321,7 +322,7 @@ def _enrich_getmany_poll_span(
321322
messaging_attributes.MESSAGING_SYSTEM,
322323
messaging_attributes.MessagingSystemValues.KAFKA.value,
323324
)
324-
span.set_attribute(server_attributes.SERVER_ADDRESS, bootstrap_servers)
325+
span.set_attribute(server_attributes.SERVER_ADDRESS, json.dumps(bootstrap_servers))
325326
span.set_attribute(messaging_attributes.MESSAGING_CLIENT_ID, client_id)
326327

327328
if consumer_group is not None:
@@ -333,7 +334,7 @@ def _enrich_getmany_poll_span(
333334
messaging_attributes.MESSAGING_BATCH_MESSAGE_COUNT, message_count
334335
)
335336

336-
span.set_attribute(messaging_attributes.MESSAGING_OPERATION_NAME, "poll")
337+
span.set_attribute(messaging_attributes.MESSAGING_OPERATION_NAME, "receive")
337338
span.set_attribute(
338339
messaging_attributes.MESSAGING_OPERATION_TYPE,
339340
messaging_attributes.MessagingOperationTypeValues.RECEIVE.value,
@@ -371,7 +372,7 @@ def _enrich_getmany_topic_span(
371372
messaging_attributes.MESSAGING_BATCH_MESSAGE_COUNT, message_count
372373
)
373374

374-
span.set_attribute(messaging_attributes.MESSAGING_OPERATION_NAME, "poll")
375+
span.set_attribute(messaging_attributes.MESSAGING_OPERATION_NAME, "receive")
375376
span.set_attribute(
376377
messaging_attributes.MESSAGING_OPERATION_TYPE,
377378
messaging_attributes.MessagingOperationTypeValues.RECEIVE.value,
@@ -444,7 +445,7 @@ async def _create_consumer_span(
444445
with tracer.start_as_current_span(
445446
span_name,
446447
context=extracted_context,
447-
kind=trace.SpanKind.CLIENT,
448+
kind=trace.SpanKind.CONSUMER,
448449
) as span:
449450
new_context = trace.set_span_in_context(span, extracted_context)
450451
token = context.attach(new_context)
@@ -530,11 +531,11 @@ async def _traced_getmany(
530531
consumer_group = _extract_consumer_group(instance)
531532

532533
span_name = _get_span_name(
533-
"poll",
534+
"receive",
534535
", ".join(sorted({topic.topic for topic in records.keys()})),
535536
)
536537
with tracer.start_as_current_span(
537-
span_name, kind=trace.SpanKind.CLIENT
538+
span_name, kind=trace.SpanKind.CONSUMER
538539
) as poll_span:
539540
_enrich_getmany_poll_span(
540541
poll_span,
@@ -545,9 +546,9 @@ async def _traced_getmany(
545546
)
546547

547548
for topic, topic_records in records.items():
548-
span_name = _get_span_name("poll", topic.topic)
549+
span_name = _get_span_name("receive", topic.topic)
549550
with tracer.start_as_current_span(
550-
span_name, kind=trace.SpanKind.CLIENT
551+
span_name, kind=trace.SpanKind.CONSUMER
551552
) as topic_span:
552553
_enrich_getmany_topic_span(
553554
topic_span,

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

+20-20
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ async def test_getone(self) -> None:
158158
expected_spans = [
159159
{
160160
"name": "topic_1 receive",
161-
"kind": SpanKind.CLIENT,
161+
"kind": SpanKind.CONSUMER,
162162
"attributes": {
163163
messaging_attributes.MESSAGING_SYSTEM: messaging_attributes.MessagingSystemValues.KAFKA.value,
164-
server_attributes.SERVER_ADDRESS: "localhost",
164+
server_attributes.SERVER_ADDRESS: '"localhost"',
165165
messaging_attributes.MESSAGING_CLIENT_ID: client_id,
166166
messaging_attributes.MESSAGING_DESTINATION_NAME: "topic_1",
167167
messaging_attributes.MESSAGING_DESTINATION_PARTITION_ID: "1",
@@ -175,10 +175,10 @@ async def test_getone(self) -> None:
175175
},
176176
{
177177
"name": "topic_2 receive",
178-
"kind": SpanKind.CLIENT,
178+
"kind": SpanKind.CONSUMER,
179179
"attributes": {
180180
messaging_attributes.MESSAGING_SYSTEM: messaging_attributes.MessagingSystemValues.KAFKA.value,
181-
server_attributes.SERVER_ADDRESS: "localhost",
181+
server_attributes.SERVER_ADDRESS: '"localhost"',
182182
messaging_attributes.MESSAGING_CLIENT_ID: client_id,
183183
messaging_attributes.MESSAGING_DESTINATION_NAME: "topic_2",
184184
messaging_attributes.MESSAGING_DESTINATION_PARTITION_ID: "2",
@@ -293,10 +293,10 @@ async def test_getmany(self) -> None:
293293
expected_spans = [
294294
{
295295
"name": "topic_1 receive",
296-
"kind": SpanKind.CLIENT,
296+
"kind": SpanKind.CONSUMER,
297297
"attributes": {
298298
messaging_attributes.MESSAGING_SYSTEM: messaging_attributes.MessagingSystemValues.KAFKA.value,
299-
server_attributes.SERVER_ADDRESS: "localhost",
299+
server_attributes.SERVER_ADDRESS: '"localhost"',
300300
messaging_attributes.MESSAGING_CLIENT_ID: client_id,
301301
messaging_attributes.MESSAGING_DESTINATION_NAME: "topic_1",
302302
messaging_attributes.MESSAGING_DESTINATION_PARTITION_ID: "1",
@@ -309,26 +309,26 @@ async def test_getmany(self) -> None:
309309
},
310310
},
311311
{
312-
"name": "topic_1 poll",
313-
"kind": SpanKind.CLIENT,
312+
"name": "topic_1 receive",
313+
"kind": SpanKind.CONSUMER,
314314
"attributes": {
315315
messaging_attributes.MESSAGING_SYSTEM: messaging_attributes.MessagingSystemValues.KAFKA.value,
316-
server_attributes.SERVER_ADDRESS: "localhost",
316+
server_attributes.SERVER_ADDRESS: '"localhost"',
317317
messaging_attributes.MESSAGING_CLIENT_ID: client_id,
318318
messaging_attributes.MESSAGING_DESTINATION_NAME: "topic_1",
319319
messaging_attributes.MESSAGING_DESTINATION_PARTITION_ID: "1",
320320
messaging_attributes.MESSAGING_CONSUMER_GROUP_NAME: group_id,
321-
messaging_attributes.MESSAGING_OPERATION_NAME: "poll",
321+
messaging_attributes.MESSAGING_OPERATION_NAME: "receive",
322322
messaging_attributes.MESSAGING_OPERATION_TYPE: messaging_attributes.MessagingOperationTypeValues.RECEIVE.value,
323323
messaging_attributes.MESSAGING_BATCH_MESSAGE_COUNT: 1,
324324
},
325325
},
326326
{
327327
"name": "topic_2 receive",
328-
"kind": SpanKind.CLIENT,
328+
"kind": SpanKind.CONSUMER,
329329
"attributes": {
330330
messaging_attributes.MESSAGING_SYSTEM: messaging_attributes.MessagingSystemValues.KAFKA.value,
331-
server_attributes.SERVER_ADDRESS: "localhost",
331+
server_attributes.SERVER_ADDRESS: '"localhost"',
332332
messaging_attributes.MESSAGING_CLIENT_ID: client_id,
333333
messaging_attributes.MESSAGING_DESTINATION_NAME: "topic_2",
334334
messaging_attributes.MESSAGING_DESTINATION_PARTITION_ID: "2",
@@ -341,29 +341,29 @@ async def test_getmany(self) -> None:
341341
},
342342
},
343343
{
344-
"name": "topic_2 poll",
345-
"kind": SpanKind.CLIENT,
344+
"name": "topic_2 receive",
345+
"kind": SpanKind.CONSUMER,
346346
"attributes": {
347347
messaging_attributes.MESSAGING_SYSTEM: messaging_attributes.MessagingSystemValues.KAFKA.value,
348-
server_attributes.SERVER_ADDRESS: "localhost",
348+
server_attributes.SERVER_ADDRESS: '"localhost"',
349349
messaging_attributes.MESSAGING_CLIENT_ID: client_id,
350350
messaging_attributes.MESSAGING_DESTINATION_NAME: "topic_2",
351351
messaging_attributes.MESSAGING_DESTINATION_PARTITION_ID: "2",
352352
messaging_attributes.MESSAGING_CONSUMER_GROUP_NAME: group_id,
353-
messaging_attributes.MESSAGING_OPERATION_NAME: "poll",
353+
messaging_attributes.MESSAGING_OPERATION_NAME: "receive",
354354
messaging_attributes.MESSAGING_OPERATION_TYPE: messaging_attributes.MessagingOperationTypeValues.RECEIVE.value,
355355
messaging_attributes.MESSAGING_BATCH_MESSAGE_COUNT: 1,
356356
},
357357
},
358358
{
359-
"name": "topic_1, topic_2 poll",
360-
"kind": SpanKind.CLIENT,
359+
"name": "topic_1, topic_2 receive",
360+
"kind": SpanKind.CONSUMER,
361361
"attributes": {
362362
messaging_attributes.MESSAGING_SYSTEM: messaging_attributes.MessagingSystemValues.KAFKA.value,
363-
server_attributes.SERVER_ADDRESS: "localhost",
363+
server_attributes.SERVER_ADDRESS: '"localhost"',
364364
messaging_attributes.MESSAGING_CLIENT_ID: client_id,
365365
messaging_attributes.MESSAGING_CONSUMER_GROUP_NAME: group_id,
366-
messaging_attributes.MESSAGING_OPERATION_NAME: "poll",
366+
messaging_attributes.MESSAGING_OPERATION_NAME: "receive",
367367
messaging_attributes.MESSAGING_OPERATION_TYPE: messaging_attributes.MessagingOperationTypeValues.RECEIVE.value,
368368
messaging_attributes.MESSAGING_BATCH_MESSAGE_COUNT: 2,
369369
},

instrumentation/opentelemetry-instrumentation-aiokafka/tests/test_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ async def test_create_consumer_span(
347347
tracer.start_as_current_span.assert_called_once_with(
348348
expected_span_name,
349349
context=extracted_context,
350-
kind=SpanKind.CLIENT,
350+
kind=SpanKind.CONSUMER,
351351
)
352352
span = tracer.start_as_current_span.return_value.__enter__()
353353
set_span_in_context.assert_called_once_with(span, extracted_context)

0 commit comments

Comments
 (0)