-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
Migrated from old repo issue
Is it possible to make _setup_resources() optional in configure_azure_monitor()? I'm referring to the following segment of code:
def configure_azure_monitor(**kwargs) -> None:
"""This function works as a configuration layer that allows the
end user to configure OpenTelemetry and Azure monitor components. The
configuration can be done via arguments passed to this function.
:keyword str connection_string: Connection string for your Application Insights resource.
:keyword credential: Token credential, such as `ManagedIdentityCredential` or `ClientSecretCredential`,
used for Azure Active Directory (AAD) authentication. Defaults to `None`.
:paramtype credential: ~azure.core.credentials.TokenCredential or None
: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>`.
:keyword str logger_name: The name of the Python logger that telemetry will be collected.
:rtype: None
"""
configurations = _get_configurations(**kwargs)
disable_tracing = configurations[DISABLE_TRACING_ARG]
disable_logging = configurations[DISABLE_LOGGING_ARG]
disable_metrics = configurations[DISABLE_METRICS_ARG]
# Setup resources
_setup_resources() # <----- this line
....When developing a containerized FastAPI application, I encounter an issue during live reloads or application startups. The error message is as follows:
Exception in detector <opentelemetry.resource.detector.azure.vm.AzureVMResourceDetector object at 0xffffa58ef810>, ignoring
This error repeats multiple times with a few seconds interval, ultimately leading to:
Cannot call collect on a MetricReader until it is registered on a MeterProvider
After these messages, the application starts normally. However, this issue is a significant inconvenience during local development, particularly when experimenting with Azure Application Insights.
I suspect _setup_resources() is the root cause, as it seems to configure the environment as if it were an Azure resource. Could this be the case?
Additionally, I've only started encountering this error in version 1.1.0; it wasn't an issue in previous versions.
Lastly, why doesn't this repository reflect the latest version of the package?