Skip to content

Commit 57ec4f9

Browse files
committed
Merge remote-tracking branch 'ot/master' into utils-package
2 parents 3870e3b + 602ddb0 commit 57ec4f9

File tree

97 files changed

+1171
-244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+1171
-244
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ Meeting notes are available as a public [Google doc](https://docs.google.com/doc
103103

104104
Approvers ([@open-telemetry/python-approvers](https://github.com/orgs/open-telemetry/teams/python-approvers)):
105105

106-
- [Alex Boten](https://github.com/codeboten), LightStep
107106
- [Carlos Alberto Cortez](https://github.com/carlosalberto), LightStep
107+
- [Chris Kleinknecht](https://github.com/c24t), Google
108108
- [Christian Neumüller](https://github.com/Oberon00), Dynatrace
109+
- [Diego Hurtado](https://github.com/ocelotl)
109110
- [Hector Hernandez](https://github.com/hectorhdzg), Microsoft
110111
- [Leighton Chen](https://github.com/lzchen), Microsoft
111112
- [Mauricio Vásquez](https://github.com/mauriciovasquezbernal), Kinvolk
@@ -115,7 +116,7 @@ Approvers ([@open-telemetry/python-approvers](https://github.com/orgs/open-telem
115116

116117
Maintainers ([@open-telemetry/python-maintainers](https://github.com/orgs/open-telemetry/teams/python-maintainers)):
117118

118-
- [Chris Kleinknecht](https://github.com/c24t), Google
119+
- [Alex Boten](https://github.com/codeboten), LightStep
119120
- [Yusuke Tsutsumi](https://github.com/toumorokoshi), Zillow Group
120121

121122
*Find more about the maintainer role in [community repository](https://github.com/open-telemetry/community/blob/master/community-membership.md#maintainer).*

RELEASING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
This document explains how to publish all OT modules at version x.y.z. Ensure that you’re following semver when choosing a version number.
33

44
Release Process:
5+
* [Checkout a clean repo](#checkout-a-clean-repo)
56
* [Create a new branch](#create-a-new-branch)
67
* [Open a Pull Request](#open-a-pull-request)
78
* [Create a Release](#Create-a-Release)
@@ -10,6 +11,8 @@ Release Process:
1011
* [Check PyPI](#Check-PyPI)
1112
* [Troubleshooting](#troubleshooting)
1213

14+
## Checkout a clean repo
15+
- To avoid pushing untracked changes, check out the repo in a new dir
1316

1417
## Create a new branch
1518
The following script does the following:
@@ -74,7 +77,6 @@ git commit -m
7477

7578
If for some reason the action failed, do it manually:
7679

77-
- To avoid pushing untracked changes, check out the repo in a new dir
7880
- Switch to the release branch (important so we don't publish packages with "dev" versions)
7981
- Build distributions with `./scripts/build.sh`
8082
- Delete distributions we don't want to push (e.g. `testutil`)

docs-requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sphinx-autodoc-typehints~=1.10.2
55
# Required by ext packages
66
asgiref~=3.0
77
ddtrace>=0.34.0
8-
aiohttp ~= 3.0
8+
aiohttp~= 3.0
99
Deprecated>=1.2.6
1010
django>=2.2
1111
PyMySQL~=0.9.3
@@ -18,4 +18,5 @@ pymongo~=3.1
1818
redis>=2.6
1919
sqlalchemy>=1.0
2020
thrift>=0.10.0
21-
wrapt >=1.0.0,<2.0.0
21+
wrapt>=1.0.0,<2.0.0
22+
psutil~=5.7.0

docs/examples/opentelemetry-example-app/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
setuptools.setup(
1818
name="opentelemetry-example-app",
19-
version="0.8.dev0",
19+
version="0.9.dev0",
2020
author="OpenTelemetry Authors",
2121
author_email="[email protected]",
2222
classifiers=[
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
OpenTelemetry System Metrics Instrumentation
2+
============================================
3+
4+
.. automodule:: opentelemetry.ext.system_metrics
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

ext/opentelemetry-ext-aiohttp-client/setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ package_dir=
3939
=src
4040
packages=find_namespace:
4141
install_requires =
42-
opentelemetry-api >= 0.8.dev0
43-
opentelemetry-instrumentation-utils == 0.8.dev0
42+
opentelemetry-api >= 0.9.dev0
43+
opentelemetry-instrumentation-utils == 0.9.dev0
4444
aiohttp ~= 3.0
4545

4646
[options.packages.find]

ext/opentelemetry-ext-aiohttp-client/src/opentelemetry/ext/aiohttp_client/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = "0.8.dev0"
15+
__version__ = "0.9.dev0"

ext/opentelemetry-ext-asgi/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
## Unreleased
44

5+
## 0.8b0
6+
7+
Released 2020-05-27
8+
59
- Add ASGI middleware ([#716](https://github.com/open-telemetry/opentelemetry-python/pull/716))

ext/opentelemetry-ext-asgi/setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ package_dir=
3939
=src
4040
packages=find_namespace:
4141
install_requires =
42-
opentelemetry-api == 0.8.dev0
42+
opentelemetry-api == 0.9.dev0
4343
asgiref ~= 3.0
4444

4545
[options.extras_require]

ext/opentelemetry-ext-asgi/src/opentelemetry/ext/asgi/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = "0.8.dev0"
15+
__version__ = "0.9.dev0"

ext/opentelemetry-ext-datadog/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
## 0.8b0
6+
7+
Released 2020-05-27
8+
59
- Add exporter to Datadog
610
([#572](https://github.com/open-telemetry/opentelemetry-python/pull/572))
711

ext/opentelemetry-ext-datadog/setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ package_dir=
4040
packages=find_namespace:
4141
install_requires =
4242
ddtrace>=0.34.0
43-
opentelemetry-api==0.8.dev0
44-
opentelemetry-sdk==0.8.dev0
43+
opentelemetry-api==0.9.dev0
44+
opentelemetry-sdk==0.9.dev0
4545

4646
[options.packages.find]
4747
where = src

ext/opentelemetry-ext-datadog/src/opentelemetry/ext/datadog/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
AUTO_REJECT = 0
33
AUTO_KEEP = 1
44
USER_KEEP = 2
5+
SAMPLE_RATE_METRIC_KEY = "_sample_rate"
6+
SAMPLING_PRIORITY_KEY = "_sampling_priority_v1"

ext/opentelemetry-ext-datadog/src/opentelemetry/ext/datadog/exporter.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from opentelemetry.trace.status import StatusCanonicalCode
2626

2727
# pylint:disable=relative-beyond-top-level
28-
from .constants import DD_ORIGIN
28+
from .constants import DD_ORIGIN, SAMPLE_RATE_METRIC_KEY
2929

3030
logger = logging.getLogger(__name__)
3131

@@ -136,6 +136,10 @@ def _translate_to_datadog(self, spans):
136136
if origin and parent_id == 0:
137137
datadog_span.set_tag(DD_ORIGIN, origin)
138138

139+
sampling_rate = _get_sampling_rate(span)
140+
if sampling_rate is not None:
141+
datadog_span.set_metric(SAMPLE_RATE_METRIC_KEY, sampling_rate)
142+
139143
# span events and span links are not supported
140144

141145
datadog_spans.append(datadog_span)
@@ -216,3 +220,13 @@ def _get_origin(span):
216220
ctx = span.get_context()
217221
origin = ctx.trace_state.get(DD_ORIGIN)
218222
return origin
223+
224+
225+
def _get_sampling_rate(span):
226+
ctx = span.get_context()
227+
return (
228+
span.sampler.rate
229+
if ctx.trace_flags.sampled
230+
and isinstance(span.sampler, trace_api.sampling.ProbabilitySampler)
231+
else None
232+
)

ext/opentelemetry-ext-datadog/src/opentelemetry/ext/datadog/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = "0.8.dev0"
15+
__version__ = "0.9.dev0"

ext/opentelemetry-ext-datadog/tests/test_datadog_exporter.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,3 +440,35 @@ def test_origin(self):
440440
]
441441
expected = ["origin-service", None]
442442
self.assertListEqual(actual, expected)
443+
444+
def test_sampling_rate(self):
445+
context = trace_api.SpanContext(
446+
trace_id=0x000000000000000000000000DEADBEEF,
447+
span_id=0x34BF92DEEFC58C92,
448+
is_remote=False,
449+
trace_flags=trace_api.TraceFlags(trace_api.TraceFlags.SAMPLED),
450+
)
451+
sampler = trace_api.sampling.ProbabilitySampler(0.5)
452+
453+
span = trace.Span(
454+
name="sampled", context=context, parent=None, sampler=sampler
455+
)
456+
span.start()
457+
span.end()
458+
459+
# pylint: disable=protected-access
460+
exporter = datadog.DatadogSpanExporter()
461+
datadog_spans = [
462+
span.to_dict() for span in exporter._translate_to_datadog([span])
463+
]
464+
465+
self.assertEqual(len(datadog_spans), 1)
466+
467+
actual = [
468+
span["metrics"].get(datadog.constants.SAMPLE_RATE_METRIC_KEY)
469+
if "metrics" in span
470+
else None
471+
for span in datadog_spans
472+
]
473+
expected = [0.5]
474+
self.assertListEqual(actual, expected)

ext/opentelemetry-ext-dbapi/setup.cfg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ package_dir=
4040
=src
4141
packages=find_namespace:
4242
install_requires =
43-
opentelemetry-api == 0.8.dev0
44-
opentelemetry-instrumentation-utils == 0.8.dev0
43+
opentelemetry-api == 0.9.dev0
44+
opentelemetry-instrumentation-utils == 0.9.dev0
4545
wrapt >= 1.0.0, < 2.0.0
4646

4747
[options.extras_require]
4848
test =
49-
opentelemetry-test == 0.8.dev0
49+
opentelemetry-test == 0.9.dev0
5050

5151
[options.packages.find]
5252
where = src

ext/opentelemetry-ext-dbapi/src/opentelemetry/ext/dbapi/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = "0.8.dev0"
15+
__version__ = "0.9.dev0"

ext/opentelemetry-ext-django/CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
## Unreleased
44

5-
- Add support for django >= 1.10 (#717)
5+
## 0.8b0
6+
7+
Released 2020-05-27
8+
9+
- Add exclude list for paths and hosts to prevent from tracing
10+
([#670](https://github.com/open-telemetry/opentelemetry-python/pull/670))
11+
- Add support for django >= 1.10 (#717)
612

713
## 0.7b1
814

ext/opentelemetry-ext-django/README.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ Installation
1515

1616
pip install opentelemetry-ext-django
1717

18+
Configuration
19+
-------------
20+
21+
Exclude lists
22+
*************
23+
Excludes certain hosts and paths from being tracked. Pass in comma delimited string into environment variables.
24+
Host refers to the entire url and path refers to the part of the url after the domain. Host matches the exact string that is given, where as path matches if the url starts with the given excluded path.
25+
26+
Excluded hosts: OPENTELEMETRY_PYTHON_DJANGO_EXCLUDED_HOSTS
27+
Excluded paths: OPENTELEMETRY_PYTHON_DJANGO_EXCLUDED_PATHS
1828

1929
References
2030
----------

ext/opentelemetry-ext-django/setup.cfg

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ package_dir=
4141
packages=find_namespace:
4242
install_requires =
4343
django >= 1.10
44-
opentelemetry-ext-wsgi == 0.8.dev0
45-
opentelemetry-auto-instrumentation == 0.8.dev0
46-
opentelemetry-api == 0.8.dev0
44+
opentelemetry-ext-wsgi == 0.9.dev0
45+
opentelemetry-auto-instrumentation == 0.9.dev0
46+
opentelemetry-api == 0.9.dev0
4747

4848
[options.extras_require]
4949
test =
50-
opentelemetry-test == 0.8.dev0
50+
opentelemetry-test == 0.9.dev0
5151

5252
[options.packages.find]
5353
where = src

ext/opentelemetry-ext-django/src/opentelemetry/ext/django/middleware.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from logging import getLogger
1616

17+
from opentelemetry.configuration import Configuration
1718
from opentelemetry.context import attach, detach
1819
from opentelemetry.ext.django.version import __version__
1920
from opentelemetry.ext.wsgi import (
@@ -23,6 +24,7 @@
2324
)
2425
from opentelemetry.propagators import extract
2526
from opentelemetry.trace import SpanKind, get_tracer
27+
from opentelemetry.util import disable_trace
2628

2729
try:
2830
from django.utils.deprecation import MiddlewareMixin
@@ -42,6 +44,13 @@ class _DjangoMiddleware(MiddlewareMixin):
4244
_environ_token = "opentelemetry-instrumentor-django.token"
4345
_environ_span_key = "opentelemetry-instrumentor-django.span_key"
4446

47+
_excluded_hosts = Configuration().DJANGO_EXCLUDED_HOSTS or []
48+
_excluded_paths = Configuration().DJANGO_EXCLUDED_PATHS or []
49+
if _excluded_hosts:
50+
_excluded_hosts = str.split(_excluded_hosts, ",")
51+
if _excluded_paths:
52+
_excluded_paths = str.split(_excluded_paths, ",")
53+
4554
def process_view(
4655
self, request, view_func, view_args, view_kwargs
4756
): # pylint: disable=unused-argument
@@ -53,6 +62,12 @@ def process_view(
5362
# key.lower().replace('_', '-').replace("http-", "", 1): value
5463
# for key, value in request.META.items()
5564
# }
65+
if disable_trace(
66+
request.build_absolute_uri("?"),
67+
self._excluded_hosts,
68+
self._excluded_paths,
69+
):
70+
return
5671

5772
environ = request.META
5873

@@ -82,6 +97,13 @@ def process_exception(self, request, exception):
8297
# Django can call this method and process_response later. In order
8398
# to avoid __exit__ and detach from being called twice then, the
8499
# respective keys are being removed here.
100+
if disable_trace(
101+
request.build_absolute_uri("?"),
102+
self._excluded_hosts,
103+
self._excluded_paths,
104+
):
105+
return
106+
85107
if self._environ_activation_key in request.META.keys():
86108
request.META[self._environ_activation_key].__exit__(
87109
type(exception),
@@ -94,6 +116,13 @@ def process_exception(self, request, exception):
94116
request.META.pop(self._environ_token, None)
95117

96118
def process_response(self, request, response):
119+
if disable_trace(
120+
request.build_absolute_uri("?"),
121+
self._excluded_hosts,
122+
self._excluded_paths,
123+
):
124+
return response
125+
97126
if (
98127
self._environ_activation_key in request.META.keys()
99128
and self._environ_span_key in request.META.keys()

ext/opentelemetry-ext-django/src/opentelemetry/ext/django/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = "0.8.dev0"
15+
__version__ = "0.9.dev0"

0 commit comments

Comments
 (0)