Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def _check_otel_version_compatibility():
_OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED as OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED,
)
from opentelemetry.sdk.environment_variables import (
OTEL_EXPORTER_OTLP_ENDPOINT,
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT,
OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION,
OTEL_EXPORTER_OTLP_PROTOCOL,
Expand Down Expand Up @@ -206,16 +207,19 @@ def _configure(self, **kwargs):
os.environ.setdefault("OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT", "true")

region = get_aws_region()
if region:
os.environ.setdefault(
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, f"https://xray.{region}.amazonaws.com/v1/traces"
)
os.environ.setdefault(OTEL_EXPORTER_OTLP_LOGS_ENDPOINT, f"https://logs.{region}.amazonaws.com/v1/logs")
else:
_logger.warning(
"AWS region could not be determined. OTLP endpoints will not be automatically configured. "
"Please set AWS_REGION environment variable or configure OTLP endpoints manually."
)
if not os.environ.get(OTEL_EXPORTER_OTLP_ENDPOINT):
if region:
os.environ.setdefault(
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, f"https://xray.{region}.amazonaws.com/v1/traces"
)
os.environ.setdefault(
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT, f"https://logs.{region}.amazonaws.com/v1/logs"
)
else:
_logger.warning(
"AWS region could not be determined. OTLP endpoints will not be automatically configured. "
"Please set AWS_REGION environment variable or configure OTLP endpoints manually."
)

os.environ.setdefault(
OTEL_PYTHON_DISABLED_INSTRUMENTATIONS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,11 +492,11 @@ def test_agent_observability_respects_custom_disabled_instrumentations(self):
disabled = os.environ.get(OTEL_PYTHON_DISABLED_INSTRUMENTATIONS, "")
self.assertTrue(disabled.startswith("custom_lib"))

def test_base_otlp_endpoint_does_not_prevent_specific_endpoints(self):
def test_base_otlp_endpoint_prevents_specific_endpoints(self):
os.environ[OTEL_EXPORTER_OTLP_ENDPOINT] = "http://my-collector:4318"
self._configure_with_agent_observability()
self.assertIn(OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, os.environ)
self.assertIn(OTEL_EXPORTER_OTLP_LOGS_ENDPOINT, os.environ)
self.assertNotIn(OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, os.environ)
self.assertNotIn(OTEL_EXPORTER_OTLP_LOGS_ENDPOINT, os.environ)

@staticmethod
def _make_ep(name, dist_name=None):
Expand Down
Loading