Merge pull request #260 from lzchen/rename

This commit is contained in:
Leighton Chen 2023-03-15 10:56:01 -07:00 коммит произвёл GitHub
Родитель 0fb9a74c1b 5c55724283
Коммит 9bd01fa6e5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
15 изменённых файлов: 33 добавлений и 31 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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] <instrumentation>_config: Specifies a dictionary of kwargs that will be applied to configuration for instrumentation <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 `<tempfile.gettempdir()>/Microsoft/AzureMonitor/opentelemetry-python-<your-instrumentation-key>`.
@ -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(

Просмотреть файл

@ -15,7 +15,7 @@ configure_azure_monitor(
logging_level=WARNING,
disable_metrics=True,
instrumentations=["flask"],
tracing_export_interval_millis=15000,
tracing_export_interval_ms=15000,
)
logger = getLogger(__name__)

Просмотреть файл

@ -11,7 +11,7 @@ configure_azure_monitor(
connection_string="<your-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

Просмотреть файл

@ -12,7 +12,7 @@ configure_azure_monitor(
connection_string="<your-connection-string>",
disable_logging=True,
disable_metrics=True,
tracing_export_interval_millis=15000,
tracing_export_interval_ms=15000,
)

Просмотреть файл

@ -12,7 +12,7 @@ configure_azure_monitor(
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()

Просмотреть файл

@ -12,7 +12,7 @@ configure_azure_monitor(
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__)

Просмотреть файл

@ -17,7 +17,7 @@ configure_azure_monitor(
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__)

Просмотреть файл

@ -16,7 +16,7 @@ configure_azure_monitor(
connection_string="<your-connection-string>",
disable_logging=True,
disable_metrics=True,
tracing_export_interval_millis=15000,
tracing_export_interval_ms=15000,
)
tracer = trace.get_tracer(__name__)

Просмотреть файл

@ -16,7 +16,7 @@ configure_azure_monitor(
connection_string="<your-connection-string>",
disable_logging=True,
disable_metrics=True,
tracing_export_interval_millis=15000,
tracing_export_interval_ms=15000,
)
http = urllib3.PoolManager()

Просмотреть файл

@ -9,7 +9,7 @@ from sqlalchemy import create_engine, text
configure_azure_monitor(
connection_string="<your-connection-string>",
tracing_export_interval_millis=15000,
tracing_export_interval_ms=15000,
disable_logging=True,
disable_metrics=True,
)

Просмотреть файл

@ -12,7 +12,7 @@ configure_azure_monitor(
# 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,
)

Просмотреть файл

@ -16,7 +16,7 @@ configure_azure_monitor(
ResourceAttributes.SERVICE_INSTANCE_ID: "simple_tracing_instance",
}
),
tracing_export_interval_millis=15000,
tracing_export_interval_ms=15000,
disable_logging=True,
disable_metrics=True,
)

Просмотреть файл

@ -55,7 +55,7 @@ class TestConfigure(unittest.TestCase):
"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 @@ class TestConfigure(unittest.TestCase):
"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 @@ class TestConfigure(unittest.TestCase):
"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 @@ class TestConfigure(unittest.TestCase):
"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 @@ class TestConfigure(unittest.TestCase):
"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 @@ class TestConfigure(unittest.TestCase):
"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 @@ class TestConfigure(unittest.TestCase):
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",
}