Skip to content

Commit

Permalink
Remove pkg_resources
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydvoss committed Sep 29, 2023
1 parent e38cf13 commit 85a5879
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
7 changes: 4 additions & 3 deletions sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

## 1.0.1 (Unreleased)

- Add message ids for AppLens
([#32195](https://github.com/Azure/azure-sdk-for-python/pull/32195))

### Features Added

- Add ability to specify which logger to export telemetry for via `logger_name` configuration
([#32192](https://github.com/Azure/azure-sdk-for-python/pull/32192))
- Add message ids for AppLens
([#32195](https://github.com/Azure/azure-sdk-for-python/pull/32195))
- Remove pkg_resources
([#32299](https://github.com/Azure/azure-sdk-for-python/pull/32299))

### Breaking Changes

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

from importlib_metadata import entry_points
from opentelemetry._logs import get_logger_provider, set_logger_provider
from opentelemetry.instrumentation.dependencies import (
get_dist_dependency_conflicts,
Expand All @@ -24,7 +25,6 @@
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.trace import get_tracer_provider, set_tracer_provider
from pkg_resources import iter_entry_points # type: ignore

from azure.core.settings import settings
from azure.core.tracing.ext.opentelemetry_span import OpenTelemetrySpan
Expand Down Expand Up @@ -156,11 +156,11 @@ def _setup_metrics(configurations: Dict[str, ConfigurationValue]):
def _setup_instrumentations(configurations: Dict[str, ConfigurationValue]):
disabled_instrumentations = configurations[DISABLED_INSTRUMENTATIONS_ARG]

# 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 entry_points(
group="opentelemetry_instrumentor"
):
lib_name = entry_point.name
print(lib_name)
if lib_name not in _SUPPORTED_INSTRUMENTED_LIBRARIES:
continue
if entry_point.name in disabled_instrumentations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def test_setup_metrics(
reader_mock.assert_called_once_with(metric_exp_init_mock)

@patch("azure.monitor.opentelemetry._configure.get_dist_dependency_conflicts")
@patch("azure.monitor.opentelemetry._configure.iter_entry_points")
@patch("azure.monitor.opentelemetry._configure.entry_points")
def test_setup_instrumentations_lib_not_supported(
self,
iter_mock,
Expand All @@ -392,7 +392,7 @@ def test_setup_instrumentations_lib_not_supported(

@patch("azure.monitor.opentelemetry._configure._logger")
@patch("azure.monitor.opentelemetry._configure.get_dist_dependency_conflicts")
@patch("azure.monitor.opentelemetry._configure.iter_entry_points")
@patch("azure.monitor.opentelemetry._configure.entry_points")
def test_setup_instrumentations_conflict(
self,
iter_mock,
Expand All @@ -415,7 +415,7 @@ def test_setup_instrumentations_conflict(

@patch("azure.monitor.opentelemetry._configure._logger")
@patch("azure.monitor.opentelemetry._configure.get_dist_dependency_conflicts")
@patch("azure.monitor.opentelemetry._configure.iter_entry_points")
@patch("azure.monitor.opentelemetry._configure.entry_points")
def test_setup_instrumentations_exception(
self,
iter_mock,
Expand All @@ -438,7 +438,7 @@ def test_setup_instrumentations_exception(

@patch("azure.monitor.opentelemetry._configure._logger")
@patch("azure.monitor.opentelemetry._configure.get_dist_dependency_conflicts")
@patch("azure.monitor.opentelemetry._configure.iter_entry_points")
@patch("azure.monitor.opentelemetry._configure.entry_points")
def test_setup_instrumentations_disabled(
self,
iter_mock,
Expand Down

0 comments on commit 85a5879

Please sign in to comment.