mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-08-03 04:10:48 +08:00
Add "instruments-any" feature: unblock multi-target instrumentations while fixing dependency conflict breakage. (#3610)
This commit is contained in:
@ -31,7 +31,8 @@ dependencies = [
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
instruments = [
|
||||
instruments = []
|
||||
instruments-any = [
|
||||
"kafka-python >= 2.0, < 3.0",
|
||||
"kafka-python-ng >= 2.0, < 3.0"
|
||||
]
|
||||
|
@ -91,7 +91,7 @@ from wrapt import wrap_function_wrapper
|
||||
from opentelemetry import trace
|
||||
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
||||
from opentelemetry.instrumentation.kafka.package import (
|
||||
_instruments,
|
||||
_instruments_any,
|
||||
_instruments_kafka_python,
|
||||
_instruments_kafka_python_ng,
|
||||
)
|
||||
@ -123,7 +123,7 @@ class KafkaInstrumentor(BaseInstrumentor):
|
||||
except PackageNotFoundError:
|
||||
pass
|
||||
|
||||
return _instruments
|
||||
return _instruments_any
|
||||
|
||||
def _instrument(self, **kwargs):
|
||||
"""Instruments the kafka module
|
||||
|
@ -16,4 +16,5 @@
|
||||
_instruments_kafka_python = "kafka-python >= 2.0, < 3.0"
|
||||
_instruments_kafka_python_ng = "kafka-python-ng >= 2.0, < 3.0"
|
||||
|
||||
_instruments = (_instruments_kafka_python, _instruments_kafka_python_ng)
|
||||
_instruments = ()
|
||||
_instruments_any = (_instruments_kafka_python, _instruments_kafka_python_ng)
|
||||
|
@ -20,7 +20,6 @@ from wrapt import BoundFunctionWrapper
|
||||
|
||||
from opentelemetry.instrumentation.kafka import KafkaInstrumentor
|
||||
from opentelemetry.instrumentation.kafka.package import (
|
||||
_instruments,
|
||||
_instruments_kafka_python,
|
||||
_instruments_kafka_python_ng,
|
||||
)
|
||||
@ -134,4 +133,7 @@ class TestKafka(TestCase):
|
||||
call("kafka-python"),
|
||||
],
|
||||
)
|
||||
self.assertEqual(package_to_instrument, _instruments)
|
||||
self.assertEqual(
|
||||
package_to_instrument,
|
||||
(_instruments_kafka_python, _instruments_kafka_python_ng),
|
||||
)
|
||||
|
Reference in New Issue
Block a user