This commit is contained in:
Leighton Chen 2022-12-24 13:58:40 -08:00
Родитель 2502bc996d
Коммит 41ba0c5c85
10 изменённых файлов: 86 добавлений и 48 удалений

18
.isort.cfg Normal file
Просмотреть файл

@ -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

Просмотреть файл

@ -7,7 +7,7 @@
- Update CONTRIBUTING.md, support Py3.11
([#210](https://github.com/microsoft/ApplicationInsights-Python/pull/210))
- Updated setup.py, directory structure
([#210](https://github.com/microsoft/ApplicationInsights-Python/pull/210))
([#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

Просмотреть файл

@ -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
@ -18,4 +20,6 @@ class AzureMonitorDistro(BaseDistro):
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,15 +10,14 @@
import os
import re
from setuptools import setup, find_packages
from setuptools import find_packages, setup
# 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('-', '/')
package_folder_path = PACKAGE_NAME.replace("-", "/")
# azure v0.x is not compatible with this package
@ -29,8 +28,8 @@ try:
try:
ver = azure.__version__
raise Exception(
'This package is incompatible with azure=={}. '.format(ver) +
'Uninstall it with "pip uninstall azure".'
"This package is incompatible with azure=={}. ".format(ver)
+ 'Uninstall it with "pip uninstall azure".'
)
except AttributeError:
pass
@ -38,46 +37,51 @@ 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)
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')
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/microsoft/ApplicationInsights-Python/tree/main/azure-monitor-opentelemetry-distro',
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',
"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'
]),
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'],
"pytyped": ["py.typed"],
},
python_requires=">=3.7",
install_requires=[
@ -95,6 +99,5 @@ setup(
"opentelemetry_configurator": [
"azure_monitor_opentelemetry_configurator = azure.monitor.opentelemetry.distro.configurator:AzureMonitorConfigurator"
],
}
},
)

Просмотреть файл

@ -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):

Просмотреть файл

@ -19,4 +19,3 @@ class TestFlaskInstrumentation(unittest.TestCase):
self.fail(
f"Unexpected exception raised when instrumenting {FlaskInstrumentor.__name__}"
)

Просмотреть файл

@ -18,4 +18,3 @@ class TestPsycopg2Instrumentation(unittest.TestCase):
self.fail(
f"Unexpected exception raised when instrumenting {Psycopg2Instrumentor.__name__}"
)

Просмотреть файл

@ -18,4 +18,3 @@ class TestRequestsInstrumentation(unittest.TestCase):
self.fail(
f"Unexpected exception raised when instrumenting {RequestsInstrumentor.__name__}"
)

14
pyproject.toml Normal file
Просмотреть файл

@ -0,0 +1,14 @@
[tool.black]
line-length = 79
exclude = '''
(
/( # generated files
.github|
.tox|
.vscode|
venv|
.*/build/lib/.*|
scripts
)/
)
'''

Просмотреть файл

@ -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 {toxinidir}
; TODO
; pylint {toxinidir}
flake8 {toxinidir}