Skip to content

Commit cc86d47

Browse files
committed
Improve kafka-python instrumentation example
1 parent 164259e commit cc86d47

File tree

1 file changed

+5
-1
lines changed
  • instrumentation/opentelemetry-instrumentation-kafka-python/src/opentelemetry/instrumentation/kafka

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,14 @@
3030
producer = KafkaProducer(bootstrap_servers=['localhost:9092'])
3131
producer.send('my-topic', b'raw_bytes')
3232
33+
def process_msg(message):
34+
print(message)
35+
3336
# report a span of type consumer with the default settings
3437
consumer = KafkaConsumer('my-topic', group_id='my-group', bootstrap_servers=['localhost:9092'])
3538
for message in consumer:
36-
# process message
39+
# process message
40+
process_msg(message)
3741
3842
The _instrument() method accepts the following keyword args:
3943
tracer_provider (TracerProvider) - an optional tracer provider

0 commit comments

Comments
 (0)