From 5c557242836067767cf39ba8ed1cbb01945252f0 Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Wed, 15 Mar 2023 10:00:02 -0700 Subject: [PATCH] rename --- CHANGELOG.md | 2 ++ azure-monitor-opentelemetry/README.md | 4 ++-- .../azure/monitor/opentelemetry/_configure.py | 16 +++++++-------- .../samples/logging/logs_with_traces.py | 2 +- .../samples/tracing/db_psycopg2.py | 2 +- .../tracing/django/sample/example/views.py | 2 +- .../samples/tracing/http_fastapi.py | 2 +- .../samples/tracing/http_flask.py | 2 +- .../samples/tracing/http_requests.py | 2 +- .../samples/tracing/http_urllib.py | 2 +- .../samples/tracing/http_urllib3.py | 2 +- .../samples/tracing/manual.py | 2 +- .../samples/tracing/sampling.py | 2 +- .../samples/tracing/simple.py | 2 +- .../tests/configuration/test_configure.py | 20 +++++++++---------- 15 files changed, 33 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3373959c..6fbdec54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ ([#255](https://github.com/microsoft/ApplicationInsights-Python/pull/255)) - Add support for Urllib3/Urllib instrumentation ([#256](https://github.com/microsoft/ApplicationInsights-Python/pull/256)) +- Change interval params to use `_ms` as suffix + ([#260](https://github.com/microsoft/ApplicationInsights-Python/pull/260)) ## [1.0.0b10](https://github.com/microsoft/ApplicationInsights-Python/releases/tag/v1.0.0b10) - 2023-02-23 diff --git a/azure-monitor-opentelemetry/README.md b/azure-monitor-opentelemetry/README.md index 1c621150..3b940298 100644 --- a/azure-monitor-opentelemetry/README.md +++ b/azure-monitor-opentelemetry/README.md @@ -57,11 +57,11 @@ You can use `configure_azure_monitor` to set up instrumentation for your app to * resource - Specified the OpenTelemetry [resource][opentelemetry_spec_resource] associated with your application. See [this][ot_sdk_python_resource] for default behavior. * logging_level - Specifies the [logging level][logging_level] of the logs you would like to collect for your logging pipeline. Defaults to logging.NOTSET. * logger_name = Specifies the [logger name][logger_name_hierarchy_doc] under which 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. +* logging_export_interval_ms - 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 metric pipeline. Accepts a list of [metric readers][ot_sdk_python_metric_reader]. * views - Specifies the list of [views][opentelemetry_spec_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. +* tracing_export_interval_ms - Specifies the distributed tracing export interval in milliseconds. Defaults to 5000. #### Exporter configurations diff --git a/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py b/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py index f08a80af..7eefae01 100644 --- a/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py +++ b/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py @@ -58,11 +58,11 @@ def configure_azure_monitor(**kwargs) -> None: :keyword bool disable_tracing: If set to `True`, disables collection and export of distributed tracing telemetry. Defaults to `False`. :keyword int logging_level: Specifies the logging of the logs you would like to collect for your logging pipeline. :keyword str logger_name: Specifies the logger name under which logging will be instrumented. Defaults to "" which corresponds to the root logger. - :keyword int logging_export_interval_millis: Specifies the logging export interval in milliseconds. Defaults to 5000. + :keyword int logging_export_interval_ms: Specifies the logging export interval in milliseconds. Defaults to 5000. :keyword Sequence[MetricReader] metric_readers: Specifies the metric readers that you would like to use for your metric pipeline. :keyword Sequence[View] views: Specifies the list of views to configure for the metric pipeline. :keyword float sampling_ratio: Specifies the ratio of distributed tracing telemetry to be sampled. Accepted values are in the range [0,1]. Defaults to 1.0, meaning no telemetry is sampled out. - :keyword int tracing_export_interval_millis: Specifies the distributed tracing export interval in milliseconds. Defaults to 5000. + :keyword int tracing_export_interval_ms: Specifies the distributed tracing export interval in milliseconds. Defaults to 5000. :keyword Dict[str, Any] _config: Specifies a dictionary of kwargs that will be applied to configuration for instrumentation . :keyword bool disable_offline_storage: Boolean value to determine whether to disable storing failed telemetry records for retry. Defaults to `False`. :keyword str storage_directory: Storage directory in which to store retry files. Defaults to `/Microsoft/AzureMonitor/opentelemetry-python-`. @@ -105,8 +105,8 @@ def _setup_tracing( resource: Resource, configurations: Dict[str, ConfigurationValue] ): sampling_ratio = configurations.get("sampling_ratio", 1.0) - tracing_export_interval_millis = configurations.get( - "tracing_export_interval_millis", 5000 + tracing_export_interval_ms = configurations.get( + "tracing_export_interval_ms", 5000 ) tracer_provider = TracerProvider( sampler=ApplicationInsightsSampler(sampling_ratio=sampling_ratio), @@ -116,7 +116,7 @@ def _setup_tracing( trace_exporter = AzureMonitorTraceExporter(**configurations) span_processor = BatchSpanProcessor( trace_exporter, - schedule_delay_millis=tracing_export_interval_millis, + schedule_delay_millis=tracing_export_interval_ms, ) get_tracer_provider().add_span_processor(span_processor) @@ -126,15 +126,15 @@ def _setup_logging( ): logger_name = configurations.get("logger_name", "") logging_level = configurations.get("logging_level", NOTSET) - logging_export_interval_millis = configurations.get( - "logging_export_interval_millis", 5000 + logging_export_interval_ms = configurations.get( + "logging_export_interval_ms", 5000 ) logger_provider = LoggerProvider(resource=resource) set_logger_provider(logger_provider) log_exporter = AzureMonitorLogExporter(**configurations) log_record_processor = BatchLogRecordProcessor( log_exporter, - schedule_delay_millis=logging_export_interval_millis, + schedule_delay_millis=logging_export_interval_ms, ) get_logger_provider().add_log_record_processor(log_record_processor) handler = LoggingHandler( diff --git a/azure-monitor-opentelemetry/samples/logging/logs_with_traces.py b/azure-monitor-opentelemetry/samples/logging/logs_with_traces.py index be029ec6..658c20a2 100644 --- a/azure-monitor-opentelemetry/samples/logging/logs_with_traces.py +++ b/azure-monitor-opentelemetry/samples/logging/logs_with_traces.py @@ -15,7 +15,7 @@ logging_level=WARNING, disable_metrics=True, instrumentations=["flask"], - tracing_export_interval_millis=15000, + tracing_export_interval_ms=15000, ) logger = getLogger(__name__) diff --git a/azure-monitor-opentelemetry/samples/tracing/db_psycopg2.py b/azure-monitor-opentelemetry/samples/tracing/db_psycopg2.py index 72bfab97..5811b6ec 100644 --- a/azure-monitor-opentelemetry/samples/tracing/db_psycopg2.py +++ b/azure-monitor-opentelemetry/samples/tracing/db_psycopg2.py @@ -11,7 +11,7 @@ connection_string="", disable_logging=True, disable_metrics=True, - tracing_export_interval_millis=15000, + tracing_export_interval_ms=15000, ) # Database calls using the psycopg2 library will be automatically captured diff --git a/azure-monitor-opentelemetry/samples/tracing/django/sample/example/views.py b/azure-monitor-opentelemetry/samples/tracing/django/sample/example/views.py index d8d37fe9..6906c9d7 100644 --- a/azure-monitor-opentelemetry/samples/tracing/django/sample/example/views.py +++ b/azure-monitor-opentelemetry/samples/tracing/django/sample/example/views.py @@ -12,7 +12,7 @@ connection_string="", disable_logging=True, disable_metrics=True, - tracing_export_interval_millis=15000, + tracing_export_interval_ms=15000, ) diff --git a/azure-monitor-opentelemetry/samples/tracing/http_fastapi.py b/azure-monitor-opentelemetry/samples/tracing/http_fastapi.py index c53b6269..8d427705 100644 --- a/azure-monitor-opentelemetry/samples/tracing/http_fastapi.py +++ b/azure-monitor-opentelemetry/samples/tracing/http_fastapi.py @@ -12,7 +12,7 @@ disable_logging=True, disable_metrics=True, fastapi_config={"excluded_urls": "http://127.0.0.1:8000/exclude"}, - tracing_export_interval_millis=15000, + tracing_export_interval_ms=15000, ) app = fastapi.FastAPI() diff --git a/azure-monitor-opentelemetry/samples/tracing/http_flask.py b/azure-monitor-opentelemetry/samples/tracing/http_flask.py index 80225271..ca8039ec 100644 --- a/azure-monitor-opentelemetry/samples/tracing/http_flask.py +++ b/azure-monitor-opentelemetry/samples/tracing/http_flask.py @@ -12,7 +12,7 @@ disable_logging=True, disable_metrics=True, flask_config={"excluded_urls": "http://localhost:8080/ignore"}, - tracing_export_interval_millis=15000, + tracing_export_interval_ms=15000, ) app = flask.Flask(__name__) diff --git a/azure-monitor-opentelemetry/samples/tracing/http_requests.py b/azure-monitor-opentelemetry/samples/tracing/http_requests.py index 29abce93..0ad78e8e 100644 --- a/azure-monitor-opentelemetry/samples/tracing/http_requests.py +++ b/azure-monitor-opentelemetry/samples/tracing/http_requests.py @@ -17,7 +17,7 @@ disable_logging=True, disable_metrics=True, requests_config={"excluded_urls": "http://example.com"}, - tracing_export_interval_millis=15000, + tracing_export_interval_ms=15000, ) tracer = trace.get_tracer(__name__) diff --git a/azure-monitor-opentelemetry/samples/tracing/http_urllib.py b/azure-monitor-opentelemetry/samples/tracing/http_urllib.py index cf2eb453..40896f4b 100644 --- a/azure-monitor-opentelemetry/samples/tracing/http_urllib.py +++ b/azure-monitor-opentelemetry/samples/tracing/http_urllib.py @@ -16,7 +16,7 @@ connection_string="", disable_logging=True, disable_metrics=True, - tracing_export_interval_millis=15000, + tracing_export_interval_ms=15000, ) tracer = trace.get_tracer(__name__) diff --git a/azure-monitor-opentelemetry/samples/tracing/http_urllib3.py b/azure-monitor-opentelemetry/samples/tracing/http_urllib3.py index 6b2d8e8e..96ed3f40 100644 --- a/azure-monitor-opentelemetry/samples/tracing/http_urllib3.py +++ b/azure-monitor-opentelemetry/samples/tracing/http_urllib3.py @@ -16,7 +16,7 @@ connection_string="", disable_logging=True, disable_metrics=True, - tracing_export_interval_millis=15000, + tracing_export_interval_ms=15000, ) http = urllib3.PoolManager() diff --git a/azure-monitor-opentelemetry/samples/tracing/manual.py b/azure-monitor-opentelemetry/samples/tracing/manual.py index 122ca429..39386429 100644 --- a/azure-monitor-opentelemetry/samples/tracing/manual.py +++ b/azure-monitor-opentelemetry/samples/tracing/manual.py @@ -9,7 +9,7 @@ configure_azure_monitor( connection_string="", - tracing_export_interval_millis=15000, + tracing_export_interval_ms=15000, disable_logging=True, disable_metrics=True, ) diff --git a/azure-monitor-opentelemetry/samples/tracing/sampling.py b/azure-monitor-opentelemetry/samples/tracing/sampling.py index ad0c8a77..7cd2831a 100644 --- a/azure-monitor-opentelemetry/samples/tracing/sampling.py +++ b/azure-monitor-opentelemetry/samples/tracing/sampling.py @@ -12,7 +12,7 @@ # Sampling ratio of between 0 and 1 inclusive # 0.1 means approximately 10% of your traces are sent sampling_ratio=0.1, - tracing_export_interval_millis=15000, + tracing_export_interval_ms=15000, disable_logging=True, disable_metrics=True, ) diff --git a/azure-monitor-opentelemetry/samples/tracing/simple.py b/azure-monitor-opentelemetry/samples/tracing/simple.py index 0212c17a..37d5d32c 100644 --- a/azure-monitor-opentelemetry/samples/tracing/simple.py +++ b/azure-monitor-opentelemetry/samples/tracing/simple.py @@ -16,7 +16,7 @@ ResourceAttributes.SERVICE_INSTANCE_ID: "simple_tracing_instance", } ), - tracing_export_interval_millis=15000, + tracing_export_interval_ms=15000, disable_logging=True, disable_metrics=True, ) diff --git a/azure-monitor-opentelemetry/tests/configuration/test_configure.py b/azure-monitor-opentelemetry/tests/configuration/test_configure.py index ed653466..52be1f3b 100644 --- a/azure-monitor-opentelemetry/tests/configuration/test_configure.py +++ b/azure-monitor-opentelemetry/tests/configuration/test_configure.py @@ -55,7 +55,7 @@ def test_configure_azure_monitor( "disable_tracing": False, "disable_logging": False, "disable_metrics": False, - "logging_export_interval_millis": 10000, + "logging_export_interval_ms": 10000, "logging_level": "test_logging_level", "logger_name": "test_logger_name", "metric_readers": "test_metric_readers", @@ -63,7 +63,7 @@ def test_configure_azure_monitor( "service_namespace": "test_namespace", "service_instance_id": "test_id", "sampling_ratio": 0.5, - "tracing_export_interval_millis": 15000, + "tracing_export_interval_ms": 15000, "views": "test_views", } resource_init_mock = Mock() @@ -103,14 +103,14 @@ def test_configure_azure_monitor_disable_tracing( "disable_tracing": True, "disable_logging": False, "disable_metrics": False, - "logging_export_interval_millis": 10000, + "logging_export_interval_ms": 10000, "logging_level": "test_logging_level", "logger_name": "test_logger_name", "service_name": "test_service_name", "service_namespace": "test_namespace", "service_instance_id": "test_id", "sampling_ratio": 0.5, - "tracing_export_interval_millis": 15000, + "tracing_export_interval_ms": 15000, "views": "test_views", } resource_init_mock = Mock() @@ -150,14 +150,14 @@ def test_configure_azure_monitor_disable_logging( "disable_tracing": False, "disable_logging": True, "disable_metrics": False, - "logging_export_interval_millis": 10000, + "logging_export_interval_ms": 10000, "logging_level": "test_logging_level", "logger_name": "test_logger_name", "service_name": "test_service_name", "service_namespace": "test_namespace", "service_instance_id": "test_id", "sampling_ratio": 0.5, - "tracing_export_interval_millis": 15000, + "tracing_export_interval_ms": 15000, "views": "test_views", } resource_init_mock = Mock() @@ -197,13 +197,13 @@ def test_configure_azure_monitor_disable_metrics( "disable_tracing": False, "disable_logging": False, "disable_metrics": True, - "logging_export_interval_millis": 10000, + "logging_export_interval_ms": 10000, "logging_level": "test_logging_level", "service_name": "test_service_name", "service_namespace": "test_namespace", "service_instance_id": "test_id", "sampling_ratio": 0.5, - "tracing_export_interval_millis": 15000, + "tracing_export_interval_ms": 15000, "views": "test_views", } resource_init_mock = Mock() @@ -271,7 +271,7 @@ def test_setup_tracing( "connection_string": "test_cs", "disable_tracing": False, "sampling_ratio": 0.5, - "tracing_export_interval_millis": 15000, + "tracing_export_interval_ms": 15000, } _setup_tracing(resource_mock, configurations) sampler_mock.assert_called_once_with(sampling_ratio=0.5) @@ -336,7 +336,7 @@ def test_setup_logging( configurations = { "connection_string": "test_cs", "disable_logging": False, - "logging_export_interval_millis": 10000, + "logging_export_interval_ms": 10000, "logging_level": "test_logging_level", "logger_name": "test_logger_name", }