Skip to content
Merged

Unvendor #31744

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
2 changes: 2 additions & 0 deletions sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
([#310](https://github.com/microsoft/ApplicationInsights-Python/pull/310))
- Replace explicit log processor exporter interval env var with OT SDK env var
([#31740](https://github.com/Azure/azure-sdk-for-python/pull/31740))
- Un-vendoring instrumentations
([#31744](https://github.com/Azure/azure-sdk-for-python/pull/31740))

### Breaking Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
from typing import Dict, cast

from opentelemetry._logs import get_logger_provider, set_logger_provider
from opentelemetry.instrumentation.dependencies import (
get_dist_dependency_conflicts,
)
from opentelemetry.instrumentation.instrumentor import (
BaseInstrumentor,
)
from opentelemetry.metrics import set_meter_provider
from opentelemetry.sdk._logs import LoggerProvider, LoggingHandler
from opentelemetry.sdk._logs.export import BatchLogRecordProcessor
Expand All @@ -28,12 +34,6 @@
SAMPLING_RATIO_ARG,
)
from azure.monitor.opentelemetry._types import ConfigurationValue
from azure.monitor.opentelemetry._vendor.v0_39b0.opentelemetry.instrumentation.dependencies import (
get_dependency_conflicts,
)
from azure.monitor.opentelemetry._vendor.v0_39b0.opentelemetry.instrumentation.instrumentor import (
BaseInstrumentor,
)
from azure.monitor.opentelemetry.exporter import ( # pylint: disable=import-error
ApplicationInsightsSampler,
AzureMonitorLogExporter,
Expand All @@ -44,16 +44,15 @@

_logger = getLogger(__name__)


_SUPPORTED_INSTRUMENTED_LIBRARIES_DEPENDENCIES_MAP = {
"django": ("django >= 1.10",),
"fastapi": ("fastapi ~= 0.58",),
"flask": ("flask >= 1.0, < 3.0",),
"psycopg2": ("psycopg2 >= 2.7.3.1",),
"requests": ("requests ~= 2.0",),
"urllib": tuple(),
"urllib3": ("urllib3 >= 1.0.0, < 2.0.0",),
}
_SUPPORTED_INSTRUMENTED_LIBRARIES = (
"django",
"fastapi",
"flask",
"psycopg2",
"requests",
"urllib",
"urllib3",
)


def configure_azure_monitor(**kwargs) -> None:
Expand Down Expand Up @@ -138,10 +137,10 @@ def _setup_instrumentations(configurations: Dict[str, ConfigurationValue]):

# use pkg_resources for now until https://github.com/open-telemetry/opentelemetry-python/pull/3168 is merged
for entry_point in iter_entry_points(
"azure_monitor_opentelemetry_instrumentor"
"opentelemetry_instrumentor"
):
lib_name = entry_point.name
if lib_name not in _SUPPORTED_INSTRUMENTED_LIBRARIES_DEPENDENCIES_MAP:
if lib_name not in _SUPPORTED_INSTRUMENTED_LIBRARIES:
continue
if entry_point.name in disabled_instrumentations:
_logger.debug(
Expand All @@ -150,10 +149,7 @@ def _setup_instrumentations(configurations: Dict[str, ConfigurationValue]):
continue
try:
# Check if dependent libraries/version are installed
instruments = _SUPPORTED_INSTRUMENTED_LIBRARIES_DEPENDENCIES_MAP[
lib_name
]
conflict = get_dependency_conflicts(instruments)
conflict = get_dist_dependency_conflicts(entry_point.dist)
if conflict:
_logger.debug(
"Skipping instrumentation %s: %s",
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading