Skip to content
Open
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
114 changes: 57 additions & 57 deletions aws-opentelemetry-distro/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,63 +26,63 @@ classifiers = [
]

dependencies = [
"opentelemetry-api == 1.37.0",
"opentelemetry-sdk == 1.37.0",
"opentelemetry-exporter-otlp-proto-grpc == 1.37.0",
"opentelemetry-exporter-otlp-proto-http == 1.37.0",
"opentelemetry-propagator-b3 == 1.37.0",
"opentelemetry-propagator-jaeger == 1.37.0",
"opentelemetry-exporter-otlp-proto-common == 1.37.0",
"opentelemetry-sdk-extension-aws == 2.0.2",
"opentelemetry-propagator-aws-xray == 1.0.1",
"opentelemetry-distro == 0.58b0",
"opentelemetry-processor-baggage == 0.58b0",
"opentelemetry-propagator-ot-trace == 0.58b0",
"opentelemetry-instrumentation == 0.58b0",
"opentelemetry-instrumentation-aws-lambda == 0.58b0",
"opentelemetry-instrumentation-aio-pika == 0.58b0",
"opentelemetry-instrumentation-aiohttp-client == 0.58b0",
"opentelemetry-instrumentation-aiokafka == 0.58b0",
"opentelemetry-instrumentation-aiopg == 0.58b0",
"opentelemetry-instrumentation-asgi == 0.58b0",
"opentelemetry-instrumentation-asyncpg == 0.58b0",
"opentelemetry-instrumentation-boto == 0.58b0",
"opentelemetry-instrumentation-boto3sqs == 0.58b0",
"opentelemetry-instrumentation-botocore == 0.58b0",
"opentelemetry-instrumentation-celery == 0.58b0",
"opentelemetry-instrumentation-confluent-kafka == 0.58b0",
"opentelemetry-instrumentation-dbapi == 0.58b0",
"opentelemetry-instrumentation-django == 0.58b0",
"opentelemetry-instrumentation-elasticsearch == 0.58b0",
"opentelemetry-instrumentation-falcon == 0.58b0",
"opentelemetry-instrumentation-fastapi == 0.58b0",
"opentelemetry-instrumentation-flask == 0.58b0",
"opentelemetry-instrumentation-grpc == 0.58b0",
"opentelemetry-instrumentation-httpx == 0.58b0",
"opentelemetry-instrumentation-jinja2 == 0.58b0",
"opentelemetry-instrumentation-kafka-python == 0.58b0",
"opentelemetry-instrumentation-logging == 0.58b0",
"opentelemetry-instrumentation-mysql == 0.58b0",
"opentelemetry-instrumentation-mysqlclient == 0.58b0",
"opentelemetry-instrumentation-pika == 0.58b0",
"opentelemetry-instrumentation-psycopg2 == 0.58b0",
"opentelemetry-instrumentation-pymemcache == 0.58b0",
"opentelemetry-instrumentation-pymongo == 0.58b0",
"opentelemetry-instrumentation-pymysql == 0.58b0",
"opentelemetry-instrumentation-pyramid == 0.58b0",
"opentelemetry-instrumentation-redis == 0.58b0",
"opentelemetry-instrumentation-remoulade == 0.58b0",
"opentelemetry-instrumentation-requests == 0.58b0",
"opentelemetry-instrumentation-sqlalchemy == 0.58b0",
"opentelemetry-instrumentation-sqlite3 == 0.58b0",
"opentelemetry-instrumentation-starlette == 0.58b0",
"opentelemetry-instrumentation-system-metrics == 0.58b0",
"opentelemetry-instrumentation-tornado == 0.58b0",
"opentelemetry-instrumentation-tortoiseorm == 0.58b0",
"opentelemetry-instrumentation-urllib == 0.58b0",
"opentelemetry-instrumentation-urllib3 == 0.58b0",
"opentelemetry-instrumentation-wsgi == 0.58b0",
"opentelemetry-instrumentation-cassandra == 0.58b0",
"opentelemetry-api == 1.39.1",
"opentelemetry-sdk == 1.39.1",
"opentelemetry-exporter-otlp-proto-grpc == 1.39.1",
"opentelemetry-exporter-otlp-proto-http == 1.39.1",
"opentelemetry-propagator-b3 == 1.39.1",
"opentelemetry-propagator-jaeger == 1.39.1",
"opentelemetry-exporter-otlp-proto-common == 1.39.1",
"opentelemetry-sdk-extension-aws == 2.1.0",
"opentelemetry-propagator-aws-xray == 1.0.2",
"opentelemetry-distro == 0.60b1",
"opentelemetry-processor-baggage == 0.60b1",
"opentelemetry-propagator-ot-trace == 0.60b1",
"opentelemetry-instrumentation == 0.60b1",
"opentelemetry-instrumentation-aws-lambda == 0.60b1",
"opentelemetry-instrumentation-aio-pika == 0.60b1",
"opentelemetry-instrumentation-aiohttp-client == 0.60b1",
"opentelemetry-instrumentation-aiokafka == 0.60b1",
"opentelemetry-instrumentation-aiopg == 0.60b1",
"opentelemetry-instrumentation-asgi == 0.60b1",
"opentelemetry-instrumentation-asyncpg == 0.60b1",
"opentelemetry-instrumentation-boto == 0.60b1",
"opentelemetry-instrumentation-boto3sqs == 0.60b1",
"opentelemetry-instrumentation-botocore == 0.60b1",
"opentelemetry-instrumentation-celery == 0.60b1",
"opentelemetry-instrumentation-confluent-kafka == 0.60b1",
"opentelemetry-instrumentation-dbapi == 0.60b1",
"opentelemetry-instrumentation-django == 0.60b1",
"opentelemetry-instrumentation-elasticsearch == 0.60b1",
"opentelemetry-instrumentation-falcon == 0.60b1",
"opentelemetry-instrumentation-fastapi == 0.60b1",
"opentelemetry-instrumentation-flask == 0.60b1",
"opentelemetry-instrumentation-grpc == 0.60b1",
"opentelemetry-instrumentation-httpx == 0.60b1",
"opentelemetry-instrumentation-jinja2 == 0.60b1",
"opentelemetry-instrumentation-kafka-python == 0.60b1",
"opentelemetry-instrumentation-logging == 0.60b1",
"opentelemetry-instrumentation-mysql == 0.60b1",
"opentelemetry-instrumentation-mysqlclient == 0.60b1",
"opentelemetry-instrumentation-pika == 0.60b1",
"opentelemetry-instrumentation-psycopg2 == 0.60b1",
"opentelemetry-instrumentation-pymemcache == 0.60b1",
"opentelemetry-instrumentation-pymongo == 0.60b1",
"opentelemetry-instrumentation-pymysql == 0.60b1",
"opentelemetry-instrumentation-pyramid == 0.60b1",
"opentelemetry-instrumentation-redis == 0.60b1",
"opentelemetry-instrumentation-remoulade == 0.60b1",
"opentelemetry-instrumentation-requests == 0.60b1",
"opentelemetry-instrumentation-sqlalchemy == 0.60b1",
"opentelemetry-instrumentation-sqlite3 == 0.60b1",
"opentelemetry-instrumentation-starlette == 0.60b1",
"opentelemetry-instrumentation-system-metrics == 0.60b1",
"opentelemetry-instrumentation-tornado == 0.60b1",
"opentelemetry-instrumentation-tortoiseorm == 0.60b1",
"opentelemetry-instrumentation-urllib == 0.60b1",
"opentelemetry-instrumentation-urllib3 == 0.60b1",
"opentelemetry-instrumentation-wsgi == 0.60b1",
"opentelemetry-instrumentation-cassandra == 0.60b1",
]

[project.optional-dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT = "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT"
OTEL_EXPORTER_OTLP_LOGS_HEADERS = "OTEL_EXPORTER_OTLP_LOGS_HEADERS"
CODE_CORRELATION_ENABLED_CONFIG = "OTEL_AWS_CODE_CORRELATION_ENABLED"
OTEL_AWS_ENHANCED_CODE_ATTRIBUTES = "OTEL_AWS_ENHANCED_CODE_ATTRIBUTES"

XRAY_SERVICE = "xray"
LOGS_SERIVCE = "logs"
Expand Down Expand Up @@ -473,7 +473,7 @@ def _customize_logs_exporter(log_exporter: LogExporter) -> LogExporter:

def _customize_span_processors(provider: TracerProvider, resource: Resource) -> None:

if get_code_correlation_enabled_status() is True:
if is_enhanced_code_attributes() is True:
# pylint: disable=import-outside-toplevel
from amazon.opentelemetry.distro.code_correlation import CodeAttributesSpanProcessor

Expand Down Expand Up @@ -622,32 +622,21 @@ def _is_application_signals_runtime_enabled():
)


def get_code_correlation_enabled_status() -> Optional[bool]:
def is_enhanced_code_attributes() -> bool:
"""
Get the code correlation enabled status from environment variable.
Get the enhanced code attributes enabled status from environment variable.

Returns:
True if OTEL_AWS_CODE_CORRELATION_ENABLED is set to 'true'
False if OTEL_AWS_CODE_CORRELATION_ENABLED is set to 'false'
None if OTEL_AWS_CODE_CORRELATION_ENABLED is not set (default state)
True if OTEL_AWS_ENHANCED_CODE_ATTRIBUTES is set to 'true'
else False
"""
env_value = os.environ.get(CODE_CORRELATION_ENABLED_CONFIG)

if env_value is None:
return None # Default state - environment variable not set
env_value = os.environ.get(OTEL_AWS_ENHANCED_CODE_ATTRIBUTES, "false")

env_value_lower = env_value.strip().lower()
if env_value_lower == "true":
return True
if env_value_lower == "false":
return False
# Invalid value, treat as default and log warning
_logger.warning(
"Invalid value for %s: %s. Expected 'true' or 'false'. Using default.",
CODE_CORRELATION_ENABLED_CONFIG,
env_value,
)
return None

return False


def _is_lambda_environment():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
from typing import Any, Dict, List, Optional

# Environment variable constants
_ENV_CONFIG = "OTEL_AWS_CODE_CORRELATION_CONFIG"
_ENV_CONFIG = "OTEL_AWS_CODE_ATTRIBUTES_CONFIG"

_logger = logging.getLogger(__name__)


class AwsCodeCorrelationConfig:
class AwsCodeAttributesConfig:
"""
Configuration manager for AWS OpenTelemetry code correlation features.

Expand All @@ -29,10 +29,10 @@ class AwsCodeCorrelationConfig:
and stack trace depth configuration.

Environment Variables:
OTEL_AWS_CODE_CORRELATION_CONFIG: JSON configuration with detailed settings
OTEL_AWS_CODE_ATTRIBUTES_CONFIG: JSON configuration with detailed settings

Example Configuration:
export OTEL_AWS_CODE_CORRELATION_CONFIG='{
export OTEL_AWS_CODE_ATTRIBUTES_CONFIG='{
"include": ["myapp", "mylib"],
"exclude": ["third-party", "vendor"],
"stack_depth": 5
Expand All @@ -55,12 +55,12 @@ def __init__(
self.stack_depth = stack_depth

@classmethod
def from_env(cls) -> "AwsCodeCorrelationConfig":
def from_env(cls) -> "AwsCodeAttributesConfig":
"""
Create configuration instance from environment variables.

Returns:
AwsCodeCorrelationConfig: Configured instance
AwsCodeAttributesConfig: Configured instance
"""
config_data = cls._parse_config_data()
include_value = cls._validate_string_list(config_data, "include")
Expand Down Expand Up @@ -168,7 +168,7 @@ def to_json(self, indent: Optional[int] = 2) -> str:
def __repr__(self) -> str:
"""Return string representation of the configuration."""
return (
f"AwsCodeCorrelationConfig("
f"AwsCodeAttributesConfig("
f"include={self.include}, "
f"exclude={self.exclude}, "
f"stack_depth={self.stack_depth})"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
from pathlib import Path
from typing import Any, Callable, Dict, List, NamedTuple, Optional, Set, Union

from ..config import AwsCodeCorrelationConfig
from ..config import AwsCodeAttributesConfig

# Module-level constants
_logger = logging.getLogger(__name__)

# Configuration
_code_attributes_config = AwsCodeCorrelationConfig.from_env()
_code_attributes_config = AwsCodeAttributesConfig.from_env()

# Global caching variables
_sys_path_hash: Optional[int] = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import functools
import logging

from amazon.opentelemetry.distro.aws_opentelemetry_configurator import get_code_correlation_enabled_status
from amazon.opentelemetry.distro.code_correlation.utils import record_code_attributes

logger = logging.getLogger(__name__)
Expand All @@ -32,9 +31,6 @@ def patched_decorate(self, callback):
def _apply_aio_pika_instrumentation_patches():
"""Apply aio-pika patches if code correlation is enabled."""
try:
if get_code_correlation_enabled_status() is not True:
return

# Import CallbackDecorator inside function to allow proper testing
try:
# pylint: disable=import-outside-toplevel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import logging
from typing import Any, Callable, Optional

from amazon.opentelemetry.distro.aws_opentelemetry_configurator import get_code_correlation_enabled_status
from amazon.opentelemetry.distro.code_correlation.utils import add_code_attributes_to_span

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -125,9 +124,6 @@ def _apply_celery_instrumentation_patches():
Apply code correlation patches to the Celery instrumentation.
"""
try:
if get_code_correlation_enabled_status() is not True:
return

if CeleryInstrumentor is None:
logger.warning("Failed to apply Celery patches: CeleryInstrumentor not available")
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

from logging import getLogger

from amazon.opentelemetry.distro.aws_opentelemetry_configurator import get_code_correlation_enabled_status

_logger = getLogger(__name__)


Expand All @@ -17,8 +15,7 @@ def _apply_django_instrumentation_patches() -> None:
to spans by modifying the process_view method of the Django middleware.
Also patches Django's path/re_path functions for URL pattern instrumentation.
"""
if get_code_correlation_enabled_status() is True:
_apply_django_code_attributes_patch()
_apply_django_code_attributes_patch()


def _apply_django_code_attributes_patch() -> None: # pylint: disable=too-many-statements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

from logging import getLogger

from amazon.opentelemetry.distro.aws_opentelemetry_configurator import get_code_correlation_enabled_status

_logger = getLogger(__name__)


Expand All @@ -16,8 +14,7 @@ def _apply_fastapi_instrumentation_patches() -> None:
This patches the FastAPI instrumentation to automatically add code attributes
to spans by decorating view functions with record_code_attributes.
"""
if get_code_correlation_enabled_status() is True:
_apply_fastapi_code_attributes_patch()
_apply_fastapi_code_attributes_patch()


def _apply_fastapi_code_attributes_patch() -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

from logging import getLogger

from amazon.opentelemetry.distro.aws_opentelemetry_configurator import get_code_correlation_enabled_status

_logger = getLogger(__name__)


Expand All @@ -16,8 +14,7 @@ def _apply_flask_instrumentation_patches() -> None:
This patches the Flask instrumentation to automatically add code attributes
to spans by decorating view functions with record_code_attributes.
"""
if get_code_correlation_enabled_status() is True:
_apply_flask_code_attributes_patch()
_apply_flask_code_attributes_patch()


def _apply_flask_code_attributes_patch() -> None: # pylint: disable=too-many-statements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import functools
import logging

from amazon.opentelemetry.distro.aws_opentelemetry_configurator import get_code_correlation_enabled_status
from amazon.opentelemetry.distro.code_correlation.utils import add_code_attributes_to_span

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -43,9 +42,6 @@ def enhanced_consume_hook(span, body, properties):
def _apply_pika_instrumentation_patches():
"""Apply pika patches if code correlation is enabled."""
try:
if get_code_correlation_enabled_status() is not True:
return

# Import pika_utils inside function to allow proper testing
try:
# pylint: disable=import-outside-toplevel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import Collection

from amazon.opentelemetry.distro._utils import is_agent_observability_enabled
from amazon.opentelemetry.distro.aws_opentelemetry_configurator import get_code_correlation_enabled_status

_logger: Logger = getLogger(__name__)

Expand All @@ -16,8 +15,7 @@ def _apply_starlette_instrumentation_patches() -> None:
This applies both version compatibility patches and code attributes support.
"""
_apply_starlette_version_patches()
if get_code_correlation_enabled_status() is True:
_apply_starlette_code_attributes_patch()
_apply_starlette_code_attributes_patch()


# Upstream fix available in OpenTelemetry 1.34.0/0.55b0 (2025-06-04)
Expand Down
Loading