Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor monitor exporter #16622

Merged
merged 13 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions eng/.docsettings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,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/azure-opentelemetry-exporter-azuremonitor/swagger/README.md', '#4554']
- ['sdk/monitor/azure-opentelemetry-exporter-azuremonitor/README.md', '#4554']
- ['sdk/monitor/azure-monitor-opentelemetry-exporter/swagger/README.md', '#4554']
- ['sdk/monitor/azure-monitor-opentelemetry-exporter/README.md', '#4554']
- ['sdk/digitaltwins/azure-digitaltwins-core/swagger/README.md', '#4554']
- ['sdk/media/azure-media-nspkg/README.md', '#4554']

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

## 1.0.0b3 (Unreleased)

- Add azure servicebus samples and docstrings to samples
([#16580](https://github.com/Azure/azure-sdk-for-python/pull/16580))
**Breaking Changes**
- The package has been renamed to `azure-monitor-opentelemetry-exporter`

**Features**
- Add azure servicebus samples and docstrings to samples
([#16580](https://github.com/Azure/azure-sdk-for-python/pull/16580))

## 1.0.0b2 (2021-01-13)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include *.md
include azure/__init__.py
include azure/opentelemetry/__init__.py
include azure/opentelemetry/exporter/__init__.py
include azure/monitor/__init__.py
include azure/monitor/opentelemetry/__init__.py
include LICENSE.txt
recursive-include tests *.py
recursive-include samples *.py *.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

The exporter for Azure Monitor allows you to export tracing data utilizing the OpenTelemetry SDK and send telemetry data to Azure Monitor for applications written in Python.

[Source code](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/monitor/azure-opentelemetry-exporter-azuremonitor) | [Package (PyPi)][pypi] | [API reference documentation][api_docs] | [Product documentation][product_docs] || [Samples](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/monitor/azure-opentelemetry-exporter-azuremonitor/samples) | [Changelog](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/monitor/azure-opentelemetry-exporter-azuremonitor/CHANGELOG.md)
[Source code](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/monitor/azure-monitor-opentelemetry-exporter) | [Package (PyPi)][pypi] | [API reference documentation][api_docs] | [Product documentation][product_docs] || [Samples](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/monitor/azure-monitor-opentelemetry-exporter/samples) | [Changelog](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md)

## Getting started

Expand All @@ -13,7 +13,7 @@ The exporter for Azure Monitor allows you to export tracing data utilizing the O
Install the Microsoft Opentelemetry exporter for Azure Monitor with [pip][pip]:

```Bash
pip install azure-opentelemetry-exporter-azuremonitor --pre
pip install azure-monitor-opentelemetry-exporter --pre
```

### Prerequisites:
Expand All @@ -31,7 +31,7 @@ Please find the samples linked below for demonstration as to how to authenticate
#### [Create Exporter from connection string][sample_authenticate_client_connstr]

```Python
from azure.opentelemetry.exporter.azuremonitor import AzureMonitorTraceExporter
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter
exporter = AzureMonitorTraceExporter(
connection_string = os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING "]
)
Expand Down Expand Up @@ -73,7 +73,7 @@ import os
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor
from azure.opentelemetry.exporter.azuremonitor import AzureMonitorTraceExporter
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter

exporter = AzureMonitorTraceExporter(
connection_string = os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING "]
Expand Down Expand Up @@ -104,7 +104,7 @@ from opentelemetry.instrumentation.requests import RequestsInstrumentor
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor

from azure.opentelemetry.exporter.azuremonitor import AzureMonitorTraceExporter
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter

trace.set_tracer_provider(TracerProvider())
tracer = trace.get_tracer(__name__)
Expand Down Expand Up @@ -132,7 +132,7 @@ The exporter raises exceptions defined in [Azure Core](https://github.com/Azure/

### More sample code

Please find further examples in the [samples](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/monitor/azure-opentelemetry-exporter-azuremonitor/samples) directory demonstrating common scenarios.
Please find further examples in the [samples](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/monitor/azure-monitor-opentelemetry-exporter/samples) directory demonstrating common scenarios.

### Additional documentation

Expand Down Expand Up @@ -169,13 +169,13 @@ contact [[email protected]](mailto:[email protected]) with any additio
[virtualenv]: https://virtualenv.pypa.io
[ot_sdk_python]: https://github.com/open-telemetry/opentelemetry-python
[application_insights_namespace]: https://docs.microsoft.com/azure/azure-monitor/app/app-insights-overview#how-do-i-use-application-insights
[exporter_options]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/monitor/azure-opentelemetry-exporter-azuremonitor/azure/opentelemetry/exporter/azuremonitor/_options.py#L21
[exporter_options]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_options.py#L21
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should folder structure be /sdk/monitor/azure-monitor-opentelemetry-exporter/azure-monitor/opentelemetry/exporter since azure-monitor is the product and not azure, then monitor? Having azure and then monitor might imply that there might be other folders under azure besides monitor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from my understanding, that would change the namespaces which we agreed upon

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah not a strong opinion here.

[trace_concept]: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/overview.md#trace
[client_reference]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/monitor/azure-opentelemetry-exporter-azuremonitor/azure/opentelemetry/exporter/azuremonitor/export/trace/_exporter.py#L30
[client_reference]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_exporter.py#L30
[opentelemtry_spec]: https://opentelemetry.io/
[instrumentation_library]: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/overview.md#instrumentation-libraries
[tracer_provider]: https://opentelemetry-python.readthedocs.io/en/stable/api/trace.html?highlight=TracerProvider#opentelemetry.trace.TracerProvider
[span_processor]: https://opentelemetry-python.readthedocs.io/en/stable/_modules/opentelemetry/sdk/trace.html?highlight=SpanProcessor#
[sampler_ref]: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk.md#sampling

[sample_authenticate_client_connstr]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/monitor/azure-opentelemetry-exporter-azuremonitor/samples/traces/sample_trace.py
[sample_authenticate_client_connstr]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/sample_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------

from azure.opentelemetry.exporter.azuremonitor.export.trace._exporter import AzureMonitorTraceExporter
from azure.opentelemetry.exporter.azuremonitor._options import ExporterOptions
from azure.monitor.opentelemetry.exporter.export.trace._exporter import AzureMonitorTraceExporter
from azure.monitor.opentelemetry.exporter._options import ExporterOptions
from ._version import VERSION

__all__ = ["AzureMonitorTraceExporter", "ExporterOptions"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os
import random

from azure.opentelemetry.exporter.azuremonitor._utils import PeriodicTask
from azure.monitor.opentelemetry.exporter._utils import PeriodicTask

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pkg_resources

from azure.opentelemetry.exporter.azuremonitor._version import VERSION as ext_version
from azure.monitor.opentelemetry.exporter._version import VERSION as ext_version


# Workaround for missing version file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

from azure.core.exceptions import HttpResponseError, ServiceRequestError
from azure.core.pipeline.policies import ContentDecodePolicy, HttpLoggingPolicy, RequestIdPolicy
from azure.opentelemetry.exporter.azuremonitor._generated import AzureMonitorClient
from azure.opentelemetry.exporter.azuremonitor._generated._configuration import AzureMonitorClientConfiguration
from azure.opentelemetry.exporter.azuremonitor._generated.models import TelemetryItem
from azure.opentelemetry.exporter.azuremonitor._connection_string_parser import ConnectionStringParser
from azure.opentelemetry.exporter.azuremonitor._storage import LocalFileStorage
from azure.opentelemetry.exporter.azuremonitor._options import ExporterOptions
from azure.monitor.opentelemetry.exporter._generated import AzureMonitorClient
from azure.monitor.opentelemetry.exporter._generated._configuration import AzureMonitorClientConfiguration
from azure.monitor.opentelemetry.exporter._generated.models import TelemetryItem
from azure.monitor.opentelemetry.exporter._connection_string_parser import ConnectionStringParser
from azure.monitor.opentelemetry.exporter._storage import LocalFileStorage
from azure.monitor.opentelemetry.exporter._options import ExporterOptions


logger = logging.getLogger(__name__)
Expand All @@ -34,14 +34,14 @@ class BaseExporter:
"""Azure Monitor base exporter for OpenTelemetry.

:param options: Exporter configuration options.
:type options: ~azure.opentelemetry.exporter.azuremonitor.options.ExporterOptions
:type options: ~azure.monitor.opentelemetry.exporter.options.ExporterOptions
"""

def __init__(self, **kwargs: Any) -> None:
"""Azure Monitor base exporter for OpenTelemetry.

:param options: Exporter configuration options.
:type options: ~azure.opentelemetry.exporter.azuremonitor.options.ExporterOptions
:type options: ~azure.monitor.opentelemetry.exporter.options.ExporterOptions
:keyword str connection_string: The connection string to be used for authentication
:rtype: None
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
from opentelemetry.sdk.util import ns_to_iso_str
from opentelemetry.trace import Span, SpanKind

from azure.opentelemetry.exporter.azuremonitor import _utils
from azure.opentelemetry.exporter.azuremonitor._generated.models import (
from azure.monitor.opentelemetry.exporter import _utils
from azure.monitor.opentelemetry.exporter._generated.models import (
MonitorBase,
RemoteDependencyData,
RequestData,
TelemetryItem
)
from azure.opentelemetry.exporter.azuremonitor.export._base import (
from azure.monitor.opentelemetry.exporter.export._base import (
BaseExporter,
ExportResult,
get_trace_export_result,
Expand All @@ -31,7 +31,7 @@ class AzureMonitorTraceExporter(BaseExporter, SpanExporter):
"""Azure Monitor base exporter for OpenTelemetry.

:param options: Exporter configuration options.
:type options: ~azure.opentelemetry.exporter.azuremonitor.options.ExporterOptions
:type options: ~azure.monitor.opentelemetry.exporter.options.ExporterOptions
"""

def export(self, spans: Sequence[Span], **kwargs: Any) -> SpanExportResult: # pylint: disable=unused-argument
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ignore_missing_imports = True

# Per-module options:

[mypy-azure.opentelemetry.exporter.azuremonitor._generated.*]
[mypy-azure.monitor.opentelemetry.exporter._generated.*]
ignore_errors = True

[mypy-azure.core.*]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ page_type: sample
languages:
- python
products:
- azure-opentelemetry-exporter-azuremonitor
- azure-monitor-opentelemetry-exporter
---

# Microsoft Azure Monitor Opentelemetry Exporter Python Samples

These code samples show common champion scenario operations with the AzureMonitorTraceExporter.

* Azure Service Bus Send: [sample_servicebus_send.py](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/monitor/azure-opentelemetry-exporter-azuremonitor/samples/traces/sample_servicebus_send.py)
* Azure Service Bus Receive: [sample_servicebus_receive.py](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/monitor/azure-opentelemetry-exporter-azuremonitor/samples/traces/sample_servicebus_receive.py)
* Azure Storage Blob Create Container: [sample_storage.py](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/monitor/azure-opentelemetry-exporter-azuremonitor/samples/traces/sample_storage.py)
* Client: [sample_client.py](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/monitor/azure-opentelemetry-exporter-azuremonitor/samples/traces/sample_client.py)
* Trace: [sample_trace.py](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/monitor/azure-opentelemetry-exporter-azuremonitor/samples/traces/sample_trace.py)
* Server: [sample_server.py](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/monitor/azure-opentelemetry-exporter-azuremonitor/samples/traces/sample_server.py)
* Azure Service Bus Send: [sample_servicebus_send.py](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/sample_servicebus_send.py)
* Azure Service Bus Receive: [sample_servicebus_receive.py](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/sample_servicebus_receive.py)
* Azure Storage Blob Create Container: [sample_storage.py](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/sample_storage.py)
* Client: [sample_client.py](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/sample_client.py)
* Trace: [sample_trace.py](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/sample_trace.py)
* Server: [sample_server.py](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/sample_server.py)

## Installation

```sh
$ pip install azure-opentelemetry-exporter-azuremonitor --pre
$ pip install azure-monitor-opentelemetry-exporter --pre
```

## Run the Applications
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor

from azure.opentelemetry.exporter.azuremonitor import AzureMonitorTraceExporter
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter

trace.set_tracer_provider(TracerProvider())
tracer = trace.get_tracer(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor

import flask
from azure.opentelemetry.exporter.azuremonitor import AzureMonitorTraceExporter
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter

# The preferred tracer implementation must be set, as the opentelemetry-api
# defines the interface with a no-op implementation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
tracer = trace.get_tracer(__name__)

# azure monitor trace exporter to send telemetry to appinsights
from azure.opentelemetry.exporter.azuremonitor import AzureMonitorTraceExporter
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter
span_processor = BatchExportSpanProcessor(
AzureMonitorTraceExporter(
connection_string = os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
tracer = trace.get_tracer(__name__)

# azure monitor trace exporter to send telemetry to appinsights
from azure.opentelemetry.exporter.azuremonitor import AzureMonitorTraceExporter
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter
span_processor = BatchExportSpanProcessor(
AzureMonitorTraceExporter(
connection_string = os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
"""
Examples to show usage of the azure-core-tracing-opentelemetry
with the storage SDK and exporting to Azure monitor backend.

This example traces calls for creating a container using storage SDK.

The telemetry will be collected automatically and sent to Application
Insights via the AzureMonitorTraceExporter
"""
Expand All @@ -26,7 +24,7 @@
tracer = trace.get_tracer(__name__)

# azure monitor trace exporter to send telemetry to appinsights
from azure.opentelemetry.exporter.azuremonitor import AzureMonitorTraceExporter
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter
span_processor = BatchExportSpanProcessor(
AzureMonitorTraceExporter(
connection_string = os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor

from azure.opentelemetry.exporter.azuremonitor import AzureMonitorTraceExporter
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter


exporter = AzureMonitorTraceExporter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


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

# a-b-c => a/b/c
Expand Down Expand Up @@ -54,7 +54,7 @@
license='MIT License',
author='Microsoft Corporation',
author_email='[email protected]',
url='https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/monitor/azure-opentelemetry-exporter-azuremonitor',
url='https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/monitor/azure-monitor-opentelemetry-exporter',
classifiers=[
"Development Status :: 4 - Beta",
'Programming Language :: Python',
Expand All @@ -72,8 +72,8 @@
'samples',
# Exclude packages that will be covered by PEP420 or nspkg
'azure',
'azure.opentelemetry',
'azure.opentelemetry.exporter'
'azure.monitor',
'azure.monitor.opentelemetry'
]),
python_requires=">=3.5.0",
install_requires=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Instructions

From `azure-opentelemetry-exporter-azuremonitor/`:
From `azure-monitor-opentelemetry-exporter/`:

```
rmdir ./azure/opentelemetry/exporter/azuremonitor/_generated
Expand Down
Loading