Thanks to visit codestin.com
Credit goes to github.com

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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
([#235](https://github.com/microsoft/ApplicationInsights-Python/pull/235))
- Fix export interval bug
([#237](https://github.com/microsoft/ApplicationInsights-Python/pull/237))
- Add ability to specify custom metric readers
([#241](https://github.com/microsoft/ApplicationInsights-Python/pull/241))

## [1.0.0b8](https://github.com/microsoft/ApplicationInsights-Python/releases/tag/v1.0.0b8) - 2022-09-26

Expand Down
3 changes: 3 additions & 0 deletions azure-monitor-opentelemetry-distro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ You can use `configure_azure_monitor` to set up instrumentation for your app to
* logging_level - Specifies the [logging level][logging_level] of the Opentelemetry Logging Handler. Ex: logging.WARNING.
* logger_name = Specifies the [logger name][logger_name_hierarchy_doc] under which all logging will be instrumented. Defaults to "" which corresponds to the root logger.
* logging_export_interval_millis - Specifies the logging export interval in milliseconds. Defaults to 5000.
* metric_readers - Specifies the [metric readers][ot_metric_reader] that you would like to use for your metrics pipeline. Accepts a list of [metric readers][ot_sdk_python_metric_reader].
* views - Specifies the list of [views][opentelemetry_specification_view] to configure for the metric pipeline. See [here][ot_sdk_python_view_examples] for example usage.
* sampling_ratio - Specifies the ratio of distributed tracing telemetry to be [sampled][application_insights_sampling]. Accepted values are in the range [0,1]. Defaults to 1.0, meaning no telemetry is sampled out.
* tracing_export_interval_millis - Specifies the distributed tracing export interval in milliseconds. Defaults to 5000.
Expand Down Expand Up @@ -106,8 +107,10 @@ Samples are available [here][samples] to demonstrate how to utilize the above co
[logging_level]: https://docs.python.org/3/library/logging.html#levels
[logger_name_hierarchy_doc]: https://docs.python.org/3/library/logging.html#logger-objects
[ot_instrumentations]: https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation
[ot_metric_reader]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#metricreader
[ot_python_docs]: https://opentelemetry.io/docs/instrumentation/python/
[ot_sdk_python]: https://github.com/open-telemetry/opentelemetry-python
[ot_sdk_python_metric_reader]: https://opentelemetry-python.readthedocs.io/en/stable/sdk/metrics.export.html#opentelemetry.sdk.metrics.export.MetricReader
[ot_sdk_python_view_examples]: https://github.com/open-telemetry/opentelemetry-python/tree/main/docs/examples/metrics/views
[opentelemetry_instrumentation_requests]: https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation/opentelemetry-instrumentation-requests
[opentelemetry_instrumentation_django]: https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation/opentelemetry-instrumentation-django
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ def _setup_logging(resource: Resource, configurations: Dict[str, Any]):

def _setup_metrics(resource: Resource, configurations: Dict[str, Any]):
views = configurations.get("views", ())
metric_readers = configurations.get("metric_readers", [])
metric_exporter = AzureMonitorMetricExporter(**configurations)
reader = PeriodicExportingMetricReader(metric_exporter)
meter_provider = MeterProvider(
metric_readers=[reader],
metric_readers=[reader] + metric_readers,
resource=resource,
views=views,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def test_configure_azure_monitor(
"logging_export_interval_millis": 10000,
"logging_level": "test_logging_level",
"logger_name": "test_logger_name",
"metric_readers": "test_metric_readers",
"service_name": "test_service_name",
"service_namespace": "test_namespace",
"service_instance_id": "test_id",
Expand Down Expand Up @@ -290,7 +291,7 @@ def test_setup_tracing(
bsp_mock.assert_called_once_with(
trace_exp_init_mock, schedule_delay_millis=15000
)
tp_init_mock.add_span_processor(bsp_init_mock)
tp_init_mock.add_span_processor.assert_called_once_with(bsp_init_mock)

@patch(
"azure.monitor.opentelemetry.distro.getLogger",
Expand Down Expand Up @@ -396,11 +397,12 @@ def test_setup_metrics(
configurations = {
"connection_string": "test_cs",
"disable_metrics": False,
"metric_readers": ["test_reader1", "test_reader2"],
"views": "test_views",
}
_setup_metrics(resource_mock, configurations)
mp_mock.assert_called_once_with(
metric_readers=[reader_init_mock],
metric_readers=[reader_init_mock, "test_reader1", "test_reader2"],
resource=resource_mock,
views="test_views",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def test_get_configurations(self):
sampling_ratio="test_sample_ratio",
tracing_export_interval="test_tracing_interval",
logging_export_interval="test_logging_interval",
metric_readers=("test_readers"),
views=("test_view"),
)

Expand All @@ -57,4 +58,5 @@ def test_get_configurations(self):
self.assertEqual(
configurations["logging_export_interval"], "test_logging_interval"
)
self.assertEqual(configurations["metric_readers"], ("test_readers"))
self.assertEqual(configurations["views"], ("test_view"))