Skip to content

Commit

Permalink
change exporter to conditional import
Browse files Browse the repository at this point in the history
  • Loading branch information
wangchy27 committed Jul 13, 2023
1 parent 20c67af commit 34049b0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions metaflow/tracing/span_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,14 @@
CONSOLE_TRACE_ENABLED,
)

from opentelemetry.exporter.otlp.proto.http.trace_exporter import (
OTLPSpanExporter,
)
from opentelemetry.exporter.zipkin.proto.http import ZipkinExporter

from opentelemetry.sdk.trace.export import ConsoleSpanExporter


def get_span_exporter():
if OTEL_ENDPOINT:
return set_otel_exporter()

elif ZIPKIN_ENDPOINT:
return set_zipkin_exporter()

elif CONSOLE_TRACE_ENABLED:
return set_console_exporter()
else:
Expand All @@ -27,6 +21,8 @@ def get_span_exporter():


def set_otel_exporter():
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter

from metaflow.metaflow_config import (
SERVICE_AUTH_KEY,
SERVICE_HEADERS,
Expand All @@ -51,12 +47,16 @@ def set_otel_exporter():


def set_zipkin_exporter():
from opentelemetry.exporter.zipkin.proto.http import ZipkinExporter

span_exporter = ZipkinExporter(
endpoint=ZIPKIN_ENDPOINT,
)
return span_exporter


def set_console_exporter():
from opentelemetry.sdk.trace.export import ConsoleSpanExporter

span_exporter = ConsoleSpanExporter()
return span_exporter

0 comments on commit 34049b0

Please sign in to comment.