1616from sap_cloud_sdk .core .telemetry import Module , Operation
1717from sap_cloud_sdk .core .telemetry .config import (
1818 create_resource_attributes_from_env ,
19- _get_app_name ,
19+ _get_app_name , ENV_OTLP_ENDPOINT , ENV_TRACES_EXPORTER , ENV_OTLP_PROTOCOL ,
2020)
2121from sap_cloud_sdk .core .telemetry .genai_attribute_transformer import (
2222 GenAIAttributeTransformer ,
@@ -34,8 +34,8 @@ def auto_instrument():
3434 Traces are exported to the OTEL collector endpoint configured in environment with
3535 OTEL_EXPORTER_OTLP_ENDPOINT, or printed to console when OTEL_TRACES_EXPORTER=console.
3636 """
37- otel_endpoint = os .getenv ("OTEL_EXPORTER_OTLP_ENDPOINT" , "" )
38- console_traces = os .getenv ("OTEL_TRACES_EXPORTER" , "" ).lower () == "console"
37+ otel_endpoint = os .getenv (ENV_OTLP_ENDPOINT , "" )
38+ console_traces = os .getenv (ENV_TRACES_EXPORTER , "" ).lower () == "console"
3939
4040 if not otel_endpoint and not console_traces :
4141 logger .warning (
@@ -60,12 +60,12 @@ def auto_instrument():
6060
6161
6262def _create_exporter () -> SpanExporter :
63- if os .getenv ("OTEL_TRACES_EXPORTER" , "" ).lower () == "console" :
63+ if os .getenv (ENV_TRACES_EXPORTER , "" ).lower () == "console" :
6464 logger .info ("Initializing auto instrumentation with console exporter" )
6565 return ConsoleSpanExporter ()
6666
67- endpoint = os .getenv ("OTEL_EXPORTER_OTLP_ENDPOINT" , "" )
68- protocol = os .getenv ("OTEL_EXPORTER_OTLP_PROTOCOL" , "grpc" ).lower ()
67+ endpoint = os .getenv (ENV_OTLP_ENDPOINT , "" )
68+ protocol = os .getenv (ENV_OTLP_PROTOCOL , "grpc" ).lower ()
6969 exporters = {"grpc" : GRPCSpanExporter , "http/protobuf" : HTTPSpanExporter }
7070 if protocol not in exporters :
7171 raise ValueError (
0 commit comments