Skip to content

Commit 5f75b27

Browse files
committed
fix: remove json.dumps from SERVER_ADDRESS attribute
1 parent 774d741 commit 5f75b27

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import asyncio
4-
import json
54
from logging import getLogger
65
from typing import (
76
TYPE_CHECKING,
@@ -213,9 +212,7 @@ def _enrich_base_span(
213212
messaging_attributes.MESSAGING_SYSTEM,
214213
messaging_attributes.MessagingSystemValues.KAFKA.value,
215214
)
216-
span.set_attribute(
217-
server_attributes.SERVER_ADDRESS, json.dumps(bootstrap_servers)
218-
)
215+
span.set_attribute(server_attributes.SERVER_ADDRESS, bootstrap_servers)
219216
span.set_attribute(messaging_attributes.MESSAGING_CLIENT_ID, client_id)
220217
span.set_attribute(messaging_attributes.MESSAGING_DESTINATION_NAME, topic)
221218

@@ -324,9 +321,7 @@ def _enrich_getmany_poll_span(
324321
messaging_attributes.MESSAGING_SYSTEM,
325322
messaging_attributes.MessagingSystemValues.KAFKA.value,
326323
)
327-
span.set_attribute(
328-
server_attributes.SERVER_ADDRESS, json.dumps(bootstrap_servers)
329-
)
324+
span.set_attribute(server_attributes.SERVER_ADDRESS, bootstrap_servers)
330325
span.set_attribute(messaging_attributes.MESSAGING_CLIENT_ID, client_id)
331326

332327
if consumer_group is not None:

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ async def test_getone(self) -> None:
161161
"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",
@@ -178,7 +178,7 @@ async def test_getone(self) -> None:
178178
"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",
@@ -296,7 +296,7 @@ async def test_getmany(self) -> None:
296296
"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",
@@ -313,7 +313,7 @@ async def test_getmany(self) -> None:
313313
"kind": SpanKind.CLIENT,
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",
@@ -328,7 +328,7 @@ async def test_getmany(self) -> None:
328328
"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",
@@ -345,7 +345,7 @@ async def test_getmany(self) -> None:
345345
"kind": SpanKind.CLIENT,
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",
@@ -360,7 +360,7 @@ async def test_getmany(self) -> None:
360360
"kind": SpanKind.CLIENT,
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,
366366
messaging_attributes.MESSAGING_OPERATION_NAME: "poll",

0 commit comments

Comments
 (0)