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
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ exclude =
target
__pycache__
*/build/lib/*
azure-monitor-opentelemetry/azure/monitor/opentelemetry/_vendor/*
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ profile=black
; docs: https://github.com/timothycrosley/isort#multi-line-output-modes
multi_line_output=3
skip=target
skip_glob=**/gen/*,.venv*/*,venv*/*,**/proto/*,.tox/*
skip_glob=**/gen/*,.venv*/*,venv*/*,**/proto/*,.tox/*, azure-monitor-opentelemetry/azure/monitor/opentelemetry/_vendor/*
known_third_party=opentelemetry,psutil,pytest,redis,redis_opentracing
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Vendor Instrumentations
([#280](https://github.com/microsoft/ApplicationInsights-Python/pull/280))
- Update samples
([#281](https://github.com/microsoft/ApplicationInsights-Python/pull/281))
- Fixed spelling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
SAMPLING_RATIO_ARG,
)
from azure.monitor.opentelemetry._types import ConfigurationValue
from azure.monitor.opentelemetry._vendor.v0_38b0.opentelemetry.instrumentation.dependencies import (
get_dependency_conflicts,
)
from azure.monitor.opentelemetry._vendor.v0_38b0.opentelemetry.instrumentation.instrumentor import (
BaseInstrumentor,
)
from azure.monitor.opentelemetry.exporter import (
ApplicationInsightsSampler,
AzureMonitorLogExporter,
Expand All @@ -22,10 +28,6 @@
)
from azure.monitor.opentelemetry.util.configurations import _get_configurations
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 @@ -39,15 +41,15 @@
_logger = getLogger(__name__)


_SUPPORTED_INSTRUMENTED_LIBRARIES = (
"django",
"fastapi",
"flask",
"psycopg2",
"requests",
"urllib",
"urllib3",
)
_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",),
}


def configure_azure_monitor(**kwargs) -> None:
Expand Down Expand Up @@ -129,13 +131,18 @@ def _setup_metrics(configurations: Dict[str, ConfigurationValue]):

def _setup_instrumentations():
# use pkg_resources for now until https://github.com/open-telemetry/opentelemetry-python/pull/3168 is merged
for entry_point in iter_entry_points("opentelemetry_instrumentor"):
for entry_point in iter_entry_points(
"azure_monitor_opentelemetry_instrumentor"
):
lib_name = entry_point.name
if lib_name not in _SUPPORTED_INSTRUMENTED_LIBRARIES:
if lib_name not in _SUPPORTED_INSTRUMENTED_LIBRARIES_DEPENDENCIES_MAP:
continue
try:
# Check if dependent libraries/version are installed
conflict = get_dist_dependency_conflicts(entry_point.dist)
instruments = _SUPPORTED_INSTRUMENTED_LIBRARIES_DEPENDENCIES_MAP[
lib_name
]
conflict = get_dependency_conflicts(instruments)
if conflict:
_logger.debug(
"Skipping instrumentation %s: %s",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License in the project root for
# license information.
# --------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License in the project root for
# license information.
# --------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License in the project root for
# license information.
# --------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License in the project root for
# license information.
# --------------------------------------------------------------------------
Loading