diff --git a/faststream/opentelemetry/consts.py b/faststream/opentelemetry/consts.py index 33a22644ed..2d6bd31478 100644 --- a/faststream/opentelemetry/consts.py +++ b/faststream/opentelemetry/consts.py @@ -1,3 +1,6 @@ +from faststream.__about__ import __version__ + + class MessageAction: CREATE = "create" PUBLISH = "publish" @@ -9,3 +12,5 @@ class MessageAction: ERROR_TYPE = "error.type" MESSAGING_DESTINATION_PUBLISH_NAME = "messaging.destination_publish.name" WITH_BATCH = "with_batch" +INSTRUMENTING_MODULE_NAME = "opentelemetry.instrumentation.faststream" +INSTRUMENTING_LIBRARY_VERSION = __version__ diff --git a/faststream/opentelemetry/middleware.py b/faststream/opentelemetry/middleware.py index e40ac577d3..94b110e724 100644 --- a/faststream/opentelemetry/middleware.py +++ b/faststream/opentelemetry/middleware.py @@ -15,6 +15,8 @@ from faststream.opentelemetry.baggage import Baggage from faststream.opentelemetry.consts import ( ERROR_TYPE, + INSTRUMENTING_LIBRARY_VERSION, + INSTRUMENTING_MODULE_NAME, MESSAGING_DESTINATION_PUBLISH_NAME, OTEL_SCHEMA, WITH_BATCH, @@ -330,7 +332,8 @@ def _get_meter( def _get_tracer(tracer_provider: Optional["TracerProvider"] = None) -> "Tracer": return trace.get_tracer( - __name__, + instrumenting_module_name=INSTRUMENTING_MODULE_NAME, + instrumenting_library_version=INSTRUMENTING_LIBRARY_VERSION, tracer_provider=tracer_provider, schema_url=OTEL_SCHEMA, )