diff --git a/ext/opentelemetry-ext-azure-monitor/README.rst b/ext/opentelemetry-ext-azure-monitor/README.rst new file mode 100644 index 00000000000..d8c3e160742 --- /dev/null +++ b/ext/opentelemetry-ext-azure-monitor/README.rst @@ -0,0 +1,10 @@ +OpenTelemetry Azure Monitor Exporters +===================================== + +This library provides integration with Microsoft Azure Monitor. + +References +---------- + +* `Azure Monitor `_ +* `OpenTelemetry Project `_ diff --git a/ext/opentelemetry-ext-azure-monitor/examples/trace.py b/ext/opentelemetry-ext-azure-monitor/examples/trace.py new file mode 100644 index 00000000000..49b38c051dd --- /dev/null +++ b/ext/opentelemetry-ext-azure-monitor/examples/trace.py @@ -0,0 +1,13 @@ +from opentelemetry import trace +from opentelemetry.ext.azure_monitor import AzureMonitorSpanExporter +from opentelemetry.sdk.trace import Tracer +from opentelemetry.sdk.trace.export import SimpleExportSpanProcessor + +trace.set_preferred_tracer_implementation(lambda T: Tracer()) +tracer = trace.tracer() +tracer.add_span_processor( + SimpleExportSpanProcessor(AzureMonitorSpanExporter()) +) + +with tracer.start_span("hello") as span: + print("Hello, World!") diff --git a/ext/opentelemetry-ext-azure-monitor/setup.cfg b/ext/opentelemetry-ext-azure-monitor/setup.cfg new file mode 100644 index 00000000000..3110ed35312 --- /dev/null +++ b/ext/opentelemetry-ext-azure-monitor/setup.cfg @@ -0,0 +1,46 @@ +# Copyright 2019, OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +[metadata] +name = opentelemetry-ext-azure-monitor +description = Azure Monitor integration for OpenTelemetry +long_description = file: README.rst +long_description_content_type = text/x-rst +author = OpenTelemetry Authors +author_email = cncf-opentelemetry-contributors@lists.cncf.io +url = https://github.com/open-telemetry/opentelemetry-python/ext/opentelemetry-ext-azure-monitor +platforms = any +license = Apache-2.0 +classifiers = + Development Status :: 3 - Alpha + Intended Audience :: Developers + License :: OSI Approved :: Apache Software License + Programming Language :: Python + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.4 + Programming Language :: Python :: 3.5 + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + +[options] +python_requires = >=3.4 +package_dir= + =src +packages=find_namespace: +install_requires = + opentelemetry-api + opentelemetry-sdk + +[options.packages.find] +where = src diff --git a/ext/opentelemetry-ext-azure-monitor/setup.py b/ext/opentelemetry-ext-azure-monitor/setup.py new file mode 100644 index 00000000000..5f8afcb23a2 --- /dev/null +++ b/ext/opentelemetry-ext-azure-monitor/setup.py @@ -0,0 +1,26 @@ +# Copyright 2019, OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import os + +import setuptools + +BASE_DIR = os.path.dirname(__file__) +VERSION_FILENAME = os.path.join( + BASE_DIR, "src", "opentelemetry", "ext", "azure_monitor", "version.py" +) +PACKAGE_INFO = {} +with open(VERSION_FILENAME) as f: + exec(f.read(), PACKAGE_INFO) + +setuptools.setup(version=PACKAGE_INFO["__version__"]) diff --git a/ext/opentelemetry-ext-azure-monitor/src/opentelemetry/ext/azure_monitor/__init__.py b/ext/opentelemetry-ext-azure-monitor/src/opentelemetry/ext/azure_monitor/__init__.py new file mode 100644 index 00000000000..81222c546eb --- /dev/null +++ b/ext/opentelemetry-ext-azure-monitor/src/opentelemetry/ext/azure_monitor/__init__.py @@ -0,0 +1,23 @@ +# Copyright 2019, OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +The opentelemetry-ext-azure-monitor package provides integration with +Microsoft Azure Monitor. +""" + +from opentelemetry.ext.azure_monitor.trace import AzureMonitorSpanExporter +from opentelemetry.ext.azure_monitor.version import __version__ # noqa + +__all__ = ["AzureMonitorSpanExporter"] diff --git a/ext/opentelemetry-ext-azure-monitor/src/opentelemetry/ext/azure_monitor/trace.py b/ext/opentelemetry-ext-azure-monitor/src/opentelemetry/ext/azure_monitor/trace.py new file mode 100644 index 00000000000..a65cdd92a11 --- /dev/null +++ b/ext/opentelemetry-ext-azure-monitor/src/opentelemetry/ext/azure_monitor/trace.py @@ -0,0 +1,25 @@ +# Copyright 2019, OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from opentelemetry.sdk.trace.export import SpanExporter, SpanExportResult + + +class AzureMonitorSpanExporter(SpanExporter): + def __init__(self): + pass + + def export(self, spans): + for span in spans: + print(span) # TODO: add actual implementation here + return SpanExportResult.SUCCESS diff --git a/ext/opentelemetry-ext-azure-monitor/src/opentelemetry/ext/azure_monitor/version.py b/ext/opentelemetry-ext-azure-monitor/src/opentelemetry/ext/azure_monitor/version.py new file mode 100644 index 00000000000..a457c2b6651 --- /dev/null +++ b/ext/opentelemetry-ext-azure-monitor/src/opentelemetry/ext/azure_monitor/version.py @@ -0,0 +1,15 @@ +# Copyright 2019, OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +__version__ = "0.1.dev0" diff --git a/ext/opentelemetry-ext-azure-monitor/tests/__init__.py b/ext/opentelemetry-ext-azure-monitor/tests/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tox.ini b/tox.ini index d0fb6cc2dc4..871931dc55a 100644 --- a/tox.ini +++ b/tox.ini @@ -66,6 +66,7 @@ deps = commands_pre = pip install -e {toxinidir}/opentelemetry-api pip install -e {toxinidir}/opentelemetry-sdk + pip install -e {toxinidir}/ext/opentelemetry-ext-azure-monitor pip install -e {toxinidir}/ext/opentelemetry-ext-wsgi pip install -e {toxinidir}/ext/opentelemetry-ext-http-requests pip install -e {toxinidir}/opentelemetry-example-app @@ -78,6 +79,9 @@ commands = opentelemetry-api/tests/ \ opentelemetry-sdk/src/opentelemetry \ opentelemetry-sdk/tests/ \ + ext/opentelemetry-ext-azure-monitor/examples/ \ + ext/opentelemetry-ext-azure-monitor/src/ \ + ext/opentelemetry-ext-azure-monitor/tests/ \ ext/opentelemetry-ext-http-requests/src/ \ ext/opentelemetry-ext-http-requests/tests/ \ ext/opentelemetry-ext-wsgi/tests/ \