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

Expand Down
4 changes: 2 additions & 2 deletions azure-monitor-opentelemetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>`.
Expand Down Expand Up @@ -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),
Expand All @@ -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)

Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
connection_string="<your-connection-string>",
disable_logging=True,
disable_metrics=True,
tracing_export_interval_millis=15000,
tracing_export_interval_ms=15000,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
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__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
connection_string="<your-connection-string>",
disable_logging=True,
disable_metrics=True,
tracing_export_interval_millis=15000,
tracing_export_interval_ms=15000,
)

http = urllib3.PoolManager()
Expand Down
2 changes: 1 addition & 1 deletion azure-monitor-opentelemetry/samples/tracing/manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

configure_azure_monitor(
connection_string="<your-connection-string>",
tracing_export_interval_millis=15000,
tracing_export_interval_ms=15000,
disable_logging=True,
disable_metrics=True,
)
Expand Down
2 changes: 1 addition & 1 deletion azure-monitor-opentelemetry/samples/tracing/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
2 changes: 1 addition & 1 deletion azure-monitor-opentelemetry/samples/tracing/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
20 changes: 10 additions & 10 deletions azure-monitor-opentelemetry/tests/configuration/test_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ 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",
"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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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",
}
Expand Down