mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-29 05:04:05 +08:00

* fix kafka: wait for metadata
Kafka's instance metadata could be unavailable (because it's being filled asynchronously). extract_send_partition() is based on a metadata, so it may return `None` for partition and later cause all type of warning messages (e.g. `Invalid type NoneType for attribute value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types`).
The proposed fix makes sure metadata is pre-populated (based on 4d598055da/kafka/producer/kafka.py (L579)
).
I'm just not sure if we should wrap `_wait_on_metadata` into try\except, maybe just passing Exception to the caller would be a better idea...
* upd: changelog
* fix: changelog
* fix: import KafkaErrors
* fix: tox -e lint errors
* fix: refact and added unit test
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
Co-authored-by: Leighton Chen <lechen@microsoft.com>
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
OpenTelemetry kafka-python integration ====================================== |pypi| .. |pypi| image:: https://badge.fury.io/py/opentelemetry-instrumentation-kafka-python.svg :target: https://pypi.org/project/opentelemetry-instrumentation-kafka-python/ Installation ------------ :: pip install opentelemetry-instrumentation-kafka-python References ---------- * `OpenTelemetry kafka-python Instrumentation <https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/kafka-python/kafka-python.html>`_ * `OpenTelemetry Project <https://opentelemetry.io/>`_ * `OpenTelemetry Python Examples <https://github.com/open-telemetry/opentelemetry-python/tree/main/docs/examples>`_