Skip to content

Commit 1f60f54

Browse files
authored
Upgrade Resource Detector version in Distro (#33866)
* Upgrade to new VMResourceDetector * Increment exporter version * Cast resource and logger_name types to fix mypy * Type marking instead of cast * feedback * Add Test Resource to tests to match typing * Type declaration
1 parent 33360ab commit 1f60f54

File tree

6 files changed

+38
-21
lines changed

6 files changed

+38
-21
lines changed

sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Release History
22

3+
## 1.0.0b22 (Unreleased)
4+
5+
### Features Added
6+
7+
### Breaking Changes
8+
9+
### Bugs Fixed
10+
11+
### Other Changes
12+
313
## 1.0.0b21 (2024-01-16)
414

515
### Other Changes

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
# license information.
66
# --------------------------------------------------------------------------
77

8-
VERSION = "1.0.0b21"
8+
VERSION = "1.0.0b22"

sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
([#33761](https://github.com/Azure/azure-sdk-for-python/pull/33761))
1515
- Fix siteName in diagnostic logging
1616
([#33808](https://github.com/Azure/azure-sdk-for-python/pull/33808))
17+
- Update min dependency versions opentelemetry-resource-detector-azure~=0.1.1, exporter~=1.0.0b21, OTel SDK/API~= 1.21
18+
([#33866](https://github.com/Azure/azure-sdk-for-python/pull/33866))
1719

1820
## 1.1.1 (2023-12-04)
1921

sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from opentelemetry.sdk._logs.export import BatchLogRecordProcessor
1919
from opentelemetry.sdk.metrics import MeterProvider
2020
from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader
21+
from opentelemetry.sdk.resources import Resource
2122
from opentelemetry.sdk.trace import TracerProvider
2223
from opentelemetry.sdk.trace.export import BatchSpanProcessor
2324
from opentelemetry.trace import get_tracer_provider, set_tracer_provider
@@ -92,7 +93,7 @@ def configure_azure_monitor(**kwargs) -> None:
9293

9394

9495
def _setup_tracing(configurations: Dict[str, ConfigurationValue]):
95-
resource = configurations[RESOURCE_ARG] # type: ignore
96+
resource: Resource = configurations[RESOURCE_ARG] # type: ignore
9697
sampling_ratio = configurations[SAMPLING_RATIO_ARG]
9798
tracer_provider = TracerProvider(
9899
sampler=ApplicationInsightsSampler(sampling_ratio=cast(float, sampling_ratio)),
@@ -109,7 +110,7 @@ def _setup_tracing(configurations: Dict[str, ConfigurationValue]):
109110

110111

111112
def _setup_logging(configurations: Dict[str, ConfigurationValue]):
112-
resource = configurations[RESOURCE_ARG] # type: ignore
113+
resource: Resource = configurations[RESOURCE_ARG] # type: ignore
113114
logger_provider = LoggerProvider(resource=resource)
114115
set_logger_provider(logger_provider)
115116
log_exporter = AzureMonitorLogExporter(**configurations)
@@ -118,12 +119,12 @@ def _setup_logging(configurations: Dict[str, ConfigurationValue]):
118119
)
119120
get_logger_provider().add_log_record_processor(log_record_processor) # type: ignore
120121
handler = LoggingHandler(logger_provider=get_logger_provider())
121-
logger_name = configurations[LOGGER_NAME_ARG] # type: ignore
122+
logger_name: str = configurations[LOGGER_NAME_ARG] # type: ignore
122123
getLogger(logger_name).addHandler(handler)
123124

124125

125126
def _setup_metrics(configurations: Dict[str, ConfigurationValue]):
126-
resource = configurations[RESOURCE_ARG] # type: ignore
127+
resource: Resource = configurations[RESOURCE_ARG] # type: ignore
127128
metric_exporter = AzureMonitorMetricExporter(**configurations)
128129
reader = PeriodicExportingMetricReader(metric_exporter)
129130
meter_provider = MeterProvider(

sdk/monitor/azure-monitor-opentelemetry/setup.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@
8888
install_requires=[
8989
"azure-core<2.0.0,>=1.24.0",
9090
"azure-core-tracing-opentelemetry~=1.0.0b10",
91-
"azure-monitor-opentelemetry-exporter~=1.0.0b18",
92-
"opentelemetry-instrumentation-django~=0.41b0",
93-
"opentelemetry-instrumentation-fastapi~=0.41b0",
94-
"opentelemetry-instrumentation-flask~=0.41b0",
95-
"opentelemetry-instrumentation-psycopg2~=0.41b0",
96-
"opentelemetry-instrumentation-requests~=0.41b0",
97-
"opentelemetry-instrumentation-urllib~=0.41b0",
98-
"opentelemetry-instrumentation-urllib3~=0.41b0",
99-
"opentelemetry-resource-detector-azure~=0.1.0",
91+
"azure-monitor-opentelemetry-exporter~=1.0.0b21",
92+
"opentelemetry-instrumentation-django~=0.42b0",
93+
"opentelemetry-instrumentation-fastapi~=0.42b0",
94+
"opentelemetry-instrumentation-flask~=0.42b0",
95+
"opentelemetry-instrumentation-psycopg2~=0.42b0",
96+
"opentelemetry-instrumentation-requests~=0.42b0",
97+
"opentelemetry-instrumentation-urllib~=0.42b0",
98+
"opentelemetry-instrumentation-urllib3~=0.42b0",
99+
"opentelemetry-resource-detector-azure~=0.1.1",
100100
],
101101
entry_points={
102102
"opentelemetry_distro": [

sdk/monitor/azure-monitor-opentelemetry/tests/configuration/test_configure.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
import os
1514
import unittest
1615
from unittest.mock import Mock, patch
1716

17+
from opentelemetry.sdk.resources import Resource
18+
1819
from azure.core.tracing.ext.opentelemetry_span import OpenTelemetrySpan
1920
from azure.monitor.opentelemetry._configure import (
2021
_setup_instrumentations,
@@ -25,6 +26,9 @@
2526
)
2627

2728

29+
TEST_RESOURCE = Resource({"foo": "bar"})
30+
31+
2832
class TestConfigure(unittest.TestCase):
2933
@patch(
3034
"azure.monitor.opentelemetry._configure._setup_instrumentations",
@@ -221,13 +225,13 @@ def test_setup_tracing(
221225
"azure_sdk": {"enabled": True}
222226
},
223227
"sampling_ratio": 0.5,
224-
"resource": "test_resource",
228+
"resource": TEST_RESOURCE,
225229
}
226230
_setup_tracing(configurations)
227231
sampler_mock.assert_called_once_with(sampling_ratio=0.5)
228232
tp_mock.assert_called_once_with(
229233
sampler=sampler_init_mock,
230-
resource="test_resource"
234+
resource=TEST_RESOURCE
231235
)
232236
set_tracer_provider_mock.assert_called_once_with(tp_init_mock)
233237
get_tracer_provider_mock.assert_called()
@@ -285,11 +289,11 @@ def test_setup_logging(
285289
configurations = {
286290
"connection_string": "test_cs",
287291
"logger_name": "test",
288-
"resource": "test_resource",
292+
"resource": TEST_RESOURCE,
289293
}
290294
_setup_logging(configurations)
291295

292-
lp_mock.assert_called_once_with(resource="test_resource")
296+
lp_mock.assert_called_once_with(resource=TEST_RESOURCE)
293297
set_logger_provider_mock.assert_called_once_with(lp_init_mock)
294298
get_logger_provider_mock.assert_called()
295299
log_exporter_mock.assert_called_once_with(**configurations)
@@ -336,12 +340,12 @@ def test_setup_metrics(
336340

337341
configurations = {
338342
"connection_string": "test_cs",
339-
"resource": "test_resource",
343+
"resource": TEST_RESOURCE,
340344
}
341345
_setup_metrics(configurations)
342346
mp_mock.assert_called_once_with(
343347
metric_readers=[reader_init_mock],
344-
resource="test_resource"
348+
resource=TEST_RESOURCE
345349
)
346350
set_meter_provider_mock.assert_called_once_with(mp_init_mock)
347351
metric_exporter_mock.assert_called_once_with(**configurations)

0 commit comments

Comments
 (0)