Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
[flake8]
ignore =
E501 # line too long, defer to black
W503 # allow line breaks before binary ops
W504 # allow line breaks after binary ops
E203 # allow whitespace before ':' (https://github.com/psf/black#slices)
# line too long, defer to black
E501

# allow line breaks before binary ops
W503

# allow line breaks after binary ops
W504

# allow whitespace before ':' (https://github.com/psf/black#slices)
E203

exclude =
.bzr
.git
Expand All @@ -15,3 +23,4 @@ exclude =
venv*/
target
__pycache__
*/build/lib/*
18 changes: 18 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[settings]
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
line_length=79
profile=black

; 3 stands for Vertical Hanging Indent, e.g.
; from third_party import (
; lib1,
; lib2,
; lib3,
; )
; docs: https://github.com/timothycrosley/isort#multi-line-output-modes
multi_line_output=3
skip=target
skip_glob=**/gen/*,.venv*/*,venv*/*,**/proto/*,.tox/*
known_third_party=opentelemetry,psutil,pytest,redis,redis_opentracing
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
([#205](https://github.com/microsoft/ApplicationInsights-Python/pull/205))
- Update CONTRIBUTING.md, support Py3.11
([#210](https://github.com/microsoft/ApplicationInsights-Python/pull/210))
- Updated setup.py, directory structure
([#214](https://github.com/microsoft/ApplicationInsights-Python/pull/214))

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

Expand Down
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

from os import environ

from opentelemetry.environment_variables import (OTEL_METRICS_EXPORTER,
OTEL_TRACES_EXPORTER)
from opentelemetry.environment_variables import (
OTEL_METRICS_EXPORTER,
OTEL_TRACES_EXPORTER,
)
from opentelemetry.instrumentation.distro import BaseDistro


Expand All @@ -18,4 +20,6 @@ def _configure(self, **kwargs):
environ.setdefault(
OTEL_METRICS_EXPORTER, "azure_monitor_opentelemetry_exporter"
)
environ.setdefault(OTEL_TRACES_EXPORTER, "azure_monitor_opentelemetry_exporter")
environ.setdefault(
OTEL_TRACES_EXPORTER, "azure_monitor_opentelemetry_exporter"
)
10 changes: 10 additions & 0 deletions azure-monitor-opentelemetry-distro/samples/simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License in the project root for
# license information.
# --------------------------------------------------------------------------

from azure.monitor.opentelemetry.distro.distro import AzureMonitorDistro

distro = AzureMonitorDistro()
distro.configure()
51 changes: 2 additions & 49 deletions azure-monitor-opentelemetry-distro/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,49 +1,2 @@
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License in the project root for
# license information.
# --------------------------------------------------------------------------
[metadata]
name = azure-monitor-opentelemetry-distro
description = Azure Monitor Distro for OpenTelemetry Python
long_description = file: README.md
long_description_content_type = text/markdown
author = Microsoft Corporation
url = https://github.com/microsoft/ApplicationInsights-Python
platforms = any
license = MIT License
classifiers =
Development Status :: 4 - Beta
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
License :: OSI Approved :: MIT License
Typing :: Typed

[options]
python_requires = >=3.7
package_dir=
=src
packages=find_namespace:
zip_safe = False
include_package_data = True
install_requires =
azure-monitor-opentelemetry-exporter == 1.0.0b8
opentelemetry-instrumentation ~= 0.35b0
opentelemetry-instrumentation-django ~= 0.35b0
opentelemetry-instrumentation-requests ~= 0.35b0
opentelemetry-instrumentation-flask ~= 0.35b0
opentelemetry-instrumentation-psycopg2 ~= 0.35b0

[options.packages.find]
where = src

[options.entry_points]
opentelemetry_distro =
azure_monitor_opentelemetry_distro = azure.monitor.opentelemetry.distro.distro:AzureMonitorDistro
opentelemetry_configurator =
azure_monitor_opentelemetry_configurator = azure.monitor.opentelemetry.distro.configurator:AzureMonitorConfigurator
[bdist_wheel]
universal=1
104 changes: 93 additions & 11 deletions azure-monitor-opentelemetry-distro/setup.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,103 @@
#!/usr/bin/env python

# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License in the project root for
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------


import os
import re

import setuptools
from setuptools import find_packages, setup

BASE_DIR = os.path.dirname(__file__)
VERSION_FILENAME = os.path.join(
BASE_DIR, "src", "azure", "monitor", "opentelemetry", "distro", "version.py"
)
PACKAGE_INFO = {}
with open(VERSION_FILENAME, encoding="utf-8") as f:
exec(f.read(), PACKAGE_INFO)
# Change the PACKAGE_NAME only to change folder and different name
PACKAGE_NAME = "azure-monitor-opentelemetry-distro"
PACKAGE_PPRINT_NAME = "Azure Monitor Opentelemetry Distro"

# 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")

setuptools.setup(
version=PACKAGE_INFO["VERSION"],
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/microsoft/ApplicationInsights-Python/tree/main/azure-monitor-opentelemetry-distro",
classifiers=[
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: MIT License",
],
zip_safe=False,
packages=find_packages(
exclude=[
"tests",
"samples",
# Exclude packages that will be covered by PEP420 or nspkg
"azure",
"azure.monitor",
"azure.monitor.opentelemetry",
]
),
include_package_data=True,
package_data={
"pytyped": ["py.typed"],
},
python_requires=">=3.7",
install_requires=[
"azure-monitor-opentelemetry-exporter>=1.0.0b11",
"opentelemetry-instrumentation~=0.35b0",
"opentelemetry-instrumentation-django~=0.35b0",
"opentelemetry-instrumentation-requests~=0.35b0",
"opentelemetry-instrumentation-flask~=0.35b0",
"opentelemetry-instrumentation-psycopg2~=0.35b0",
],
entry_points={
"opentelemetry_distro": [
"azure_monitor_opentelemetry_distro = azure.monitor.opentelemetry.distro.distro:AzureMonitorDistro"
],
"opentelemetry_configurator": [
"azure_monitor_opentelemetry_configurator = azure.monitor.opentelemetry.distro.configurator:AzureMonitorConfigurator"
],
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@

import unittest

from azure.monitor.opentelemetry.exporter import (AzureMonitorLogExporter,
AzureMonitorMetricExporter,
AzureMonitorTraceExporter)
from azure.monitor.opentelemetry.exporter import (
AzureMonitorLogExporter,
AzureMonitorMetricExporter,
AzureMonitorTraceExporter,
)


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

import unittest

from opentelemetry.instrumentation.flask import FlaskInstrumentor
Expand All @@ -13,4 +19,3 @@ def test_instrument(self):
self.fail(
f"Unexpected exception raised when instrumenting {FlaskInstrumentor.__name__}"
)

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

import unittest

from opentelemetry.instrumentation.psycopg2 import Psycopg2Instrumentor
Expand All @@ -12,4 +18,3 @@ def test_instrument(self):
self.fail(
f"Unexpected exception raised when instrumenting {Psycopg2Instrumentor.__name__}"
)

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

import unittest

from opentelemetry.instrumentation.requests import RequestsInstrumentor
Expand All @@ -12,4 +18,3 @@ def test_instrument(self):
self.fail(
f"Unexpected exception raised when instrumenting {RequestsInstrumentor.__name__}"
)

14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[tool.black]
line-length = 79
exclude = '''
(
/( # generated files
.github|
.tox|
.vscode|
venv|
.*/build/lib/.*|
scripts
)/
)
'''
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ commands_pre =
python -m pip install -e {toxinidir}/azure-monitor-opentelemetry-distro

commands =
black {toxinidir}
isort --recursive {toxinidir}
black --config pyproject.toml {toxinidir} --diff --check
isort --settings-path .isort.cfg {toxinidir} --diff --check-only
flake8 --config .flake8 {toxinidir}
; TODO
; pylint {toxinidir}
flake8 {toxinidir}