Skip to content

Commit

Permalink
Add stub tracer SDK (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
c24t authored Jul 17, 2019
1 parent 3d0046a commit 7a7a207
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 29 deletions.
10 changes: 5 additions & 5 deletions opentelemetry-api/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
import setuptools

BASE_DIR = os.path.dirname(__file__)
VERSION_FILENAME = os.path.join(
BASE_DIR, "src", "opentelemetry", "internal", "version.py")
VERSION_FILENAME = os.path.join(BASE_DIR, "src", "opentelemetry", "version.py")
PACKAGE_INFO = {}
with open(VERSION_FILENAME) as f:
exec(f.read(), PACKAGE_INFO) #pylint:disable=exec-used
exec(f.read(), PACKAGE_INFO)

setuptools.setup(
name="opentelemetry-api",
version=PACKAGE_INFO["__version__"], # noqa
version=PACKAGE_INFO["__version__"],
author="OpenTelemetry Authors",
author_email="[email protected]",
classifiers=[
Expand All @@ -47,7 +46,8 @@
extras_require={},
license="Apache-2.0",
package_dir={"": "src"},
packages=setuptools.find_namespace_packages(where="src"),
packages=setuptools.find_namespace_packages(where="src",
include="opentelemetry.*"),
url=("https://github.com/open-telemetry/opentelemetry-python"
"/tree/master/opentelemetry-api"),
zip_safe=False,
Expand Down
3 changes: 1 addition & 2 deletions opentelemetry-api/src/opentelemetry/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
created as children of the currently active span, and the newly-created span
becomes the new active span::
# TODO (#15): which module holds the global tracer?
from opentelemetry.api.trace import tracer
from opentelemetry.trace import tracer
# Create a new root span, set it as the current span in context
with tracer.start_span("parent"):
Expand Down
20 changes: 12 additions & 8 deletions opentelemetry-sdk/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
import os
import setuptools

base_dir = os.path.dirname(__file__)

package_info = {}
with open(os.path.join(base_dir, "src", "opentelemetry", "sdk", "version.py")) as f:
exec(f.read(), package_info)
BASE_DIR = os.path.dirname(__file__)
VERSION_FILENAME = os.path.join(BASE_DIR, "src", "opentelemetry", "sdk",
"version.py")
PACKAGE_INFO = {}
with open(VERSION_FILENAME) as f:
exec(f.read(), PACKAGE_INFO)

setuptools.setup(
name="opentelemetry-sdk",
version=package_info["__version__"], # noqa
version=PACKAGE_INFO["__version__"],
author="OpenTelemetry Authors",
author_email="[email protected]",
classifiers=[
Expand All @@ -41,11 +42,14 @@
include_package_data=True,
long_description=open("README.rst").read(),
install_requires=[
"opentelemetry-api==0.1.dev0"
],
extras_require={},
license="Apache-2.0",
package_dir={"": "src"},
packages=setuptools.find_namespace_packages(where="src"),
url="https://github.com/open-telemetry/opentelemetry-python/tree/master/opentelemetry-sdk",
packages=setuptools.find_namespace_packages(where="src",
include="opentelemetry.sdk.*"),
url=("https://github.com/open-telemetry/opentelemetry-python"
"/tree/master/opentelemetry-sdk"),
zip_safe=False,
)
6 changes: 5 additions & 1 deletion opentelemetry-sdk/src/opentelemetry/sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .version import __version__
from . import trace

__all__ = [
"trace",
]
19 changes: 19 additions & 0 deletions opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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 import trace as trace_api


class Tracer(trace_api.Tracer):
pass
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,3 @@
# 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 .version import __version__

__all__ = [
"__version__",
]
25 changes: 25 additions & 0 deletions opentelemetry-sdk/tests/trace/test_trace.py
Original file line number Diff line number Diff line change
@@ -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.

import unittest

from opentelemetry import trace as trace_api
from opentelemetry.sdk import trace


class TestTracer(unittest.TestCase):

def test_extends_api(self):
tracer = trace.Tracer()
self.assertIsInstance(tracer, trace_api.Tracer)
22 changes: 15 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
skipsdist = True
envlist = py{34,35,36,37}-test, lint, py37-mypy, docs
envlist = py{34,35,36,37}-test-{api,sdk}, lint, py37-mypy, docs

[travis]
python =
Expand All @@ -11,24 +11,32 @@ deps =
mypy: mypy~=0.711

setenv =
PYTHONPATH={toxinidir}/opentelemetry-api/src/
mypy: MYPYPATH={env:PYTHONPATH}
mypy: MYPYPATH={toxinidir}/opentelemetry-api/src/

changedir =
test: opentelemetry-api/tests
test-api: opentelemetry-api/tests
test-sdk: opentelemetry-sdk/tests

commands_pre =
test-api: pip install -e {toxinidir}/opentelemetry-api
test-sdk: pip install -e {toxinidir}/opentelemetry-api
test-sdk: pip install -e {toxinidir}/opentelemetry-sdk

commands =
py37-mypy: mypy opentelemetry-api/src/opentelemetry/
mypy: mypy --namespace-packages opentelemetry-api/src/opentelemetry/
; For test code, we don't want to enforce the full mypy strictness
py37-mypy: mypy --config-file=mypy-relaxed.ini opentelemetry-api/tests/ opentelemetry-api/setup.py
test: python -m unittest discover
mypy: mypy --namespace-packages --config-file=mypy-relaxed.ini opentelemetry-api/tests/
test-{api,sdk}: python -m unittest discover

[testenv:lint]
deps =
pylint~=2.3
flake8~=3.7
isort~=4.3

commands_pre =
pip install -e {toxinidir}/opentelemetry-api

commands =
; Prefer putting everything in one pylint command to profit from duplication
; warnings.
Expand Down

0 comments on commit 7a7a207

Please sign in to comment.