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 @@ -44,6 +44,8 @@
([#244](https://github.com/microsoft/ApplicationInsights-Python/pull/244))
- Replace service.X configurations with Resource
([#246](https://github.com/microsoft/ApplicationInsights-Python/pull/246))
- Change namespace to `azure.monitor.opentelemtry`
([#247](https://github.com/microsoft/ApplicationInsights-Python/pull/247))

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Azure Monitor Opentelemetry Distro

Azure Monitor Distro of [Opentelemetry Python][ot_sdk_python] provides multiple installable components available for an Opentelemetry Azure Monitor monitoring solution. It allows you to instrument your Python applications to capture and report telemetry to Azure Monitor via the Azure monitor exporters.
The Azure Monitor Distro of [Opentelemetry Python][ot_sdk_python] provides multiple installable components available for an Opentelemetry Azure Monitor monitoring solution. It allows you to instrument your Python applications to capture and report telemetry to Azure Monitor via the Azure monitor exporters.

This distro automatically installs the following libraries:

Expand All @@ -20,7 +20,7 @@ The [Azure Monitor OpenTelemetry exporters][azure_monitor_opentelemetry_exporter

Currently, all instrumentations available in OpenTelemetry are in a beta state, meaning they are not stable and may have breaking changes in the future. Efforts are being made in pushing these to a more stable state.

### Prerequisites:
### Prerequisites

To use this package, you must have:

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License in the project root for
# license information.
# -------------------------------------------------------------------------

from azure.monitor.opentelemetry._configure import configure_azure_monitor

from ._version import VERSION

__all__ = [
"configure_azure_monitor",
]
__version__ = VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
from logging import NOTSET, getLogger
from typing import Dict

from azure.monitor.opentelemetry.distro._types import ConfigurationValue
from azure.monitor.opentelemetry.distro.util import _get_configurations
from azure.monitor.opentelemetry._types import ConfigurationValue
from azure.monitor.opentelemetry.exporter import (
ApplicationInsightsSampler,
AzureMonitorLogExporter,
AzureMonitorMetricExporter,
AzureMonitorTraceExporter,
)
from azure.monitor.opentelemetry.util import _get_configurations
from opentelemetry._logs import get_logger_provider, set_logger_provider
from opentelemetry.metrics import set_meter_provider
from opentelemetry.sdk._logs import LoggerProvider, LoggingHandler
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License in the project root for
# license information.
# -------------------------------------------------------------------------
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import logging

from azure.monitor.opentelemetry.distro._diagnostics._diagnostic_logging import (
from azure.monitor.opentelemetry.diagnostics._diagnostic_logging import (
AzureDiagnosticLogging,
)
from opentelemetry.sdk._configuration import _OTelSDKConfigurator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import logging
from os import environ

from azure.monitor.opentelemetry.distro._diagnostics._diagnostic_logging import (
from azure.monitor.opentelemetry.diagnostics._diagnostic_logging import (
AzureDiagnosticLogging,
)
from azure.monitor.opentelemetry.distro._diagnostics._status_logger import (
from azure.monitor.opentelemetry.diagnostics._status_logger import (
AzureStatusLogger,
)
from opentelemetry.environment_variables import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
from os import makedirs
from os.path import exists, join

from azure.monitor.opentelemetry.distro._constants import (
from azure.monitor.opentelemetry._constants import (
_CUSTOMER_IKEY,
_EXTENSION_VERSION,
_IS_DIAGNOSTICS_ENABLED,
_env_var_or_default,
_get_log_path,
)
from azure.monitor.opentelemetry.distro._version import VERSION
from azure.monitor.opentelemetry._version import VERSION

_DIAGNOSTIC_LOGGER_FILE_NAME = "applicationinsights-extension.log"
_SITE_NAME = _env_var_or_default("WEBSITE_SITE_NAME")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
from os.path import exists, join
from platform import node

from azure.monitor.opentelemetry.distro._constants import (
from azure.monitor.opentelemetry._constants import (
_CUSTOMER_IKEY,
_EXTENSION_VERSION,
_IS_DIAGNOSTICS_ENABLED,
_get_log_path,
)
from azure.monitor.opentelemetry.distro._version import VERSION
from azure.monitor.opentelemetry._version import VERSION

_MACHINE_NAME = node()
_STATUS_LOG_PATH = _get_log_path(status_log_path=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from typing import Dict

from azure.monitor.opentelemetry.distro._types import ConfigurationValue
from azure.monitor.opentelemetry._types import ConfigurationValue


def _get_configurations(**kwargs) -> Dict[str, ConfigurationValue]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from logging import WARNING, getLogger

from azure.monitor.opentelemetry.distro import configure_azure_monitor
from azure.monitor.opentelemetry import configure_azure_monitor
from opentelemetry import trace

configure_azure_monitor(
Expand All @@ -28,3 +28,5 @@
logger.info("Correlated info log")
logger.warning("Correlated warning log")
logger.error("Correlated error log")

input()
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from logging import DEBUG, getLogger

from azure.monitor.opentelemetry.distro import configure_azure_monitor
from azure.monitor.opentelemetry import configure_azure_monitor

configure_azure_monitor(
connection_string="<your-connection-string>",
Expand All @@ -21,3 +21,5 @@

# Pass custom properties in a dictionary with the extra argument
logger.debug("DEBUG: Debug with properties", extra={"debug": "true"})

input()
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from logging import WARNING, getLogger

from azure.monitor.opentelemetry.distro import configure_azure_monitor
from azure.monitor.opentelemetry import configure_azure_monitor

configure_azure_monitor(
connection_string="<your-connection-string>",
Expand All @@ -31,3 +31,5 @@
print(val)
except ZeroDivisionError:
logger.error("Error: Division by zero", stack_info=True, exc_info=True)

input()
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from logging import WARNING, getLogger

import flask
from azure.monitor.opentelemetry.distro import configure_azure_monitor
from azure.monitor.opentelemetry import configure_azure_monitor

configure_azure_monitor(
connection_string="<your-connection-string>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from logging import WARNING, getLogger

from azure.monitor.opentelemetry.distro import configure_azure_monitor
from azure.monitor.opentelemetry import configure_azure_monitor
from opentelemetry.sdk.resources import Resource, ResourceAttributes

configure_azure_monitor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from azure.monitor.opentelemetry.distro import configure_azure_monitor

from azure.monitor.opentelemetry import configure_azure_monitor
from opentelemetry import metrics

# Configure Azure monitor collection telemetry pipeline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the MIT License.
from typing import Iterable

from azure.monitor.opentelemetry.distro import configure_azure_monitor
from azure.monitor.opentelemetry import configure_azure_monitor
from opentelemetry import metrics
from opentelemetry.metrics import CallbackOptions, Observation
from opentelemetry.sdk.resources import Resource, ResourceAttributes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from azure.monitor.opentelemetry.distro import configure_azure_monitor
from azure.monitor.opentelemetry import configure_azure_monitor
from opentelemetry import metrics
from opentelemetry.sdk.metrics import Counter
from opentelemetry.sdk.metrics.view import View
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging

import requests
from azure.monitor.opentelemetry.distro import configure_azure_monitor
from azure.monitor.opentelemetry import configure_azure_monitor
from opentelemetry import trace

logger = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# license information.
# --------------------------------------------------------------------------
import psycopg2
from azure.monitor.opentelemetry.distro import configure_azure_monitor
from azure.monitor.opentelemetry import configure_azure_monitor

# Configure Azure monitor collection telemetry pipeline
configure_azure_monitor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# license information.
# --------------------------------------------------------------------------

from azure.monitor.opentelemetry.distro import configure_azure_monitor
from azure.monitor.opentelemetry import configure_azure_monitor
from django.http import HttpResponse

# Configure Azure monitor collection telemetry pipeline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# license information.
# --------------------------------------------------------------------------
import flask
from azure.monitor.opentelemetry.distro import configure_azure_monitor
from azure.monitor.opentelemetry import configure_azure_monitor

# Configure Azure monitor collection telemetry pipeline
configure_azure_monitor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# license information.
# --------------------------------------------------------------------------

from azure.monitor.opentelemetry.distro import configure_azure_monitor
from azure.monitor.opentelemetry import configure_azure_monitor
from opentelemetry import trace
from opentelemetry.sdk.resources import Resource, ResourceAttributes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from setuptools import find_packages, setup

# Change the PACKAGE_NAME only to change folder and different name
PACKAGE_NAME = "azure-monitor-opentelemetry-distro"
PACKAGE_NAME = "azure-monitor-opentelemetry"
PACKAGE_PPRINT_NAME = "Azure Monitor Opentelemetry Distro"

# a-b-c => a/b/c
Expand Down Expand Up @@ -76,7 +76,6 @@
# Exclude packages that will be covered by PEP420 or nspkg
"azure",
"azure.monitor",
"azure.monitor.opentelemetry",
]
),
include_package_data=True,
Expand All @@ -96,10 +95,10 @@
],
entry_points={
"opentelemetry_distro": [
"azure_monitor_opentelemetry_distro = azure.monitor.opentelemetry.distro._distro:AzureMonitorDistro"
"azure_monitor_opentelemetry_distro = azure.monitor.opentelemetry.autoinstrumentation._distro:AzureMonitorDistro"
],
"opentelemetry_configurator": [
"azure_monitor_opentelemetry_configurator = azure.monitor.opentelemetry.distro._configurator:AzureMonitorConfigurator"
"azure_monitor_opentelemetry_configurator = azure.monitor.opentelemetry.autoinstrumentation._configurator:AzureMonitorConfigurator"
],
},
)
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
from unittest import TestCase
from unittest.mock import patch

from azure.monitor.opentelemetry.distro._distro import AzureMonitorDistro
from azure.monitor.opentelemetry.autoinstrumentation._distro import (
AzureMonitorDistro,
)


class TestDistro(TestCase):
@patch(
"azure.monitor.opentelemetry.distro._distro.AzureDiagnosticLogging.enable"
"azure.monitor.opentelemetry.autoinstrumentation._distro.AzureDiagnosticLogging.enable"
)
# TODO: Enabled when duplciate logging issue is solved
# @patch(
# "azure.monitor.opentelemetry.distro._diagnostic_logging._EXPORTER_DIAGNOSTICS_ENABLED",
# "azure.monitor.opentelemetry.autoinstrumentation._diagnostic_logging._EXPORTER_DIAGNOSTICS_ENABLED",
# False,
# )
def test_configure(self, mock_diagnostics):
Expand All @@ -20,10 +22,10 @@ def test_configure(self, mock_diagnostics):

# TODO: Enabled when duplicate logging issue is solved
# @patch(
# "azure.monitor.opentelemetry.distro._distro.AzureDiagnosticLogging.enable"
# "azure.monitor.opentelemetry.autoinstrumentation._distro.AzureDiagnosticLogging.enable"
# )
# @patch(
# "azure.monitor.opentelemetry.distro._diagnostic_logging._EXPORTER_DIAGNOSTICS_ENABLED",
# "azure.monitor.opentelemetry.autoinstrumentation._diagnostic_logging._EXPORTER_DIAGNOSTICS_ENABLED",
# True,
# )
# def test_configure_exporter_diagnostics(self, mock_diagnostics):
Expand Down
Loading