diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 4c90f831b100..4417af465c45 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -44,6 +44,9 @@ # PRLabel: %Monitor - LogAnalytics /sdk/loganalytics/ @alexeldeib +# PRLabel: %Monitor - Exporter +/sdk/monitor/opentelemetry-exporter-azuremonitor @rakshith91 @lmazuel @hectorhdzg @lzchen + # PRLabel: %Consumption /sdk/consumption/ @sandeepnl diff --git a/eng/.docsettings.yml b/eng/.docsettings.yml index 103fdb6a8b86..cdad479fc240 100644 --- a/eng/.docsettings.yml +++ b/eng/.docsettings.yml @@ -97,6 +97,8 @@ known_content_issues: - ['sdk/storage/azure-storage-queue/swagger/README.md', '#4554'] - ['sdk/storage/README.md', '#4554'] - ['sdk/textanalytics/azure-ai-textanalytics/samples/README.md', '#4554'] + - ['sdk/monitor/opentelemetry-exporter-azuremonitor/swagger/README.md', '#4554'] + - ['sdk/monitor/opentelemetry-exporter-azuremonitor/README.md', '#4554'] # nspckg and common. - ['sdk/appconfiguration/azure-appconfiguration/README.md', 'nspkg and common'] diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/CHANGELOG.md b/sdk/monitor/opentelemetry-exporter-azuremonitor/CHANGELOG.md new file mode 100644 index 000000000000..ca105e1bd704 --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/CHANGELOG.md @@ -0,0 +1,55 @@ +# Release History + +## Unreleased + +## 0.5b.0 +Released 2020-09-24 + +- Change epoch for live metrics + ([#115](https://github.com/microsoft/opentelemetry-azure-monitor-python/pull/115)) +- Dropping support for Python 3.4 + ([#117](https://github.com/microsoft/opentelemetry-azure-monitor-python/pull/117)) + +## 0.4b.0 +Released 2020-06-29 + +- Added live metrics + ([#96](https://github.com/microsoft/opentelemetry-azure-monitor-python/pull/96)) +- Remove dependency metrics from auto-collection + ([#92](https://github.com/microsoft/opentelemetry-azure-monitor-python/pull/92)) +- Change default local storage directory + ([#100](https://github.com/microsoft/opentelemetry-azure-monitor-python/pull/100)) +- Implement proxies in exporter configuration + ([#101](https://github.com/microsoft/opentelemetry-azure-monitor-python/pull/101)) +- Remove request failed per second metrics from auto-collection + ([#102](https://github.com/microsoft/opentelemetry-azure-monitor-python/pull/102)) + +## 0.3b.1 +Released 2020-05-21 + +- Fix metrics exporter serialization bug + ([#92](https://github.com/microsoft/opentelemetry-azure-monitor-python/pull/92)) + +## 0.3b.0 +Released 2020-05-19 + +- Implement max size logic for local storage + ([#74](https://github.com/microsoft/opentelemetry-azure-monitor-python/pull/74)) +- Remove label sets + add is_remote to spancontext + ([#75](https://github.com/microsoft/opentelemetry-azure-monitor-python/pull/75)) +- Adding live metrics manager + ([#78](https://github.com/microsoft/opentelemetry-azure-monitor-python/pull/78)) +- Handle status 439 - Too Many Requests over extended time + ([#80](https://github.com/microsoft/opentelemetry-azure-monitor-python/pull/80)) +- Fix breaking changes from OT release 0.7b.0 + ([#86](https://github.com/microsoft/opentelemetry-azure-monitor-python/pull/86)) + +## 0.2b.0 +Released 2020-03-31 + +- Initial beta release + +## 0.1a.0 +Released 2019-11-06 + +- Initial alpha release \ No newline at end of file diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/LICENSE.txt b/sdk/monitor/opentelemetry-exporter-azuremonitor/LICENSE.txt new file mode 100644 index 000000000000..05b0ebf5bc76 --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Microsoft Corporation. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/MANIFEST.in b/sdk/monitor/opentelemetry-exporter-azuremonitor/MANIFEST.in new file mode 100644 index 000000000000..252a3fcdbac5 --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/MANIFEST.in @@ -0,0 +1,6 @@ +include *.md +include opentelemetry/__init__.py +include opentelemetry/exporter/__init__.py +include LICENSE.txt +recursive-include tests *.py +recursive-include samples *.py *.md \ No newline at end of file diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/README.md b/sdk/monitor/opentelemetry-exporter-azuremonitor/README.md new file mode 100644 index 000000000000..81bb27c7b27e --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/README.md @@ -0,0 +1,13 @@ +# Azure Opentelemetry Exporter for Monitor + +## Getting started + +## Key concepts + +## Examples + +## Troubleshooting + +## Next steps + +## Contributing diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/dev_requirements.txt b/sdk/monitor/opentelemetry-exporter-azuremonitor/dev_requirements.txt new file mode 100644 index 000000000000..78ec05d4a43a --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/dev_requirements.txt @@ -0,0 +1,6 @@ +-e ../../../tools/azure-devtools +-e ../../../tools/azure-sdk-tools +../../core/azure-core +-e ../../identity/azure-identity +aiohttp>=3.0; python_version >= '3.5' + diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/mypy.ini b/sdk/monitor/opentelemetry-exporter-azuremonitor/mypy.ini new file mode 100644 index 000000000000..370a4abcd082 --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/mypy.ini @@ -0,0 +1,14 @@ +[mypy] +python_version = 3.6 +warn_return_any = True +warn_unused_configs = True +ignore_missing_imports = True + +# Per-module options: + +[mypy-opentelemetry.exporter.azuremonitor._generated.*] +ignore_errors = True + +[mypy-azure.core.*] +ignore_errors = True + diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/__init__.py b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/__init__.py new file mode 100644 index 000000000000..69e3be50dac4 --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/__init__.py b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/__init__.py new file mode 100644 index 000000000000..69e3be50dac4 --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/__init__.py b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/__init__.py new file mode 100644 index 000000000000..2e5e1443b729 --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/__init__.py @@ -0,0 +1,11 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- + +from ._generated._azure_monitor_exporter import AzureMonitorExporter +from ._version import VERSION + +__all__ = ['AzureMonitorExporter'] +__version__ = VERSION diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/__init__.py b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/__init__.py new file mode 100644 index 000000000000..cb5939a2b6f2 --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/__init__.py @@ -0,0 +1,16 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._azure_monitor_exporter import AzureMonitorExporter +__all__ = ['AzureMonitorExporter'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/_azure_monitor_exporter.py b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/_azure_monitor_exporter.py new file mode 100644 index 000000000000..e2a9a0ccf055 --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/_azure_monitor_exporter.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.core import PipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +from ._configuration import AzureMonitorExporterConfiguration +from .operations import AzureMonitorExporterOperationsMixin +from . import models + + +class AzureMonitorExporter(AzureMonitorExporterOperationsMixin): + """Opentelemetry Exporter for Azure Monitor. + + :param host: Breeze endpoint: https://dc.services.visualstudio.com. + :type host: str + """ + + def __init__( + self, + host="https://dc.services.visualstudio.com", # type: str + **kwargs # type: Any + ): + # type: (...) -> None + base_url = '{Host}/v2' + self._config = AzureMonitorExporterConfiguration(host, **kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AzureMonitorExporter + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/_configuration.py b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/_configuration.py new file mode 100644 index 000000000000..9b43c4dcf865 --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/_configuration.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +VERSION = "unknown" + +class AzureMonitorExporterConfiguration(Configuration): + """Configuration for AzureMonitorExporter. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param host: Breeze endpoint: https://dc.services.visualstudio.com. + :type host: str + """ + + def __init__( + self, + host="https://dc.services.visualstudio.com", # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if host is None: + raise ValueError("Parameter 'host' must not be None.") + super(AzureMonitorExporterConfiguration, self).__init__(**kwargs) + + self.host = host + kwargs.setdefault('sdk_moniker', 'azuremonitorexporter/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/aio/__init__.py b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/aio/__init__.py new file mode 100644 index 000000000000..3a91b03769f3 --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._azure_monitor_exporter_async import AzureMonitorExporter +__all__ = ['AzureMonitorExporter'] diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/aio/_azure_monitor_exporter_async.py b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/aio/_azure_monitor_exporter_async.py new file mode 100644 index 000000000000..8d210078816c --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/aio/_azure_monitor_exporter_async.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core import AsyncPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import AzureMonitorExporterConfiguration +from .operations_async import AzureMonitorExporterOperationsMixin +from .. import models + + +class AzureMonitorExporter(AzureMonitorExporterOperationsMixin): + """Opentelemetry Exporter for Azure Monitor. + + :param host: Breeze endpoint: https://dc.services.visualstudio.com. + :type host: str + """ + + def __init__( + self, + host: str = "https://dc.services.visualstudio.com", + **kwargs: Any + ) -> None: + base_url = '{Host}/v2' + self._config = AzureMonitorExporterConfiguration(host, **kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AzureMonitorExporter": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/aio/_configuration_async.py b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/aio/_configuration_async.py new file mode 100644 index 000000000000..311e90039666 --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/aio/_configuration_async.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +VERSION = "unknown" + +class AzureMonitorExporterConfiguration(Configuration): + """Configuration for AzureMonitorExporter. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param host: Breeze endpoint: https://dc.services.visualstudio.com. + :type host: str + """ + + def __init__( + self, + host: str = "https://dc.services.visualstudio.com", + **kwargs: Any + ) -> None: + if host is None: + raise ValueError("Parameter 'host' must not be None.") + super(AzureMonitorExporterConfiguration, self).__init__(**kwargs) + + self.host = host + kwargs.setdefault('sdk_moniker', 'azuremonitorexporter/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/aio/operations_async/__init__.py b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/aio/operations_async/__init__.py new file mode 100644 index 000000000000..17277d4a90a0 --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/aio/operations_async/__init__.py @@ -0,0 +1,13 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._azure_monitor_exporter_operations_async import AzureMonitorExporterOperationsMixin + +__all__ = [ + 'AzureMonitorExporterOperationsMixin', +] diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/aio/operations_async/_azure_monitor_exporter_operations_async.py b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/aio/operations_async/_azure_monitor_exporter_operations_async.py new file mode 100644 index 000000000000..807ae9bd4b19 --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/aio/operations_async/_azure_monitor_exporter_operations_async.py @@ -0,0 +1,88 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AzureMonitorExporterOperationsMixin: + + async def track( + self, + body: List["models.TelemetryItem"], + **kwargs + ) -> "models.TrackResponse": + """Track telemetry events. + + This operation sends a sequence of telemetry events that will be monitored by Azure Monitor. + + :param body: The list of telemetry events to track. + :type body: list[~azure_monitor_exporter.models.TelemetryItem] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TrackResponse, or the result of cls(response) + :rtype: ~azure_monitor_exporter.models.TrackResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TrackResponse"] + error_map = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(models.TrackResponse, response)), + 402: lambda response: HttpResponseError(response=response, model=self._deserialize(models.TrackResponse, response)), + 429: lambda response: HttpResponseError(response=response, model=self._deserialize(models.TrackResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(models.TrackResponse, response)), + 503: lambda response: HttpResponseError(response=response, model=self._deserialize(models.TrackResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.track.metadata['url'] # type: ignore + path_format_arguments = { + 'Host': self._serialize.url("self._config.host", self._config.host, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, '[TelemetryItem]') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 206]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.status_code == 200: + deserialized = self._deserialize('TrackResponse', pipeline_response) + + if response.status_code == 206: + deserialized = self._deserialize('TrackResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + track.metadata = {'url': '/track'} # type: ignore diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/models/__init__.py b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/models/__init__.py new file mode 100644 index 000000000000..e9bc207a05d0 --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/models/__init__.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import AvailabilityData + from ._models_py3 import MessageData + from ._models_py3 import MetricDataPoint + from ._models_py3 import MetricsData + from ._models_py3 import MonitorBase + from ._models_py3 import MonitorDomain + from ._models_py3 import PageViewData + from ._models_py3 import PageViewPerfData + from ._models_py3 import RemoteDependencyData + from ._models_py3 import RequestData + from ._models_py3 import StackFrame + from ._models_py3 import TelemetryErrorDetails + from ._models_py3 import TelemetryEventData + from ._models_py3 import TelemetryExceptionData + from ._models_py3 import TelemetryExceptionDetails + from ._models_py3 import TelemetryItem + from ._models_py3 import TrackResponse +except (SyntaxError, ImportError): + from ._models import AvailabilityData # type: ignore + from ._models import MessageData # type: ignore + from ._models import MetricDataPoint # type: ignore + from ._models import MetricsData # type: ignore + from ._models import MonitorBase # type: ignore + from ._models import MonitorDomain # type: ignore + from ._models import PageViewData # type: ignore + from ._models import PageViewPerfData # type: ignore + from ._models import RemoteDependencyData # type: ignore + from ._models import RequestData # type: ignore + from ._models import StackFrame # type: ignore + from ._models import TelemetryErrorDetails # type: ignore + from ._models import TelemetryEventData # type: ignore + from ._models import TelemetryExceptionData # type: ignore + from ._models import TelemetryExceptionDetails # type: ignore + from ._models import TelemetryItem # type: ignore + from ._models import TrackResponse # type: ignore + +from ._azure_monitor_exporter_enums import ( + ContextTagKeys, + DataPointType, + SeverityLevel, +) + +__all__ = [ + 'AvailabilityData', + 'MessageData', + 'MetricDataPoint', + 'MetricsData', + 'MonitorBase', + 'MonitorDomain', + 'PageViewData', + 'PageViewPerfData', + 'RemoteDependencyData', + 'RequestData', + 'StackFrame', + 'TelemetryErrorDetails', + 'TelemetryEventData', + 'TelemetryExceptionData', + 'TelemetryExceptionDetails', + 'TelemetryItem', + 'TrackResponse', + 'ContextTagKeys', + 'DataPointType', + 'SeverityLevel', +] diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/models/_azure_monitor_exporter_enums.py b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/models/_azure_monitor_exporter_enums.py new file mode 100644 index 000000000000..5c2ea1504d0a --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/models/_azure_monitor_exporter_enums.py @@ -0,0 +1,77 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class ContextTagKeys(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The context tag keys. + """ + + AI_APPLICATION_VER = "ai.application.ver" + AI_DEVICE_ID = "ai.device.id" + AI_DEVICE_LOCALE = "ai.device.locale" + AI_DEVICE_MODEL = "ai.device.model" + AI_DEVICE_OEM_NAME = "ai.device.oemName" + AI_DEVICE_OS_VERSION = "ai.device.osVersion" + AI_DEVICE_TYPE = "ai.device.type" + AI_LOCATION_IP = "ai.location.ip" + AI_LOCATION_COUNTRY = "ai.location.country" + AI_LOCATION_PROVINCE = "ai.location.province" + AI_LOCATION_CITY = "ai.location.city" + AI_OPERATION_ID = "ai.operation.id" + AI_OPERATION_NAME = "ai.operation.name" + AI_OPERATION_PARENT_ID = "ai.operation.parentId" + AI_OPERATION_SYNTHETIC_SOURCE = "ai.operation.syntheticSource" + AI_OPERATION_CORRELATION_VECTOR = "ai.operation.correlationVector" + AI_SESSION_ID = "ai.session.id" + AI_SESSION_IS_FIRST = "ai.session.isFirst" + AI_USER_ACCOUNT_ID = "ai.user.accountId" + AI_USER_ID = "ai.user.id" + AI_USER_AUTH_USER_ID = "ai.user.authUserId" + AI_CLOUD_ROLE = "ai.cloud.role" + AI_CLOUD_ROLE_VER = "ai.cloud.roleVer" + AI_CLOUD_ROLE_INSTANCE = "ai.cloud.roleInstance" + AI_CLOUD_LOCATION = "ai.cloud.location" + AI_INTERNAL_SDK_VERSION = "ai.internal.sdkVersion" + AI_INTERNAL_AGENT_VERSION = "ai.internal.agentVersion" + AI_INTERNAL_NODE_NAME = "ai.internal.nodeName" + +class DataPointType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Type of the metric data measurement. + """ + + MEASUREMENT = "Measurement" + AGGREGATION = "Aggregation" + +class SeverityLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Defines the level of severity for the event. + """ + + VERBOSE = "Verbose" + INFORMATION = "Information" + WARNING = "Warning" + ERROR = "Error" + CRITICAL = "Critical" diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/models/_models.py b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/models/_models.py new file mode 100644 index 000000000000..0039965ccf93 --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/models/_models.py @@ -0,0 +1,851 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class MonitorDomain(msrest.serialization.Model): + """The abstract common base of all domains. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Schema version. + :type version: int + """ + + _validation = { + 'version': {'required': True}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + } + + def __init__( + self, + **kwargs + ): + super(MonitorDomain, self).__init__(**kwargs) + self.version = kwargs.get('version', 2) + + +class AvailabilityData(MonitorDomain): + """Instances of AvailabilityData represent the result of executing an availability test. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Schema version. + :type version: int + :param id: Required. Identifier of a test run. Use it to correlate steps of test run and + telemetry generated by the service. + :type id: str + :param name: Required. Name of the test that these availability results represent. + :type name: str + :param duration: Required. Duration in format: DD.HH:MM:SS.MMMMMM. Must be less than 1000 days. + :type duration: str + :param success: Required. Success flag. + :type success: bool + :param run_location: Name of the location where the test was run from. + :type run_location: str + :param message: Diagnostic message for the result. + :type message: str + :param properties: Collection of custom properties. + :type properties: dict[str, str] + :param measurements: Collection of custom measurements. + :type measurements: dict[str, float] + """ + + _validation = { + 'version': {'required': True}, + 'id': {'required': True, 'max_length': 512, 'min_length': 0}, + 'name': {'required': True, 'max_length': 1024, 'min_length': 0}, + 'duration': {'required': True}, + 'success': {'required': True}, + 'run_location': {'max_length': 1024, 'min_length': 0}, + 'message': {'max_length': 8192, 'min_length': 0}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'duration': {'key': 'duration', 'type': 'str'}, + 'success': {'key': 'success', 'type': 'bool'}, + 'run_location': {'key': 'runLocation', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + 'measurements': {'key': 'measurements', 'type': '{float}'}, + } + + def __init__( + self, + **kwargs + ): + super(AvailabilityData, self).__init__(**kwargs) + self.id = kwargs['id'] + self.name = kwargs['name'] + self.duration = kwargs['duration'] + self.success = kwargs['success'] + self.run_location = kwargs.get('run_location', None) + self.message = kwargs.get('message', None) + self.properties = kwargs.get('properties', None) + self.measurements = kwargs.get('measurements', None) + + +class MessageData(MonitorDomain): + """Instances of Message represent printf-like trace statements that are text-searched. Log4Net, NLog and other text-based log file entries are translated into instances of this type. The message does not have measurements. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Schema version. + :type version: int + :param message: Required. Trace message. + :type message: str + :param severity_level: Trace severity level. Possible values include: "Verbose", "Information", + "Warning", "Error", "Critical". + :type severity_level: str or ~azure_monitor_exporter.models.SeverityLevel + :param properties: Collection of custom properties. + :type properties: dict[str, str] + :param measurements: Collection of custom measurements. + :type measurements: dict[str, float] + """ + + _validation = { + 'version': {'required': True}, + 'message': {'required': True, 'max_length': 32768, 'min_length': 0}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + 'message': {'key': 'message', 'type': 'str'}, + 'severity_level': {'key': 'severityLevel', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + 'measurements': {'key': 'measurements', 'type': '{float}'}, + } + + def __init__( + self, + **kwargs + ): + super(MessageData, self).__init__(**kwargs) + self.message = kwargs['message'] + self.severity_level = kwargs.get('severity_level', None) + self.properties = kwargs.get('properties', None) + self.measurements = kwargs.get('measurements', None) + + +class MetricDataPoint(msrest.serialization.Model): + """Metric data single measurement. + + All required parameters must be populated in order to send to Azure. + + :param namespace: Namespace of the metric. + :type namespace: str + :param name: Required. Name of the metric. + :type name: str + :param data_point_type: Metric type. Single measurement or the aggregated value. Possible + values include: "Measurement", "Aggregation". + :type data_point_type: str or ~azure_monitor_exporter.models.DataPointType + :param value: Required. Single value for measurement. Sum of individual measurements for the + aggregation. + :type value: float + :param count: Metric weight of the aggregated metric. Should not be set for a measurement. + :type count: int + :param min: Minimum value of the aggregated metric. Should not be set for a measurement. + :type min: float + :param max: Maximum value of the aggregated metric. Should not be set for a measurement. + :type max: float + :param std_dev: Standard deviation of the aggregated metric. Should not be set for a + measurement. + :type std_dev: float + """ + + _validation = { + 'namespace': {'max_length': 256, 'min_length': 0}, + 'name': {'required': True, 'max_length': 1024, 'min_length': 0}, + 'value': {'required': True}, + } + + _attribute_map = { + 'namespace': {'key': 'ns', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'data_point_type': {'key': 'kind', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'float'}, + 'count': {'key': 'count', 'type': 'int'}, + 'min': {'key': 'min', 'type': 'float'}, + 'max': {'key': 'max', 'type': 'float'}, + 'std_dev': {'key': 'stdDev', 'type': 'float'}, + } + + def __init__( + self, + **kwargs + ): + super(MetricDataPoint, self).__init__(**kwargs) + self.namespace = kwargs.get('namespace', None) + self.name = kwargs['name'] + self.data_point_type = kwargs.get('data_point_type', None) + self.value = kwargs['value'] + self.count = kwargs.get('count', None) + self.min = kwargs.get('min', None) + self.max = kwargs.get('max', None) + self.std_dev = kwargs.get('std_dev', None) + + +class MetricsData(MonitorDomain): + """An instance of the Metric item is a list of measurements (single data points) and/or aggregations. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Schema version. + :type version: int + :param metrics: Required. List of metrics. Only one metric in the list is currently supported + by Application Insights storage. If multiple data points were sent only the first one will be + used. + :type metrics: list[~azure_monitor_exporter.models.MetricDataPoint] + :param properties: Collection of custom properties. + :type properties: dict[str, str] + """ + + _validation = { + 'version': {'required': True}, + 'metrics': {'required': True}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + 'metrics': {'key': 'metrics', 'type': '[MetricDataPoint]'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(MetricsData, self).__init__(**kwargs) + self.metrics = kwargs['metrics'] + self.properties = kwargs.get('properties', None) + + +class MonitorBase(msrest.serialization.Model): + """Data struct to contain only C section with custom fields. + + :param base_type: Name of item (B section) if any. If telemetry data is derived straight from + this, this should be null. + :type base_type: str + :param base_data: The data payload for the telemetry request. + :type base_data: ~azure_monitor_exporter.models.MonitorDomain + """ + + _attribute_map = { + 'base_type': {'key': 'baseType', 'type': 'str'}, + 'base_data': {'key': 'baseData', 'type': 'MonitorDomain'}, + } + + def __init__( + self, + **kwargs + ): + super(MonitorBase, self).__init__(**kwargs) + self.base_type = kwargs.get('base_type', None) + self.base_data = kwargs.get('base_data', None) + + +class PageViewData(MonitorDomain): + """An instance of PageView represents a generic action on a page like a button click. It is also the base type for PageView. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Schema version. + :type version: int + :param id: Required. Identifier of a page view instance. Used for correlation between page view + and other telemetry items. + :type id: str + :param name: Required. Event name. Keep it low cardinality to allow proper grouping and useful + metrics. + :type name: str + :param url: Request URL with all query string parameters. + :type url: str + :param duration: Request duration in format: DD.HH:MM:SS.MMMMMM. For a page view + (PageViewData), this is the duration. For a page view with performance information + (PageViewPerfData), this is the page load time. Must be less than 1000 days. + :type duration: str + :param referred_uri: Fully qualified page URI or URL of the referring page; if unknown, leave + blank. + :type referred_uri: str + :param properties: Collection of custom properties. + :type properties: dict[str, str] + :param measurements: Collection of custom measurements. + :type measurements: dict[str, float] + """ + + _validation = { + 'version': {'required': True}, + 'id': {'required': True, 'max_length': 512, 'min_length': 0}, + 'name': {'required': True, 'max_length': 1024, 'min_length': 0}, + 'url': {'max_length': 2048, 'min_length': 0}, + 'referred_uri': {'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'url': {'key': 'url', 'type': 'str'}, + 'duration': {'key': 'duration', 'type': 'str'}, + 'referred_uri': {'key': 'referredUri', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + 'measurements': {'key': 'measurements', 'type': '{float}'}, + } + + def __init__( + self, + **kwargs + ): + super(PageViewData, self).__init__(**kwargs) + self.id = kwargs['id'] + self.name = kwargs['name'] + self.url = kwargs.get('url', None) + self.duration = kwargs.get('duration', None) + self.referred_uri = kwargs.get('referred_uri', None) + self.properties = kwargs.get('properties', None) + self.measurements = kwargs.get('measurements', None) + + +class PageViewPerfData(MonitorDomain): + """An instance of PageViewPerf represents: a page view with no performance data, a page view with performance data, or just the performance data of an earlier page request. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Schema version. + :type version: int + :param id: Required. Identifier of a page view instance. Used for correlation between page view + and other telemetry items. + :type id: str + :param name: Required. Event name. Keep it low cardinality to allow proper grouping and useful + metrics. + :type name: str + :param url: Request URL with all query string parameters. + :type url: str + :param duration: Request duration in format: DD.HH:MM:SS.MMMMMM. For a page view + (PageViewData), this is the duration. For a page view with performance information + (PageViewPerfData), this is the page load time. Must be less than 1000 days. + :type duration: str + :param perf_total: Performance total in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff. + :type perf_total: str + :param network_connect: Network connection time in TimeSpan 'G' (general long) format: + d:hh:mm:ss.fffffff. + :type network_connect: str + :param sent_request: Sent request time in TimeSpan 'G' (general long) format: + d:hh:mm:ss.fffffff. + :type sent_request: str + :param received_response: Received response time in TimeSpan 'G' (general long) format: + d:hh:mm:ss.fffffff. + :type received_response: str + :param dom_processing: DOM processing time in TimeSpan 'G' (general long) format: + d:hh:mm:ss.fffffff. + :type dom_processing: str + :param properties: Collection of custom properties. + :type properties: dict[str, str] + :param measurements: Collection of custom measurements. + :type measurements: dict[str, float] + """ + + _validation = { + 'version': {'required': True}, + 'id': {'required': True, 'max_length': 512, 'min_length': 0}, + 'name': {'required': True, 'max_length': 1024, 'min_length': 0}, + 'url': {'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'url': {'key': 'url', 'type': 'str'}, + 'duration': {'key': 'duration', 'type': 'str'}, + 'perf_total': {'key': 'perfTotal', 'type': 'str'}, + 'network_connect': {'key': 'networkConnect', 'type': 'str'}, + 'sent_request': {'key': 'sentRequest', 'type': 'str'}, + 'received_response': {'key': 'receivedResponse', 'type': 'str'}, + 'dom_processing': {'key': 'domProcessing', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + 'measurements': {'key': 'measurements', 'type': '{float}'}, + } + + def __init__( + self, + **kwargs + ): + super(PageViewPerfData, self).__init__(**kwargs) + self.id = kwargs['id'] + self.name = kwargs['name'] + self.url = kwargs.get('url', None) + self.duration = kwargs.get('duration', None) + self.perf_total = kwargs.get('perf_total', None) + self.network_connect = kwargs.get('network_connect', None) + self.sent_request = kwargs.get('sent_request', None) + self.received_response = kwargs.get('received_response', None) + self.dom_processing = kwargs.get('dom_processing', None) + self.properties = kwargs.get('properties', None) + self.measurements = kwargs.get('measurements', None) + + +class RemoteDependencyData(MonitorDomain): + """An instance of Remote Dependency represents an interaction of the monitored component with a remote component/service like SQL or an HTTP endpoint. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Schema version. + :type version: int + :param id: Identifier of a dependency call instance. Used for correlation with the request + telemetry item corresponding to this dependency call. + :type id: str + :param name: Required. Name of the command initiated with this dependency call. Low cardinality + value. Examples are stored procedure name and URL path template. + :type name: str + :param result_code: Result code of a dependency call. Examples are SQL error code and HTTP + status code. + :type result_code: str + :param data: Command initiated by this dependency call. Examples are SQL statement and HTTP URL + with all query parameters. + :type data: str + :param type: Dependency type name. Very low cardinality value for logical grouping of + dependencies and interpretation of other fields like commandName and resultCode. Examples are + SQL, Azure table, and HTTP. + :type type: str + :param target: Target site of a dependency call. Examples are server name, host address. + :type target: str + :param duration: Required. Request duration in format: DD.HH:MM:SS.MMMMMM. Must be less than + 1000 days. + :type duration: str + :param success: Indication of successful or unsuccessful call. + :type success: bool + :param properties: Collection of custom properties. + :type properties: dict[str, str] + :param measurements: Collection of custom measurements. + :type measurements: dict[str, float] + """ + + _validation = { + 'version': {'required': True}, + 'id': {'max_length': 512, 'min_length': 0}, + 'name': {'required': True, 'max_length': 1024, 'min_length': 0}, + 'result_code': {'max_length': 1024, 'min_length': 0}, + 'data': {'max_length': 8192, 'min_length': 0}, + 'type': {'max_length': 1024, 'min_length': 0}, + 'target': {'max_length': 1024, 'min_length': 0}, + 'duration': {'required': True}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'result_code': {'key': 'resultCode', 'type': 'str'}, + 'data': {'key': 'data', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'duration': {'key': 'duration', 'type': 'str'}, + 'success': {'key': 'success', 'type': 'bool'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + 'measurements': {'key': 'measurements', 'type': '{float}'}, + } + + def __init__( + self, + **kwargs + ): + super(RemoteDependencyData, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.name = kwargs['name'] + self.result_code = kwargs.get('result_code', None) + self.data = kwargs.get('data', None) + self.type = kwargs.get('type', None) + self.target = kwargs.get('target', None) + self.duration = kwargs['duration'] + self.success = kwargs.get('success', True) + self.properties = kwargs.get('properties', None) + self.measurements = kwargs.get('measurements', None) + + +class RequestData(MonitorDomain): + """An instance of Request represents completion of an external request to the application to do work and contains a summary of that request execution and the results. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Schema version. + :type version: int + :param id: Required. Identifier of a request call instance. Used for correlation between + request and other telemetry items. + :type id: str + :param name: Name of the request. Represents code path taken to process request. Low + cardinality value to allow better grouping of requests. For HTTP requests it represents the + HTTP method and URL path template like 'GET /values/{id}'. + :type name: str + :param duration: Required. Request duration in format: DD.HH:MM:SS.MMMMMM. Must be less than + 1000 days. + :type duration: str + :param success: Required. Indication of successful or unsuccessful call. + :type success: bool + :param response_code: Required. Result of a request execution. HTTP status code for HTTP + requests. + :type response_code: str + :param source: Source of the request. Examples are the instrumentation key of the caller or the + ip address of the caller. + :type source: str + :param url: Request URL with all query string parameters. + :type url: str + :param properties: Collection of custom properties. + :type properties: dict[str, str] + :param measurements: Collection of custom measurements. + :type measurements: dict[str, float] + """ + + _validation = { + 'version': {'required': True}, + 'id': {'required': True, 'max_length': 512, 'min_length': 0}, + 'name': {'max_length': 1024, 'min_length': 0}, + 'duration': {'required': True}, + 'success': {'required': True}, + 'response_code': {'required': True, 'max_length': 1024, 'min_length': 0}, + 'source': {'max_length': 1024, 'min_length': 0}, + 'url': {'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'duration': {'key': 'duration', 'type': 'str'}, + 'success': {'key': 'success', 'type': 'bool'}, + 'response_code': {'key': 'responseCode', 'type': 'str'}, + 'source': {'key': 'source', 'type': 'str'}, + 'url': {'key': 'url', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + 'measurements': {'key': 'measurements', 'type': '{float}'}, + } + + def __init__( + self, + **kwargs + ): + super(RequestData, self).__init__(**kwargs) + self.id = kwargs['id'] + self.name = kwargs.get('name', None) + self.duration = kwargs['duration'] + self.success = kwargs.get('success', True) + self.response_code = kwargs['response_code'] + self.source = kwargs.get('source', None) + self.url = kwargs.get('url', None) + self.properties = kwargs.get('properties', None) + self.measurements = kwargs.get('measurements', None) + + +class StackFrame(msrest.serialization.Model): + """Stack frame information. + + All required parameters must be populated in order to send to Azure. + + :param level: Required. + :type level: int + :param method: Required. Method name. + :type method: str + :param assembly: Name of the assembly (dll, jar, etc.) containing this function. + :type assembly: str + :param file_name: File name or URL of the method implementation. + :type file_name: str + :param line: Line number of the code implementation. + :type line: int + """ + + _validation = { + 'level': {'required': True}, + 'method': {'required': True, 'max_length': 1024, 'min_length': 0}, + 'assembly': {'max_length': 1024, 'min_length': 0}, + 'file_name': {'max_length': 1024, 'min_length': 0}, + } + + _attribute_map = { + 'level': {'key': 'level', 'type': 'int'}, + 'method': {'key': 'method', 'type': 'str'}, + 'assembly': {'key': 'assembly', 'type': 'str'}, + 'file_name': {'key': 'fileName', 'type': 'str'}, + 'line': {'key': 'line', 'type': 'int'}, + } + + def __init__( + self, + **kwargs + ): + super(StackFrame, self).__init__(**kwargs) + self.level = kwargs['level'] + self.method = kwargs['method'] + self.assembly = kwargs.get('assembly', None) + self.file_name = kwargs.get('file_name', None) + self.line = kwargs.get('line', None) + + +class TelemetryErrorDetails(msrest.serialization.Model): + """The error details. + + :param index: The index in the original payload of the item. + :type index: int + :param status_code: The item specific `HTTP Response status code <#Response Status Codes>`_. + :type status_code: int + :param message: The error message. + :type message: str + """ + + _attribute_map = { + 'index': {'key': 'index', 'type': 'int'}, + 'status_code': {'key': 'statusCode', 'type': 'int'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TelemetryErrorDetails, self).__init__(**kwargs) + self.index = kwargs.get('index', None) + self.status_code = kwargs.get('status_code', None) + self.message = kwargs.get('message', None) + + +class TelemetryEventData(MonitorDomain): + """Instances of Event represent structured event records that can be grouped and searched by their properties. Event data item also creates a metric of event count by name. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Schema version. + :type version: int + :param name: Required. Event name. Keep it low cardinality to allow proper grouping and useful + metrics. + :type name: str + :param properties: Collection of custom properties. + :type properties: dict[str, str] + :param measurements: Collection of custom measurements. + :type measurements: dict[str, float] + """ + + _validation = { + 'version': {'required': True}, + 'name': {'required': True, 'max_length': 512, 'min_length': 0}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + 'name': {'key': 'name', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + 'measurements': {'key': 'measurements', 'type': '{float}'}, + } + + def __init__( + self, + **kwargs + ): + super(TelemetryEventData, self).__init__(**kwargs) + self.name = kwargs['name'] + self.properties = kwargs.get('properties', None) + self.measurements = kwargs.get('measurements', None) + + +class TelemetryExceptionData(MonitorDomain): + """An instance of Exception represents a handled or unhandled exception that occurred during execution of the monitored application. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Schema version. + :type version: int + :param exceptions: Required. Exception chain - list of inner exceptions. + :type exceptions: list[~azure_monitor_exporter.models.TelemetryExceptionDetails] + :param severity_level: Severity level. Mostly used to indicate exception severity level when it + is reported by logging library. Possible values include: "Verbose", "Information", "Warning", + "Error", "Critical". + :type severity_level: str or ~azure_monitor_exporter.models.SeverityLevel + :param problem_id: Identifier of where the exception was thrown in code. Used for exceptions + grouping. Typically a combination of exception type and a function from the call stack. + :type problem_id: str + :param properties: Collection of custom properties. + :type properties: dict[str, str] + :param measurements: Collection of custom measurements. + :type measurements: dict[str, float] + """ + + _validation = { + 'version': {'required': True}, + 'exceptions': {'required': True}, + 'problem_id': {'max_length': 1024, 'min_length': 0}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + 'exceptions': {'key': 'exceptions', 'type': '[TelemetryExceptionDetails]'}, + 'severity_level': {'key': 'severityLevel', 'type': 'str'}, + 'problem_id': {'key': 'problemId', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + 'measurements': {'key': 'measurements', 'type': '{float}'}, + } + + def __init__( + self, + **kwargs + ): + super(TelemetryExceptionData, self).__init__(**kwargs) + self.exceptions = kwargs['exceptions'] + self.severity_level = kwargs.get('severity_level', None) + self.problem_id = kwargs.get('problem_id', None) + self.properties = kwargs.get('properties', None) + self.measurements = kwargs.get('measurements', None) + + +class TelemetryExceptionDetails(msrest.serialization.Model): + """Exception details of the exception in a chain. + + All required parameters must be populated in order to send to Azure. + + :param id: In case exception is nested (outer exception contains inner one), the id and outerId + properties are used to represent the nesting. + :type id: int + :param outer_id: The value of outerId is a reference to an element in ExceptionDetails that + represents the outer exception. + :type outer_id: int + :param type_name: Exception type name. + :type type_name: str + :param message: Required. Exception message. + :type message: str + :param has_full_stack: Indicates if full exception stack is provided in the exception. The + stack may be trimmed, such as in the case of a StackOverflow exception. + :type has_full_stack: bool + :param stack: Text describing the stack. Either stack or parsedStack should have a value. + :type stack: str + :param parsed_stack: List of stack frames. Either stack or parsedStack should have a value. + :type parsed_stack: list[~azure_monitor_exporter.models.StackFrame] + """ + + _validation = { + 'type_name': {'max_length': 1024, 'min_length': 0}, + 'message': {'required': True, 'max_length': 32768, 'min_length': 0}, + 'stack': {'max_length': 32768, 'min_length': 0}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'int'}, + 'outer_id': {'key': 'outerId', 'type': 'int'}, + 'type_name': {'key': 'typeName', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'has_full_stack': {'key': 'hasFullStack', 'type': 'bool'}, + 'stack': {'key': 'stack', 'type': 'str'}, + 'parsed_stack': {'key': 'parsedStack', 'type': '[StackFrame]'}, + } + + def __init__( + self, + **kwargs + ): + super(TelemetryExceptionDetails, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.outer_id = kwargs.get('outer_id', None) + self.type_name = kwargs.get('type_name', None) + self.message = kwargs['message'] + self.has_full_stack = kwargs.get('has_full_stack', True) + self.stack = kwargs.get('stack', None) + self.parsed_stack = kwargs.get('parsed_stack', None) + + +class TelemetryItem(msrest.serialization.Model): + """System variables for a telemetry item. + + All required parameters must be populated in order to send to Azure. + + :param version: Envelope version. For internal use only. By assigning this the default, it will + not be serialized within the payload unless changed to a value other than #1. + :type version: int + :param name: Required. Type name of telemetry data item. + :type name: str + :param time: Required. Event date time when telemetry item was created. This is the wall clock + time on the client when the event was generated. There is no guarantee that the client's time + is accurate. This field must be formatted in UTC ISO 8601 format, with a trailing 'Z' + character, as described publicly on https://en.wikipedia.org/wiki/ISO_8601#UTC. Note: the + number of decimal seconds digits provided are variable (and unspecified). Consumers should + handle this, i.e. managed code consumers should not use format 'O' for parsing as it specifies + a fixed length. Example: 2009-06-15T13:45:30.0000000Z. + :type time: str + :param sample_rate: Sampling rate used in application. This telemetry item represents 1 / + sampleRate actual telemetry items. + :type sample_rate: float + :param sequence: Sequence field used to track absolute order of uploaded events. + :type sequence: str + :param instrumentation_key: The instrumentation key of the Application Insights resource. + :type instrumentation_key: str + :param tags: A set of tags. Key/value collection of context properties. See ContextTagKeys for + information on available properties. + :type tags: dict[str, str] + :param data: Telemetry data item. + :type data: ~azure_monitor_exporter.models.MonitorBase + """ + + _validation = { + 'name': {'required': True}, + 'time': {'required': True}, + 'sequence': {'max_length': 64, 'min_length': 0}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + 'name': {'key': 'name', 'type': 'str'}, + 'time': {'key': 'time', 'type': 'str'}, + 'sample_rate': {'key': 'sampleRate', 'type': 'float'}, + 'sequence': {'key': 'seq', 'type': 'str'}, + 'instrumentation_key': {'key': 'iKey', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'data': {'key': 'data', 'type': 'MonitorBase'}, + } + + def __init__( + self, + **kwargs + ): + super(TelemetryItem, self).__init__(**kwargs) + self.version = kwargs.get('version', 1) + self.name = kwargs['name'] + self.time = kwargs['time'] + self.sample_rate = kwargs.get('sample_rate', 100) + self.sequence = kwargs.get('sequence', None) + self.instrumentation_key = kwargs.get('instrumentation_key', None) + self.tags = kwargs.get('tags', None) + self.data = kwargs.get('data', None) + + +class TrackResponse(msrest.serialization.Model): + """Response containing the status of each telemetry item. + + :param items_received: The number of items received. + :type items_received: int + :param items_accepted: The number of items accepted. + :type items_accepted: int + :param errors: An array of error detail objects. + :type errors: list[~azure_monitor_exporter.models.TelemetryErrorDetails] + """ + + _attribute_map = { + 'items_received': {'key': 'itemsReceived', 'type': 'int'}, + 'items_accepted': {'key': 'itemsAccepted', 'type': 'int'}, + 'errors': {'key': 'errors', 'type': '[TelemetryErrorDetails]'}, + } + + def __init__( + self, + **kwargs + ): + super(TrackResponse, self).__init__(**kwargs) + self.items_received = kwargs.get('items_received', None) + self.items_accepted = kwargs.get('items_accepted', None) + self.errors = kwargs.get('errors', None) diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/models/_models_py3.py b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/models/_models_py3.py new file mode 100644 index 000000000000..142384073a3e --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/models/_models_py3.py @@ -0,0 +1,977 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Dict, List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._azure_monitor_exporter_enums import * + + +class MonitorDomain(msrest.serialization.Model): + """The abstract common base of all domains. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Schema version. + :type version: int + """ + + _validation = { + 'version': {'required': True}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + } + + def __init__( + self, + *, + version: int = 2, + **kwargs + ): + super(MonitorDomain, self).__init__(**kwargs) + self.version = version + + +class AvailabilityData(MonitorDomain): + """Instances of AvailabilityData represent the result of executing an availability test. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Schema version. + :type version: int + :param id: Required. Identifier of a test run. Use it to correlate steps of test run and + telemetry generated by the service. + :type id: str + :param name: Required. Name of the test that these availability results represent. + :type name: str + :param duration: Required. Duration in format: DD.HH:MM:SS.MMMMMM. Must be less than 1000 days. + :type duration: str + :param success: Required. Success flag. + :type success: bool + :param run_location: Name of the location where the test was run from. + :type run_location: str + :param message: Diagnostic message for the result. + :type message: str + :param properties: Collection of custom properties. + :type properties: dict[str, str] + :param measurements: Collection of custom measurements. + :type measurements: dict[str, float] + """ + + _validation = { + 'version': {'required': True}, + 'id': {'required': True, 'max_length': 512, 'min_length': 0}, + 'name': {'required': True, 'max_length': 1024, 'min_length': 0}, + 'duration': {'required': True}, + 'success': {'required': True}, + 'run_location': {'max_length': 1024, 'min_length': 0}, + 'message': {'max_length': 8192, 'min_length': 0}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'duration': {'key': 'duration', 'type': 'str'}, + 'success': {'key': 'success', 'type': 'bool'}, + 'run_location': {'key': 'runLocation', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + 'measurements': {'key': 'measurements', 'type': '{float}'}, + } + + def __init__( + self, + *, + version: int = 2, + id: str, + name: str, + duration: str, + success: bool, + run_location: Optional[str] = None, + message: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + measurements: Optional[Dict[str, float]] = None, + **kwargs + ): + super(AvailabilityData, self).__init__(version=version, **kwargs) + self.id = id + self.name = name + self.duration = duration + self.success = success + self.run_location = run_location + self.message = message + self.properties = properties + self.measurements = measurements + + +class MessageData(MonitorDomain): + """Instances of Message represent printf-like trace statements that are text-searched. Log4Net, NLog and other text-based log file entries are translated into instances of this type. The message does not have measurements. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Schema version. + :type version: int + :param message: Required. Trace message. + :type message: str + :param severity_level: Trace severity level. Possible values include: "Verbose", "Information", + "Warning", "Error", "Critical". + :type severity_level: str or ~azure_monitor_exporter.models.SeverityLevel + :param properties: Collection of custom properties. + :type properties: dict[str, str] + :param measurements: Collection of custom measurements. + :type measurements: dict[str, float] + """ + + _validation = { + 'version': {'required': True}, + 'message': {'required': True, 'max_length': 32768, 'min_length': 0}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + 'message': {'key': 'message', 'type': 'str'}, + 'severity_level': {'key': 'severityLevel', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + 'measurements': {'key': 'measurements', 'type': '{float}'}, + } + + def __init__( + self, + *, + version: int = 2, + message: str, + severity_level: Optional[Union[str, "SeverityLevel"]] = None, + properties: Optional[Dict[str, str]] = None, + measurements: Optional[Dict[str, float]] = None, + **kwargs + ): + super(MessageData, self).__init__(version=version, **kwargs) + self.message = message + self.severity_level = severity_level + self.properties = properties + self.measurements = measurements + + +class MetricDataPoint(msrest.serialization.Model): + """Metric data single measurement. + + All required parameters must be populated in order to send to Azure. + + :param namespace: Namespace of the metric. + :type namespace: str + :param name: Required. Name of the metric. + :type name: str + :param data_point_type: Metric type. Single measurement or the aggregated value. Possible + values include: "Measurement", "Aggregation". + :type data_point_type: str or ~azure_monitor_exporter.models.DataPointType + :param value: Required. Single value for measurement. Sum of individual measurements for the + aggregation. + :type value: float + :param count: Metric weight of the aggregated metric. Should not be set for a measurement. + :type count: int + :param min: Minimum value of the aggregated metric. Should not be set for a measurement. + :type min: float + :param max: Maximum value of the aggregated metric. Should not be set for a measurement. + :type max: float + :param std_dev: Standard deviation of the aggregated metric. Should not be set for a + measurement. + :type std_dev: float + """ + + _validation = { + 'namespace': {'max_length': 256, 'min_length': 0}, + 'name': {'required': True, 'max_length': 1024, 'min_length': 0}, + 'value': {'required': True}, + } + + _attribute_map = { + 'namespace': {'key': 'ns', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'data_point_type': {'key': 'kind', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'float'}, + 'count': {'key': 'count', 'type': 'int'}, + 'min': {'key': 'min', 'type': 'float'}, + 'max': {'key': 'max', 'type': 'float'}, + 'std_dev': {'key': 'stdDev', 'type': 'float'}, + } + + def __init__( + self, + *, + name: str, + value: float, + namespace: Optional[str] = None, + data_point_type: Optional[Union[str, "DataPointType"]] = None, + count: Optional[int] = None, + min: Optional[float] = None, + max: Optional[float] = None, + std_dev: Optional[float] = None, + **kwargs + ): + super(MetricDataPoint, self).__init__(**kwargs) + self.namespace = namespace + self.name = name + self.data_point_type = data_point_type + self.value = value + self.count = count + self.min = min + self.max = max + self.std_dev = std_dev + + +class MetricsData(MonitorDomain): + """An instance of the Metric item is a list of measurements (single data points) and/or aggregations. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Schema version. + :type version: int + :param metrics: Required. List of metrics. Only one metric in the list is currently supported + by Application Insights storage. If multiple data points were sent only the first one will be + used. + :type metrics: list[~azure_monitor_exporter.models.MetricDataPoint] + :param properties: Collection of custom properties. + :type properties: dict[str, str] + """ + + _validation = { + 'version': {'required': True}, + 'metrics': {'required': True}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + 'metrics': {'key': 'metrics', 'type': '[MetricDataPoint]'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + } + + def __init__( + self, + *, + version: int = 2, + metrics: List["MetricDataPoint"], + properties: Optional[Dict[str, str]] = None, + **kwargs + ): + super(MetricsData, self).__init__(version=version, **kwargs) + self.metrics = metrics + self.properties = properties + + +class MonitorBase(msrest.serialization.Model): + """Data struct to contain only C section with custom fields. + + :param base_type: Name of item (B section) if any. If telemetry data is derived straight from + this, this should be null. + :type base_type: str + :param base_data: The data payload for the telemetry request. + :type base_data: ~azure_monitor_exporter.models.MonitorDomain + """ + + _attribute_map = { + 'base_type': {'key': 'baseType', 'type': 'str'}, + 'base_data': {'key': 'baseData', 'type': 'MonitorDomain'}, + } + + def __init__( + self, + *, + base_type: Optional[str] = None, + base_data: Optional["MonitorDomain"] = None, + **kwargs + ): + super(MonitorBase, self).__init__(**kwargs) + self.base_type = base_type + self.base_data = base_data + + +class PageViewData(MonitorDomain): + """An instance of PageView represents a generic action on a page like a button click. It is also the base type for PageView. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Schema version. + :type version: int + :param id: Required. Identifier of a page view instance. Used for correlation between page view + and other telemetry items. + :type id: str + :param name: Required. Event name. Keep it low cardinality to allow proper grouping and useful + metrics. + :type name: str + :param url: Request URL with all query string parameters. + :type url: str + :param duration: Request duration in format: DD.HH:MM:SS.MMMMMM. For a page view + (PageViewData), this is the duration. For a page view with performance information + (PageViewPerfData), this is the page load time. Must be less than 1000 days. + :type duration: str + :param referred_uri: Fully qualified page URI or URL of the referring page; if unknown, leave + blank. + :type referred_uri: str + :param properties: Collection of custom properties. + :type properties: dict[str, str] + :param measurements: Collection of custom measurements. + :type measurements: dict[str, float] + """ + + _validation = { + 'version': {'required': True}, + 'id': {'required': True, 'max_length': 512, 'min_length': 0}, + 'name': {'required': True, 'max_length': 1024, 'min_length': 0}, + 'url': {'max_length': 2048, 'min_length': 0}, + 'referred_uri': {'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'url': {'key': 'url', 'type': 'str'}, + 'duration': {'key': 'duration', 'type': 'str'}, + 'referred_uri': {'key': 'referredUri', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + 'measurements': {'key': 'measurements', 'type': '{float}'}, + } + + def __init__( + self, + *, + version: int = 2, + id: str, + name: str, + url: Optional[str] = None, + duration: Optional[str] = None, + referred_uri: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + measurements: Optional[Dict[str, float]] = None, + **kwargs + ): + super(PageViewData, self).__init__(version=version, **kwargs) + self.id = id + self.name = name + self.url = url + self.duration = duration + self.referred_uri = referred_uri + self.properties = properties + self.measurements = measurements + + +class PageViewPerfData(MonitorDomain): + """An instance of PageViewPerf represents: a page view with no performance data, a page view with performance data, or just the performance data of an earlier page request. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Schema version. + :type version: int + :param id: Required. Identifier of a page view instance. Used for correlation between page view + and other telemetry items. + :type id: str + :param name: Required. Event name. Keep it low cardinality to allow proper grouping and useful + metrics. + :type name: str + :param url: Request URL with all query string parameters. + :type url: str + :param duration: Request duration in format: DD.HH:MM:SS.MMMMMM. For a page view + (PageViewData), this is the duration. For a page view with performance information + (PageViewPerfData), this is the page load time. Must be less than 1000 days. + :type duration: str + :param perf_total: Performance total in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff. + :type perf_total: str + :param network_connect: Network connection time in TimeSpan 'G' (general long) format: + d:hh:mm:ss.fffffff. + :type network_connect: str + :param sent_request: Sent request time in TimeSpan 'G' (general long) format: + d:hh:mm:ss.fffffff. + :type sent_request: str + :param received_response: Received response time in TimeSpan 'G' (general long) format: + d:hh:mm:ss.fffffff. + :type received_response: str + :param dom_processing: DOM processing time in TimeSpan 'G' (general long) format: + d:hh:mm:ss.fffffff. + :type dom_processing: str + :param properties: Collection of custom properties. + :type properties: dict[str, str] + :param measurements: Collection of custom measurements. + :type measurements: dict[str, float] + """ + + _validation = { + 'version': {'required': True}, + 'id': {'required': True, 'max_length': 512, 'min_length': 0}, + 'name': {'required': True, 'max_length': 1024, 'min_length': 0}, + 'url': {'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'url': {'key': 'url', 'type': 'str'}, + 'duration': {'key': 'duration', 'type': 'str'}, + 'perf_total': {'key': 'perfTotal', 'type': 'str'}, + 'network_connect': {'key': 'networkConnect', 'type': 'str'}, + 'sent_request': {'key': 'sentRequest', 'type': 'str'}, + 'received_response': {'key': 'receivedResponse', 'type': 'str'}, + 'dom_processing': {'key': 'domProcessing', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + 'measurements': {'key': 'measurements', 'type': '{float}'}, + } + + def __init__( + self, + *, + version: int = 2, + id: str, + name: str, + url: Optional[str] = None, + duration: Optional[str] = None, + perf_total: Optional[str] = None, + network_connect: Optional[str] = None, + sent_request: Optional[str] = None, + received_response: Optional[str] = None, + dom_processing: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + measurements: Optional[Dict[str, float]] = None, + **kwargs + ): + super(PageViewPerfData, self).__init__(version=version, **kwargs) + self.id = id + self.name = name + self.url = url + self.duration = duration + self.perf_total = perf_total + self.network_connect = network_connect + self.sent_request = sent_request + self.received_response = received_response + self.dom_processing = dom_processing + self.properties = properties + self.measurements = measurements + + +class RemoteDependencyData(MonitorDomain): + """An instance of Remote Dependency represents an interaction of the monitored component with a remote component/service like SQL or an HTTP endpoint. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Schema version. + :type version: int + :param id: Identifier of a dependency call instance. Used for correlation with the request + telemetry item corresponding to this dependency call. + :type id: str + :param name: Required. Name of the command initiated with this dependency call. Low cardinality + value. Examples are stored procedure name and URL path template. + :type name: str + :param result_code: Result code of a dependency call. Examples are SQL error code and HTTP + status code. + :type result_code: str + :param data: Command initiated by this dependency call. Examples are SQL statement and HTTP URL + with all query parameters. + :type data: str + :param type: Dependency type name. Very low cardinality value for logical grouping of + dependencies and interpretation of other fields like commandName and resultCode. Examples are + SQL, Azure table, and HTTP. + :type type: str + :param target: Target site of a dependency call. Examples are server name, host address. + :type target: str + :param duration: Required. Request duration in format: DD.HH:MM:SS.MMMMMM. Must be less than + 1000 days. + :type duration: str + :param success: Indication of successful or unsuccessful call. + :type success: bool + :param properties: Collection of custom properties. + :type properties: dict[str, str] + :param measurements: Collection of custom measurements. + :type measurements: dict[str, float] + """ + + _validation = { + 'version': {'required': True}, + 'id': {'max_length': 512, 'min_length': 0}, + 'name': {'required': True, 'max_length': 1024, 'min_length': 0}, + 'result_code': {'max_length': 1024, 'min_length': 0}, + 'data': {'max_length': 8192, 'min_length': 0}, + 'type': {'max_length': 1024, 'min_length': 0}, + 'target': {'max_length': 1024, 'min_length': 0}, + 'duration': {'required': True}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'result_code': {'key': 'resultCode', 'type': 'str'}, + 'data': {'key': 'data', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'duration': {'key': 'duration', 'type': 'str'}, + 'success': {'key': 'success', 'type': 'bool'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + 'measurements': {'key': 'measurements', 'type': '{float}'}, + } + + def __init__( + self, + *, + version: int = 2, + name: str, + duration: str, + id: Optional[str] = None, + result_code: Optional[str] = None, + data: Optional[str] = None, + type: Optional[str] = None, + target: Optional[str] = None, + success: Optional[bool] = True, + properties: Optional[Dict[str, str]] = None, + measurements: Optional[Dict[str, float]] = None, + **kwargs + ): + super(RemoteDependencyData, self).__init__(version=version, **kwargs) + self.id = id + self.name = name + self.result_code = result_code + self.data = data + self.type = type + self.target = target + self.duration = duration + self.success = success + self.properties = properties + self.measurements = measurements + + +class RequestData(MonitorDomain): + """An instance of Request represents completion of an external request to the application to do work and contains a summary of that request execution and the results. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Schema version. + :type version: int + :param id: Required. Identifier of a request call instance. Used for correlation between + request and other telemetry items. + :type id: str + :param name: Name of the request. Represents code path taken to process request. Low + cardinality value to allow better grouping of requests. For HTTP requests it represents the + HTTP method and URL path template like 'GET /values/{id}'. + :type name: str + :param duration: Required. Request duration in format: DD.HH:MM:SS.MMMMMM. Must be less than + 1000 days. + :type duration: str + :param success: Required. Indication of successful or unsuccessful call. + :type success: bool + :param response_code: Required. Result of a request execution. HTTP status code for HTTP + requests. + :type response_code: str + :param source: Source of the request. Examples are the instrumentation key of the caller or the + ip address of the caller. + :type source: str + :param url: Request URL with all query string parameters. + :type url: str + :param properties: Collection of custom properties. + :type properties: dict[str, str] + :param measurements: Collection of custom measurements. + :type measurements: dict[str, float] + """ + + _validation = { + 'version': {'required': True}, + 'id': {'required': True, 'max_length': 512, 'min_length': 0}, + 'name': {'max_length': 1024, 'min_length': 0}, + 'duration': {'required': True}, + 'success': {'required': True}, + 'response_code': {'required': True, 'max_length': 1024, 'min_length': 0}, + 'source': {'max_length': 1024, 'min_length': 0}, + 'url': {'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'duration': {'key': 'duration', 'type': 'str'}, + 'success': {'key': 'success', 'type': 'bool'}, + 'response_code': {'key': 'responseCode', 'type': 'str'}, + 'source': {'key': 'source', 'type': 'str'}, + 'url': {'key': 'url', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + 'measurements': {'key': 'measurements', 'type': '{float}'}, + } + + def __init__( + self, + *, + version: int = 2, + id: str, + duration: str, + success: bool = True, + response_code: str, + name: Optional[str] = None, + source: Optional[str] = None, + url: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + measurements: Optional[Dict[str, float]] = None, + **kwargs + ): + super(RequestData, self).__init__(version=version, **kwargs) + self.id = id + self.name = name + self.duration = duration + self.success = success + self.response_code = response_code + self.source = source + self.url = url + self.properties = properties + self.measurements = measurements + + +class StackFrame(msrest.serialization.Model): + """Stack frame information. + + All required parameters must be populated in order to send to Azure. + + :param level: Required. + :type level: int + :param method: Required. Method name. + :type method: str + :param assembly: Name of the assembly (dll, jar, etc.) containing this function. + :type assembly: str + :param file_name: File name or URL of the method implementation. + :type file_name: str + :param line: Line number of the code implementation. + :type line: int + """ + + _validation = { + 'level': {'required': True}, + 'method': {'required': True, 'max_length': 1024, 'min_length': 0}, + 'assembly': {'max_length': 1024, 'min_length': 0}, + 'file_name': {'max_length': 1024, 'min_length': 0}, + } + + _attribute_map = { + 'level': {'key': 'level', 'type': 'int'}, + 'method': {'key': 'method', 'type': 'str'}, + 'assembly': {'key': 'assembly', 'type': 'str'}, + 'file_name': {'key': 'fileName', 'type': 'str'}, + 'line': {'key': 'line', 'type': 'int'}, + } + + def __init__( + self, + *, + level: int, + method: str, + assembly: Optional[str] = None, + file_name: Optional[str] = None, + line: Optional[int] = None, + **kwargs + ): + super(StackFrame, self).__init__(**kwargs) + self.level = level + self.method = method + self.assembly = assembly + self.file_name = file_name + self.line = line + + +class TelemetryErrorDetails(msrest.serialization.Model): + """The error details. + + :param index: The index in the original payload of the item. + :type index: int + :param status_code: The item specific `HTTP Response status code <#Response Status Codes>`_. + :type status_code: int + :param message: The error message. + :type message: str + """ + + _attribute_map = { + 'index': {'key': 'index', 'type': 'int'}, + 'status_code': {'key': 'statusCode', 'type': 'int'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + index: Optional[int] = None, + status_code: Optional[int] = None, + message: Optional[str] = None, + **kwargs + ): + super(TelemetryErrorDetails, self).__init__(**kwargs) + self.index = index + self.status_code = status_code + self.message = message + + +class TelemetryEventData(MonitorDomain): + """Instances of Event represent structured event records that can be grouped and searched by their properties. Event data item also creates a metric of event count by name. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Schema version. + :type version: int + :param name: Required. Event name. Keep it low cardinality to allow proper grouping and useful + metrics. + :type name: str + :param properties: Collection of custom properties. + :type properties: dict[str, str] + :param measurements: Collection of custom measurements. + :type measurements: dict[str, float] + """ + + _validation = { + 'version': {'required': True}, + 'name': {'required': True, 'max_length': 512, 'min_length': 0}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + 'name': {'key': 'name', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + 'measurements': {'key': 'measurements', 'type': '{float}'}, + } + + def __init__( + self, + *, + version: int = 2, + name: str, + properties: Optional[Dict[str, str]] = None, + measurements: Optional[Dict[str, float]] = None, + **kwargs + ): + super(TelemetryEventData, self).__init__(version=version, **kwargs) + self.name = name + self.properties = properties + self.measurements = measurements + + +class TelemetryExceptionData(MonitorDomain): + """An instance of Exception represents a handled or unhandled exception that occurred during execution of the monitored application. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Schema version. + :type version: int + :param exceptions: Required. Exception chain - list of inner exceptions. + :type exceptions: list[~azure_monitor_exporter.models.TelemetryExceptionDetails] + :param severity_level: Severity level. Mostly used to indicate exception severity level when it + is reported by logging library. Possible values include: "Verbose", "Information", "Warning", + "Error", "Critical". + :type severity_level: str or ~azure_monitor_exporter.models.SeverityLevel + :param problem_id: Identifier of where the exception was thrown in code. Used for exceptions + grouping. Typically a combination of exception type and a function from the call stack. + :type problem_id: str + :param properties: Collection of custom properties. + :type properties: dict[str, str] + :param measurements: Collection of custom measurements. + :type measurements: dict[str, float] + """ + + _validation = { + 'version': {'required': True}, + 'exceptions': {'required': True}, + 'problem_id': {'max_length': 1024, 'min_length': 0}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + 'exceptions': {'key': 'exceptions', 'type': '[TelemetryExceptionDetails]'}, + 'severity_level': {'key': 'severityLevel', 'type': 'str'}, + 'problem_id': {'key': 'problemId', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + 'measurements': {'key': 'measurements', 'type': '{float}'}, + } + + def __init__( + self, + *, + version: int = 2, + exceptions: List["TelemetryExceptionDetails"], + severity_level: Optional[Union[str, "SeverityLevel"]] = None, + problem_id: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + measurements: Optional[Dict[str, float]] = None, + **kwargs + ): + super(TelemetryExceptionData, self).__init__(version=version, **kwargs) + self.exceptions = exceptions + self.severity_level = severity_level + self.problem_id = problem_id + self.properties = properties + self.measurements = measurements + + +class TelemetryExceptionDetails(msrest.serialization.Model): + """Exception details of the exception in a chain. + + All required parameters must be populated in order to send to Azure. + + :param id: In case exception is nested (outer exception contains inner one), the id and outerId + properties are used to represent the nesting. + :type id: int + :param outer_id: The value of outerId is a reference to an element in ExceptionDetails that + represents the outer exception. + :type outer_id: int + :param type_name: Exception type name. + :type type_name: str + :param message: Required. Exception message. + :type message: str + :param has_full_stack: Indicates if full exception stack is provided in the exception. The + stack may be trimmed, such as in the case of a StackOverflow exception. + :type has_full_stack: bool + :param stack: Text describing the stack. Either stack or parsedStack should have a value. + :type stack: str + :param parsed_stack: List of stack frames. Either stack or parsedStack should have a value. + :type parsed_stack: list[~azure_monitor_exporter.models.StackFrame] + """ + + _validation = { + 'type_name': {'max_length': 1024, 'min_length': 0}, + 'message': {'required': True, 'max_length': 32768, 'min_length': 0}, + 'stack': {'max_length': 32768, 'min_length': 0}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'int'}, + 'outer_id': {'key': 'outerId', 'type': 'int'}, + 'type_name': {'key': 'typeName', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'has_full_stack': {'key': 'hasFullStack', 'type': 'bool'}, + 'stack': {'key': 'stack', 'type': 'str'}, + 'parsed_stack': {'key': 'parsedStack', 'type': '[StackFrame]'}, + } + + def __init__( + self, + *, + message: str, + id: Optional[int] = None, + outer_id: Optional[int] = None, + type_name: Optional[str] = None, + has_full_stack: Optional[bool] = True, + stack: Optional[str] = None, + parsed_stack: Optional[List["StackFrame"]] = None, + **kwargs + ): + super(TelemetryExceptionDetails, self).__init__(**kwargs) + self.id = id + self.outer_id = outer_id + self.type_name = type_name + self.message = message + self.has_full_stack = has_full_stack + self.stack = stack + self.parsed_stack = parsed_stack + + +class TelemetryItem(msrest.serialization.Model): + """System variables for a telemetry item. + + All required parameters must be populated in order to send to Azure. + + :param version: Envelope version. For internal use only. By assigning this the default, it will + not be serialized within the payload unless changed to a value other than #1. + :type version: int + :param name: Required. Type name of telemetry data item. + :type name: str + :param time: Required. Event date time when telemetry item was created. This is the wall clock + time on the client when the event was generated. There is no guarantee that the client's time + is accurate. This field must be formatted in UTC ISO 8601 format, with a trailing 'Z' + character, as described publicly on https://en.wikipedia.org/wiki/ISO_8601#UTC. Note: the + number of decimal seconds digits provided are variable (and unspecified). Consumers should + handle this, i.e. managed code consumers should not use format 'O' for parsing as it specifies + a fixed length. Example: 2009-06-15T13:45:30.0000000Z. + :type time: str + :param sample_rate: Sampling rate used in application. This telemetry item represents 1 / + sampleRate actual telemetry items. + :type sample_rate: float + :param sequence: Sequence field used to track absolute order of uploaded events. + :type sequence: str + :param instrumentation_key: The instrumentation key of the Application Insights resource. + :type instrumentation_key: str + :param tags: A set of tags. Key/value collection of context properties. See ContextTagKeys for + information on available properties. + :type tags: dict[str, str] + :param data: Telemetry data item. + :type data: ~azure_monitor_exporter.models.MonitorBase + """ + + _validation = { + 'name': {'required': True}, + 'time': {'required': True}, + 'sequence': {'max_length': 64, 'min_length': 0}, + } + + _attribute_map = { + 'version': {'key': 'ver', 'type': 'int'}, + 'name': {'key': 'name', 'type': 'str'}, + 'time': {'key': 'time', 'type': 'str'}, + 'sample_rate': {'key': 'sampleRate', 'type': 'float'}, + 'sequence': {'key': 'seq', 'type': 'str'}, + 'instrumentation_key': {'key': 'iKey', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'data': {'key': 'data', 'type': 'MonitorBase'}, + } + + def __init__( + self, + *, + name: str, + time: str, + version: Optional[int] = 1, + sample_rate: Optional[float] = 100, + sequence: Optional[str] = None, + instrumentation_key: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + data: Optional["MonitorBase"] = None, + **kwargs + ): + super(TelemetryItem, self).__init__(**kwargs) + self.version = version + self.name = name + self.time = time + self.sample_rate = sample_rate + self.sequence = sequence + self.instrumentation_key = instrumentation_key + self.tags = tags + self.data = data + + +class TrackResponse(msrest.serialization.Model): + """Response containing the status of each telemetry item. + + :param items_received: The number of items received. + :type items_received: int + :param items_accepted: The number of items accepted. + :type items_accepted: int + :param errors: An array of error detail objects. + :type errors: list[~azure_monitor_exporter.models.TelemetryErrorDetails] + """ + + _attribute_map = { + 'items_received': {'key': 'itemsReceived', 'type': 'int'}, + 'items_accepted': {'key': 'itemsAccepted', 'type': 'int'}, + 'errors': {'key': 'errors', 'type': '[TelemetryErrorDetails]'}, + } + + def __init__( + self, + *, + items_received: Optional[int] = None, + items_accepted: Optional[int] = None, + errors: Optional[List["TelemetryErrorDetails"]] = None, + **kwargs + ): + super(TrackResponse, self).__init__(**kwargs) + self.items_received = items_received + self.items_accepted = items_accepted + self.errors = errors diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/operations/__init__.py b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/operations/__init__.py new file mode 100644 index 000000000000..ee09cf842f4a --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/operations/__init__.py @@ -0,0 +1,13 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._azure_monitor_exporter_operations import AzureMonitorExporterOperationsMixin + +__all__ = [ + 'AzureMonitorExporterOperationsMixin', +] diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/operations/_azure_monitor_exporter_operations.py b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/operations/_azure_monitor_exporter_operations.py new file mode 100644 index 000000000000..ed66d3b9b97a --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/operations/_azure_monitor_exporter_operations.py @@ -0,0 +1,93 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class AzureMonitorExporterOperationsMixin(object): + + def track( + self, + body, # type: List["models.TelemetryItem"] + **kwargs # type: Any + ): + # type: (...) -> "models.TrackResponse" + """Track telemetry events. + + This operation sends a sequence of telemetry events that will be monitored by Azure Monitor. + + :param body: The list of telemetry events to track. + :type body: list[~azure_monitor_exporter.models.TelemetryItem] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TrackResponse, or the result of cls(response) + :rtype: ~azure_monitor_exporter.models.TrackResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TrackResponse"] + error_map = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(models.TrackResponse, response)), + 402: lambda response: HttpResponseError(response=response, model=self._deserialize(models.TrackResponse, response)), + 429: lambda response: HttpResponseError(response=response, model=self._deserialize(models.TrackResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(models.TrackResponse, response)), + 503: lambda response: HttpResponseError(response=response, model=self._deserialize(models.TrackResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.track.metadata['url'] # type: ignore + path_format_arguments = { + 'Host': self._serialize.url("self._config.host", self._config.host, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, '[TelemetryItem]') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 206]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.status_code == 200: + deserialized = self._deserialize('TrackResponse', pipeline_response) + + if response.status_code == 206: + deserialized = self._deserialize('TrackResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + track.metadata = {'url': '/track'} # type: ignore diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/py.typed b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_generated/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_version.py b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_version.py new file mode 100644 index 000000000000..ab32f7856eb1 --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/opentelemetry/exporter/azuremonitor/_version.py @@ -0,0 +1,8 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/sdk_packaging.toml b/sdk/monitor/opentelemetry-exporter-azuremonitor/sdk_packaging.toml new file mode 100644 index 000000000000..e7687fdae93b --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/sdk_packaging.toml @@ -0,0 +1,2 @@ +[packaging] +auto_update = false \ No newline at end of file diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/setup.cfg b/sdk/monitor/opentelemetry-exporter-azuremonitor/setup.cfg new file mode 100644 index 000000000000..3c6e79cf31da --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/setup.py b/sdk/monitor/opentelemetry-exporter-azuremonitor/setup.py new file mode 100644 index 000000000000..3875ca677709 --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/setup.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python + +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + + +import os +import re + +from setuptools import setup, find_packages + + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "opentelemetry-exporter-azuremonitor" +PACKAGE_PPRINT_NAME = "Azure Monitor Opentelemetry Exporter" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') + + +# azure v0.x is not compatible with this package +# azure v0.x used to have a __version__ attribute (newer versions don't) +try: + import azure + + try: + ver = azure.__version__ + raise Exception( + 'This package is incompatible with azure=={}. '.format(ver) + + 'Uninstall it with "pip uninstall azure".' + ) + except AttributeError: + pass +except ImportError: + pass + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, '_version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=open('README.md', 'r').read(), + long_description_content_type='text/markdown', + license='MIT License', + author='Microsoft Corporation', + author_email='ascl@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/monitor/opentelemetry-exporter-azuremonitor', + classifiers=[ + "Development Status :: 4 - Beta", + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=[ + # Exclude packages that will be covered by PEP420 or nspkg + 'opentelemetry', + 'opentelemetry.exporter', + 'tests', + ]), + install_requires=[ + "azure-core<2.0.0,>=1.6.0", + "msrest>=0.6.10", + ], +) diff --git a/sdk/monitor/opentelemetry-exporter-azuremonitor/swagger/README.md b/sdk/monitor/opentelemetry-exporter-azuremonitor/swagger/README.md new file mode 100644 index 000000000000..a8bbcc782e4c --- /dev/null +++ b/sdk/monitor/opentelemetry-exporter-azuremonitor/swagger/README.md @@ -0,0 +1,21 @@ +# Opentelemtry Exporter for Azure Monitor Client for Python + +> see https://aka.ms/autorest + +### Configuration + +```yaml +title: AzureMonitorExporter +description: Opentelemetry Exporter for Azure Monitor +generated-metadata: false +license-header: MICROSOFT_MIT_NO_VERSION +no-namespace-folders: true +output-folder: ../opentelemetry/exporter/azuremonitor/_generated +source-code-folder-path: ./opentelemetry/exporter/azuremonitor/_generated +input-file: + - https://github.com/Azure/azure-rest-api-specs/blob/master/specification/applicationinsights/data-plane/Monitor.Exporters/preview/2020-09-15_Preview/swagger.json + +python: true +v3: true +use: "@autorest/python@5.1.0-preview.7" +```