Make requests instrumentation optional
Even if basic otel dependencies are available, this instrumentor is a separate dependency which may be missing. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
5731cce190
commit
004f357acb
1 changed files with 5 additions and 2 deletions
|
|
@ -46,7 +46,6 @@ class OtelTracing:
|
|||
from opentelemetry.exporter.otlp.proto.http.trace_exporter import (
|
||||
OTLPSpanExporter,
|
||||
)
|
||||
from opentelemetry.instrumentation.requests import RequestsInstrumentor
|
||||
|
||||
otel_endpoint = os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"]
|
||||
provider = TracerProvider(
|
||||
|
|
@ -65,7 +64,11 @@ class OtelTracing:
|
|||
if traceparent:
|
||||
self.set_context(traceparent)
|
||||
|
||||
RequestsInstrumentor().instrument()
|
||||
try:
|
||||
from opentelemetry.instrumentation.requests import RequestsInstrumentor
|
||||
RequestsInstrumentor().instrument()
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
@contextmanager
|
||||
def span(self, name, **attributes):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue