Skip to content

Commit 76c8faa

Browse files
committed
remove changes not from this issue
1 parent ebe92be commit 76c8faa

File tree

3 files changed

+40
-31
lines changed

3 files changed

+40
-31
lines changed

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

+19-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,9 @@ 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(
217+
server_attributes.SERVER_ADDRESS, json.dumps(bootstrap_servers)
218+
)
216219
span.set_attribute(messaging_attributes.MESSAGING_CLIENT_ID, client_id)
217220
span.set_attribute(messaging_attributes.MESSAGING_DESTINATION_NAME, topic)
218221

@@ -253,7 +256,7 @@ def _enrich_send_span(
253256
span.set_attribute(messaging_attributes.MESSAGING_OPERATION_NAME, "send")
254257
span.set_attribute(
255258
messaging_attributes.MESSAGING_OPERATION_TYPE,
256-
messaging_attributes.MessagingOperationTypeValues.SEND.value,
259+
messaging_attributes.MessagingOperationTypeValues.PUBLISH.value,
257260
)
258261

259262

@@ -321,7 +324,9 @@ def _enrich_getmany_poll_span(
321324
messaging_attributes.MESSAGING_SYSTEM,
322325
messaging_attributes.MessagingSystemValues.KAFKA.value,
323326
)
324-
span.set_attribute(server_attributes.SERVER_ADDRESS, bootstrap_servers)
327+
span.set_attribute(
328+
server_attributes.SERVER_ADDRESS, json.dumps(bootstrap_servers)
329+
)
325330
span.set_attribute(messaging_attributes.MESSAGING_CLIENT_ID, client_id)
326331

327332
if consumer_group is not None:
@@ -333,7 +338,9 @@ def _enrich_getmany_poll_span(
333338
messaging_attributes.MESSAGING_BATCH_MESSAGE_COUNT, message_count
334339
)
335340

336-
span.set_attribute(messaging_attributes.MESSAGING_OPERATION_NAME, "poll")
341+
span.set_attribute(
342+
messaging_attributes.MESSAGING_OPERATION_NAME, "receive"
343+
)
337344
span.set_attribute(
338345
messaging_attributes.MESSAGING_OPERATION_TYPE,
339346
messaging_attributes.MessagingOperationTypeValues.RECEIVE.value,
@@ -371,7 +378,9 @@ def _enrich_getmany_topic_span(
371378
messaging_attributes.MESSAGING_BATCH_MESSAGE_COUNT, message_count
372379
)
373380

374-
span.set_attribute(messaging_attributes.MESSAGING_OPERATION_NAME, "poll")
381+
span.set_attribute(
382+
messaging_attributes.MESSAGING_OPERATION_NAME, "receive"
383+
)
375384
span.set_attribute(
376385
messaging_attributes.MESSAGING_OPERATION_TYPE,
377386
messaging_attributes.MessagingOperationTypeValues.RECEIVE.value,
@@ -444,7 +453,7 @@ async def _create_consumer_span(
444453
with tracer.start_as_current_span(
445454
span_name,
446455
context=extracted_context,
447-
kind=trace.SpanKind.CLIENT,
456+
kind=trace.SpanKind.CONSUMER,
448457
) as span:
449458
new_context = trace.set_span_in_context(span, extracted_context)
450459
token = context.attach(new_context)
@@ -530,11 +539,11 @@ async def _traced_getmany(
530539
consumer_group = _extract_consumer_group(instance)
531540

532541
span_name = _get_span_name(
533-
"poll",
542+
"receive",
534543
", ".join(sorted({topic.topic for topic in records.keys()})),
535544
)
536545
with tracer.start_as_current_span(
537-
span_name, kind=trace.SpanKind.CLIENT
546+
span_name, kind=trace.SpanKind.CONSUMER
538547
) as poll_span:
539548
_enrich_getmany_poll_span(
540549
poll_span,
@@ -545,9 +554,9 @@ async def _traced_getmany(
545554
)
546555

547556
for topic, topic_records in records.items():
548-
span_name = _get_span_name("poll", topic.topic)
557+
span_name = _get_span_name("receive", topic.topic)
549558
with tracer.start_as_current_span(
550-
span_name, kind=trace.SpanKind.CLIENT
559+
span_name, kind=trace.SpanKind.CONSUMER
551560
) as topic_span:
552561
_enrich_getmany_topic_span(
553562
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)