From e0bd6f08e489fa34190e2406ec561cdf8a6360ab Mon Sep 17 00:00:00 2001 From: Leighton Date: Tue, 31 Mar 2020 14:09:00 -0700 Subject: [PATCH 1/5] for release beta v0.2.0 --- CHANGELOG.md | 13 +++++++++++++ README.md | 6 +++--- azure_monitor/setup.cfg | 6 +++--- azure_monitor/src/azure_monitor/version.py | 2 +- 4 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..ca2f99e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,13 @@ +# Changelog + +## Unreleased + +## 0.2.0 +Released 2020-03-31 + +- Initial beta release + +## 0.1.0 +Released 2019-11-06 + +- Initial alpha release diff --git a/README.md b/README.md index 91fd8ee..112d3ff 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # OpenTelemetry Azure Monitor SDKs and Exporters [![Gitter chat](https://img.shields.io/gitter/room/Microsoft/azure-monitor-python)](https://gitter.im/Microsoft/azure-monitor-python) -[![Build status](https://travis-ci.org/microsoft/opentelemetry-azure-monitor-python.svg?branch=master)](https://travis-ci.org/microsoft/opentelemetry-exporters-python) -[![PyPI version](https://badge.fury.io/py/opentelemetry-azure-monitor-exporter.svg)](https://badge.fury.io/py/opentelemetry-azure-monitor-exporter) +[![Build status](https://travis-ci.org/microsoft/opentelemetry-azure-monitor-python.svg?branch=master)](https://travis-ci.org/microsoft/opentelemetry-azure-monitor-python) +[![PyPI version](https://badge.fury.io/py/opentelemetry-azure-monitor.svg)](https://badge.fury.io/py/opentelemetry-azure-monitor) ## Installation ```sh -pip install opentelemetry-azure-monitor-exporter +pip install opentelemetry-azure-monitor ``` ## Documentation diff --git a/azure_monitor/setup.cfg b/azure_monitor/setup.cfg index bbb0ddb..0157b80 100644 --- a/azure_monitor/setup.cfg +++ b/azure_monitor/setup.cfg @@ -1,17 +1,17 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. [metadata] -name = opentelemetry-azure-monitor-exporter +name = opentelemetry-azure-monitor description = Azure Monitor integration for OpenTelemetry long_description = file: README.rst long_description_content_type = text/x-rst author = Microsoft author_email = appinsightssdk@microsoft.com -url = https://github.com/microsoft/opentelemetry-exporters-python +url = https://github.com/microsoft/opentelemetry-azure-monitor-python platforms = any license = MIT classifiers = - Development Status :: 3 - Alpha + Development Status :: 4 - Beta Intended Audience :: Developers License :: OSI Approved :: MIT License Programming Language :: Python diff --git a/azure_monitor/src/azure_monitor/version.py b/azure_monitor/src/azure_monitor/version.py index 7a5fe00..3e3cc8e 100644 --- a/azure_monitor/src/azure_monitor/version.py +++ b/azure_monitor/src/azure_monitor/version.py @@ -1,3 +1,3 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -__version__ = "0.2.dev0" +__version__ = "0.2b.0" From 925f1439ce28438bad411220dc9c5b8f421fe5c4 Mon Sep 17 00:00:00 2001 From: Leighton Date: Tue, 31 Mar 2020 19:24:29 -0700 Subject: [PATCH 2/5] release --- azure_monitor/CHANGELOG.md | 13 ++ azure_monitor/README.md | 169 +++++++++++++++++++++ azure_monitor/setup.cfg | 6 +- azure_monitor/src/azure_monitor/version.py | 2 +- 4 files changed, 186 insertions(+), 4 deletions(-) create mode 100644 azure_monitor/CHANGELOG.md create mode 100644 azure_monitor/README.md diff --git a/azure_monitor/CHANGELOG.md b/azure_monitor/CHANGELOG.md new file mode 100644 index 0000000..ca2f99e --- /dev/null +++ b/azure_monitor/CHANGELOG.md @@ -0,0 +1,13 @@ +# Changelog + +## Unreleased + +## 0.2.0 +Released 2020-03-31 + +- Initial beta release + +## 0.1.0 +Released 2019-11-06 + +- Initial alpha release diff --git a/azure_monitor/README.md b/azure_monitor/README.md new file mode 100644 index 0000000..112d3ff --- /dev/null +++ b/azure_monitor/README.md @@ -0,0 +1,169 @@ +# OpenTelemetry Azure Monitor SDKs and Exporters + +[![Gitter chat](https://img.shields.io/gitter/room/Microsoft/azure-monitor-python)](https://gitter.im/Microsoft/azure-monitor-python) +[![Build status](https://travis-ci.org/microsoft/opentelemetry-azure-monitor-python.svg?branch=master)](https://travis-ci.org/microsoft/opentelemetry-azure-monitor-python) +[![PyPI version](https://badge.fury.io/py/opentelemetry-azure-monitor.svg)](https://badge.fury.io/py/opentelemetry-azure-monitor) + +## Installation + +```sh +pip install opentelemetry-azure-monitor +``` + +## Documentation + +The online documentation is available at https://opentelemetry-azure-monitor-python.readthedocs.io/. + + +## Usage + +### Trace + +The **Azure Monitor Trace Exporter** allows you to export [OpenTelemetry](https://opentelemetry.io/) traces to [Azure Monitor](https://docs.microsoft.com/azure/azure-monitor/). + +This example shows how to send a span "hello" to Azure Monitor. + +* Create an Azure Monitor resource and get the instrumentation key, more information can be found [here](https://docs.microsoft.com/azure/azure-monitor/app/create-new-resource). +* Place your instrumentation key in a `connection string` and directly into your code. +* Alternatively, you can specify your `connection string` in an environment variable ``APPLICATIONINSIGHTS_CONNECTION_STRING``. + +```python +from azure_monitor import AzureMonitorSpanExporter +from opentelemetry import trace +from opentelemetry.sdk.trace import TracerProvider +from opentelemetry.sdk.trace.export import BatchExportSpanProcessor + +trace.set_tracer_provider(TracerProvider()) + +# We tell OpenTelemetry who it is that is creating spans. In this case, we have +# no real name (no setup.py), so we make one up. If we had a version, we would +# also specify it here. +tracer = trace.get_tracer(__name__) + +exporter = AzureMonitorSpanExporter( + connection_string='InstrumentationKey=', +) + +# SpanExporter receives the spans and send them to the target location. +span_processor = BatchExportSpanProcessor(exporter) +trace.get_tracer_provider().add_span_processor(span_processor) + +with tracer.start_as_current_span('hello'): + print('Hello World!') +``` + +#### Integrations + +OpenTelemetry also supports several [integrations](https://github.com/open-telemetry/opentelemetry-python/tree/master/ext) which allows to integrate with third party libraries. + +This example shows how to integrate with the [requests](https://2.python-requests.org/en/master/)_ library. + +* Create an Azure Monitor resource and get the instrumentation key, more information can be found [here](https://docs.microsoft.com/azure/azure-monitor/app/create-new-resource). +* Install the `requests` integration package using ``pip install opentelemetry-ext-http-requests``. +* Place your instrumentation key in a `connection string` and directly into your code. +* Alternatively, you can specify your `connection string` in an environment variable ``APPLICATIONINSIGHTS_CONNECTION_STRING``. + +```python +import requests + +from azure_monitor import AzureMonitorSpanExporter +from opentelemetry import trace +from opentelemetry.ext import http_requests +from opentelemetry.sdk.trace import TracerProvider +from opentelemetry.sdk.trace.export import BatchExportSpanProcessor + +trace.set_tracer_provider(TracerProvider()) +tracer_provider = trace.get_tracer_provider() + +exporter = AzureMonitorSpanExporter( + connection_string='InstrumentationKey=', + ) +span_processor = BatchExportSpanProcessor(exporter) +tracer_provider.add_span_processor(span_processor) + +http_requests.enable(tracer_provider) +response = requests.get(url="https://azure.microsoft.com/") +``` + +#### Modifying Traces + +* You can pass a callback function to the exporter to process telemetry before it is exported. +* Your callback function can return `False` if you do not want this envelope exported. +* Your callback function must accept an [envelope](https://github.com/microsoft/opentelemetry-exporters-python/blob/master/azure_monitor/src/azure_monitor/protocol.py#L80) data type as its parameter. +* You can see the schema for Azure Monitor data types in the envelopes [here](https://github.com/microsoft/opentelemetry-exporters-python/blob/master/azure_monitor/src/azure_monitor/protocol.py). +* The `AzureMonitorSpanExporter` handles `Data` data types. + +```python +from azure_monitor import AzureMonitorSpanExporter +from opentelemetry import trace +from opentelemetry.sdk.trace import TracerProvider +from opentelemetry.sdk.trace.export import BatchExportSpanProcessor + +# Callback function to add os_type: linux to span properties +def callback_function(envelope): + envelope.data.baseData.properties['os_type'] = 'linux' + return True + +exporter = AzureMonitorSpanExporter( + connection_string='InstrumentationKey=' +) +exporter.add_telemetry_processor(callback_function) + +trace.set_tracer_provider(TracerProvider()) +tracer = trace.get_tracer(__name__) +span_processor = BatchExportSpanProcessor(exporter) +trace.get_tracer_provider().add_span_processor(span_processor) + +with tracer.start_as_current_span('hello'): + print('Hello World!') +``` + +### Metrics + +The **Azure Monitor Metrics Exporter** allows you to export metrics to [Azure Monitor](https://docs.microsoft.com/azure/azure-monitor/). + +This example shows how to track a counter metric and send it as telemetry every export interval. + +* Create an Azure Monitor resource and get the instrumentation key, more information can be found [here](https://docs.microsoft.com/azure/azure-monitor/app/create-new-resource). +* Place your instrumentation key in a `connection string` and directly into your code. +* Alternatively, you can specify your `connection string` in an environment variable ``APPLICATIONINSIGHTS_CONNECTION_STRING``. + +```python +import time + +from azure_monitor import AzureMonitorMetricsExporter +from opentelemetry import metrics +from opentelemetry.sdk.metrics import Counter, MeterProvider +from opentelemetry.sdk.metrics.export.controller import PushController + +metrics.set_meter_provider(MeterProvider()) +meter = metrics.get_meter(__name__) +exporter = AzureMonitorMetricsExporter( + connection_string='InstrumentationKey=' +) +controller = PushController(meter, exporter, 5) + +requests_counter = meter.create_metric( + name="requests", + description="number of requests", + unit="1", + value_type=int, + metric_type=Counter, + label_keys=("environment",), +) + +testing_label_set = meter.get_label_set({"environment": "testing"}) + +requests_counter.add(25, testing_label_set) +time.sleep(100) +``` + +# References + +[Azure Monitor](https://docs.microsoft.com/azure/azure-monitor/) + +[OpenTelemetry Project](https://opentelemetry.io/) + +[OpenTelemetry Python Client](https://github.com/open-telemetry/opentelemetry-python) + +[Azure Monitor Python Gitter](https://gitter.im/Microsoft/azure-monitor-python) diff --git a/azure_monitor/setup.cfg b/azure_monitor/setup.cfg index 0157b80..496120e 100644 --- a/azure_monitor/setup.cfg +++ b/azure_monitor/setup.cfg @@ -2,9 +2,9 @@ # Licensed under the MIT License. [metadata] name = opentelemetry-azure-monitor -description = Azure Monitor integration for OpenTelemetry -long_description = file: README.rst -long_description_content_type = text/x-rst +description = Azure Monitor SDKs and Exporters for OpenTelemetry +long_description = file: README.md +long_description_content_type = text/markdown author = Microsoft author_email = appinsightssdk@microsoft.com url = https://github.com/microsoft/opentelemetry-azure-monitor-python diff --git a/azure_monitor/src/azure_monitor/version.py b/azure_monitor/src/azure_monitor/version.py index 3e3cc8e..835d02b 100644 --- a/azure_monitor/src/azure_monitor/version.py +++ b/azure_monitor/src/azure_monitor/version.py @@ -1,3 +1,3 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -__version__ = "0.2b.0" +__version__ = "0.3.dev0" From 7ddf4f589d35904e03f2186d8b8c60bc673b74b4 Mon Sep 17 00:00:00 2001 From: Leighton Date: Tue, 31 Mar 2020 19:26:12 -0700 Subject: [PATCH 3/5] remove files --- CHANGELOG.md | 13 ---- README.md | 169 --------------------------------------------------- 2 files changed, 182 deletions(-) delete mode 100644 CHANGELOG.md delete mode 100644 README.md diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index ca2f99e..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,13 +0,0 @@ -# Changelog - -## Unreleased - -## 0.2.0 -Released 2020-03-31 - -- Initial beta release - -## 0.1.0 -Released 2019-11-06 - -- Initial alpha release diff --git a/README.md b/README.md deleted file mode 100644 index 112d3ff..0000000 --- a/README.md +++ /dev/null @@ -1,169 +0,0 @@ -# OpenTelemetry Azure Monitor SDKs and Exporters - -[![Gitter chat](https://img.shields.io/gitter/room/Microsoft/azure-monitor-python)](https://gitter.im/Microsoft/azure-monitor-python) -[![Build status](https://travis-ci.org/microsoft/opentelemetry-azure-monitor-python.svg?branch=master)](https://travis-ci.org/microsoft/opentelemetry-azure-monitor-python) -[![PyPI version](https://badge.fury.io/py/opentelemetry-azure-monitor.svg)](https://badge.fury.io/py/opentelemetry-azure-monitor) - -## Installation - -```sh -pip install opentelemetry-azure-monitor -``` - -## Documentation - -The online documentation is available at https://opentelemetry-azure-monitor-python.readthedocs.io/. - - -## Usage - -### Trace - -The **Azure Monitor Trace Exporter** allows you to export [OpenTelemetry](https://opentelemetry.io/) traces to [Azure Monitor](https://docs.microsoft.com/azure/azure-monitor/). - -This example shows how to send a span "hello" to Azure Monitor. - -* Create an Azure Monitor resource and get the instrumentation key, more information can be found [here](https://docs.microsoft.com/azure/azure-monitor/app/create-new-resource). -* Place your instrumentation key in a `connection string` and directly into your code. -* Alternatively, you can specify your `connection string` in an environment variable ``APPLICATIONINSIGHTS_CONNECTION_STRING``. - -```python -from azure_monitor import AzureMonitorSpanExporter -from opentelemetry import trace -from opentelemetry.sdk.trace import TracerProvider -from opentelemetry.sdk.trace.export import BatchExportSpanProcessor - -trace.set_tracer_provider(TracerProvider()) - -# We tell OpenTelemetry who it is that is creating spans. In this case, we have -# no real name (no setup.py), so we make one up. If we had a version, we would -# also specify it here. -tracer = trace.get_tracer(__name__) - -exporter = AzureMonitorSpanExporter( - connection_string='InstrumentationKey=', -) - -# SpanExporter receives the spans and send them to the target location. -span_processor = BatchExportSpanProcessor(exporter) -trace.get_tracer_provider().add_span_processor(span_processor) - -with tracer.start_as_current_span('hello'): - print('Hello World!') -``` - -#### Integrations - -OpenTelemetry also supports several [integrations](https://github.com/open-telemetry/opentelemetry-python/tree/master/ext) which allows to integrate with third party libraries. - -This example shows how to integrate with the [requests](https://2.python-requests.org/en/master/)_ library. - -* Create an Azure Monitor resource and get the instrumentation key, more information can be found [here](https://docs.microsoft.com/azure/azure-monitor/app/create-new-resource). -* Install the `requests` integration package using ``pip install opentelemetry-ext-http-requests``. -* Place your instrumentation key in a `connection string` and directly into your code. -* Alternatively, you can specify your `connection string` in an environment variable ``APPLICATIONINSIGHTS_CONNECTION_STRING``. - -```python -import requests - -from azure_monitor import AzureMonitorSpanExporter -from opentelemetry import trace -from opentelemetry.ext import http_requests -from opentelemetry.sdk.trace import TracerProvider -from opentelemetry.sdk.trace.export import BatchExportSpanProcessor - -trace.set_tracer_provider(TracerProvider()) -tracer_provider = trace.get_tracer_provider() - -exporter = AzureMonitorSpanExporter( - connection_string='InstrumentationKey=', - ) -span_processor = BatchExportSpanProcessor(exporter) -tracer_provider.add_span_processor(span_processor) - -http_requests.enable(tracer_provider) -response = requests.get(url="https://azure.microsoft.com/") -``` - -#### Modifying Traces - -* You can pass a callback function to the exporter to process telemetry before it is exported. -* Your callback function can return `False` if you do not want this envelope exported. -* Your callback function must accept an [envelope](https://github.com/microsoft/opentelemetry-exporters-python/blob/master/azure_monitor/src/azure_monitor/protocol.py#L80) data type as its parameter. -* You can see the schema for Azure Monitor data types in the envelopes [here](https://github.com/microsoft/opentelemetry-exporters-python/blob/master/azure_monitor/src/azure_monitor/protocol.py). -* The `AzureMonitorSpanExporter` handles `Data` data types. - -```python -from azure_monitor import AzureMonitorSpanExporter -from opentelemetry import trace -from opentelemetry.sdk.trace import TracerProvider -from opentelemetry.sdk.trace.export import BatchExportSpanProcessor - -# Callback function to add os_type: linux to span properties -def callback_function(envelope): - envelope.data.baseData.properties['os_type'] = 'linux' - return True - -exporter = AzureMonitorSpanExporter( - connection_string='InstrumentationKey=' -) -exporter.add_telemetry_processor(callback_function) - -trace.set_tracer_provider(TracerProvider()) -tracer = trace.get_tracer(__name__) -span_processor = BatchExportSpanProcessor(exporter) -trace.get_tracer_provider().add_span_processor(span_processor) - -with tracer.start_as_current_span('hello'): - print('Hello World!') -``` - -### Metrics - -The **Azure Monitor Metrics Exporter** allows you to export metrics to [Azure Monitor](https://docs.microsoft.com/azure/azure-monitor/). - -This example shows how to track a counter metric and send it as telemetry every export interval. - -* Create an Azure Monitor resource and get the instrumentation key, more information can be found [here](https://docs.microsoft.com/azure/azure-monitor/app/create-new-resource). -* Place your instrumentation key in a `connection string` and directly into your code. -* Alternatively, you can specify your `connection string` in an environment variable ``APPLICATIONINSIGHTS_CONNECTION_STRING``. - -```python -import time - -from azure_monitor import AzureMonitorMetricsExporter -from opentelemetry import metrics -from opentelemetry.sdk.metrics import Counter, MeterProvider -from opentelemetry.sdk.metrics.export.controller import PushController - -metrics.set_meter_provider(MeterProvider()) -meter = metrics.get_meter(__name__) -exporter = AzureMonitorMetricsExporter( - connection_string='InstrumentationKey=' -) -controller = PushController(meter, exporter, 5) - -requests_counter = meter.create_metric( - name="requests", - description="number of requests", - unit="1", - value_type=int, - metric_type=Counter, - label_keys=("environment",), -) - -testing_label_set = meter.get_label_set({"environment": "testing"}) - -requests_counter.add(25, testing_label_set) -time.sleep(100) -``` - -# References - -[Azure Monitor](https://docs.microsoft.com/azure/azure-monitor/) - -[OpenTelemetry Project](https://opentelemetry.io/) - -[OpenTelemetry Python Client](https://github.com/open-telemetry/opentelemetry-python) - -[Azure Monitor Python Gitter](https://gitter.im/Microsoft/azure-monitor-python) From bb3b1931ae88fa4da08413237f205c5261b1019b Mon Sep 17 00:00:00 2001 From: Leighton Date: Wed, 1 Apr 2020 12:10:50 -0700 Subject: [PATCH 4/5] fix exporters --- azure_monitor/examples/traces/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure_monitor/examples/traces/README.md b/azure_monitor/examples/traces/README.md index 383bf92..07def03 100644 --- a/azure_monitor/examples/traces/README.md +++ b/azure_monitor/examples/traces/README.md @@ -2,7 +2,7 @@ ## Installation ```sh -$ pip install opentelemetry-azure-monitor-exporter +$ pip install opentelemetry-azure-monitor ``` ## Run the Applications From a725808a40356f75d5f11a20dfcbf27d49023be8 Mon Sep 17 00:00:00 2001 From: Leighton Date: Wed, 1 Apr 2020 12:14:32 -0700 Subject: [PATCH 5/5] exporers --- docs/conf.py | 2 +- docs/index.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index c21be60..b503d5f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -28,7 +28,7 @@ author = "Microsoft" # The full version, including alpha/beta/rc tags -release = "0.0.1b" +release = "0.2b.0" # -- General configuration --------------------------------------------------- diff --git a/docs/index.rst b/docs/index.rst index e360c22..7526b12 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -19,7 +19,7 @@ The package is available on PyPI, and can installed via pip: .. code-block:: sh - pip install opentelemetry-azure-monitor-exporter + pip install opentelemetry-azure-monitor .. toctree:: :maxdepth: 1