Skip to content

Commit 5434a7a

Browse files
authored
Merge branch 'main' into issue_1968
2 parents fd2fff4 + c1e8a51 commit 5434a7a

File tree

22 files changed

+309
-62
lines changed

22 files changed

+309
-62
lines changed

.github/workflows/test.yml

+31-14
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ env:
1010
# Otherwise, set variable to the commit of your branch on
1111
# opentelemetry-python-contrib which is compatible with these Core repo
1212
# changes.
13-
CONTRIB_REPO_SHA: 3ad534cbba41c2b92618f5f03c4c92cee4a72df6
13+
CONTRIB_REPO_SHA: dde62cebffe519c35875af6d06fae053b3be65ec
1414

1515
jobs:
1616
build:
@@ -20,15 +20,15 @@ jobs:
2020
py37: 3.7
2121
py38: 3.8
2222
py39: 3.9
23-
pypy3: pypy3
23+
pypy3: pypy-3.7
2424
RUN_MATRIX_COMBINATION: ${{ matrix.python-version }}-${{ matrix.package }}-${{ matrix.os }}
2525
runs-on: ${{ matrix.os }}
2626
strategy:
2727
fail-fast: false # ensures the entire test matrix is run, even if one permutation fails
2828
matrix:
2929
python-version: [ py36, py37, py38, py39, pypy3 ]
3030
package: ["instrumentation", "core", "exporter", "propagator"]
31-
os: [ ubuntu-latest ]
31+
os: [ ubuntu-20.04, windows-2019 ]
3232
steps:
3333
- name: Checkout Core Repo @ SHA - ${{ github.sha }}
3434
uses: actions/checkout@v2
@@ -42,14 +42,22 @@ jobs:
4242
uses: actions/setup-python@v2
4343
with:
4444
python-version: ${{ env[matrix.python-version] }}
45+
architecture: 'x64'
4546
- name: Install tox
4647
run: pip install -U tox-factor
4748
- name: Cache tox environment
4849
# Preserves .tox directory between runs for faster installs
4950
uses: actions/cache@v2
5051
with:
51-
path: .tox
52-
key: tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', 'dev-requirements.txt') }}-core
52+
path: |
53+
.tox
54+
~/.cache/pip
55+
key: v2-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', 'dev-requirements.txt') }}-core
56+
# tox fails on windows and Python3.6 when tox dir is reused between builds so we remove it
57+
- name: fix for windows + py3.6
58+
if: ${{ matrix.os == 'windows-2019' && matrix.python-version == 'py36' }}
59+
shell: pwsh
60+
run: Remove-Item .\.tox\ -Force -Recurse -ErrorAction Ignore
5361
- name: run tox
5462
run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- --benchmark-json=${{ env.RUN_MATRIX_COMBINATION }}-benchmark.json
5563
- name: Find and merge benchmarks
@@ -81,7 +89,7 @@ jobs:
8189
matrix:
8290
tox-environment: [ "docker-tests", "lint", "docs", "mypy", "mypyinstalled", "tracecontext" ]
8391
name: ${{ matrix.tox-environment }}
84-
runs-on: ubuntu-latest
92+
runs-on: ubuntu-20.04
8593
steps:
8694
- name: Checkout Core Repo @ SHA - ${{ github.sha }}
8795
uses: actions/checkout@v2
@@ -95,14 +103,17 @@ jobs:
95103
uses: actions/setup-python@v2
96104
with:
97105
python-version: 3.9
106+
architecture: 'x64'
98107
- name: Install tox
99108
run: pip install -U tox
100109
- name: Cache tox environment
101110
# Preserves .tox directory between runs for faster installs
102111
uses: actions/cache@v2
103112
with:
104-
path: .tox
105-
key: tox-cache-${{ matrix.tox-environment }}-${{ hashFiles('tox.ini', 'dev-requirements.txt') }}-core
113+
path: |
114+
.tox
115+
~/.cache/pip
116+
key: v2-tox-cache-${{ matrix.tox-environment }}-${{ hashFiles('tox.ini', 'dev-requirements.txt') }}-core
106117
- name: run tox
107118
run: tox -e ${{ matrix.tox-environment }}
108119
contrib-build:
@@ -119,7 +130,7 @@ jobs:
119130
matrix:
120131
python-version: [ py36, py37, py38, py39, pypy3 ]
121132
package: ["instrumentation", "exporter"]
122-
os: [ ubuntu-latest ]
133+
os: [ ubuntu-20.04]
123134
steps:
124135
- name: Checkout Contrib Repo @ SHA - ${{ env.CONTRIB_REPO_SHA }}
125136
uses: actions/checkout@v2
@@ -135,14 +146,17 @@ jobs:
135146
uses: actions/setup-python@v2
136147
with:
137148
python-version: ${{ env[matrix.python-version] }}
149+
architecture: 'x64'
138150
- name: Install tox
139151
run: pip install -U tox-factor
140152
- name: Cache tox environment
141153
# Preserves .tox directory between runs for faster installs
142154
uses: actions/cache@v2
143155
with:
144-
path: .tox
145-
key: tox-cache-${{ matrix.python-version }}-${{ matrix.package }}-${{ matrix.os }}-${{ hashFiles('tox.ini', 'dev-requirements.txt') }}-contrib
156+
path: |
157+
.tox
158+
~/.cache/pip
159+
key: v2-tox-cache-${{ matrix.python-version }}-${{ matrix.package }}-${{ matrix.os }}-${{ hashFiles('tox.ini', 'dev-requirements.txt') }}-contrib
146160
- name: run tox
147161
run: tox -f ${{ matrix.python-version }}-${{ matrix.package }}
148162
contrib-misc:
@@ -151,7 +165,7 @@ jobs:
151165
matrix:
152166
tox-environment: [ "docker-tests"]
153167
name: ${{ matrix.tox-environment }}
154-
runs-on: ubuntu-latest
168+
runs-on: ubuntu-20.04
155169
steps:
156170
- name: Checkout Contrib Repo @ SHA - ${{ env.CONTRIB_REPO_SHA }}
157171
uses: actions/checkout@v2
@@ -167,13 +181,16 @@ jobs:
167181
uses: actions/setup-python@v2
168182
with:
169183
python-version: 3.9
184+
architecture: 'x64'
170185
- name: Install tox
171186
run: pip install -U tox
172187
- name: Cache tox environment
173188
# Preserves .tox directory between runs for faster installs
174189
uses: actions/cache@v2
175190
with:
176-
path: .tox
177-
key: tox-cache-${{ matrix.tox-environment }}-${{ hashFiles('tox.ini', 'dev-requirements.txt') }}-contrib
191+
path: |
192+
.tox
193+
~/.cache/pip
194+
key: v2-tox-cache-${{ matrix.tox-environment }}-${{ hashFiles('tox.ini', 'dev-requirements.txt') }}-contrib
178195
- name: run tox
179196
run: tox -e ${{ matrix.tox-environment }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ build
1212
eggs
1313
parts
1414
bin
15+
include
1516
var
1617
sdist
1718
develop-eggs

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
- Automatically load OTEL environment variables as options for `opentelemetry-instrument`
99
([#1969](https://github.com/open-telemetry/opentelemetry-python/pull/1969))
1010

11+
- `opentelemetry-semantic-conventions` Update to semantic conventions v1.6.1
12+
([#2077](https://github.com/open-telemetry/opentelemetry-python/pull/2077))
13+
- Fix propagation bug caused by counting skipped entries
14+
([#2071](https://github.com/open-telemetry/opentelemetry-python/pull/2071))
15+
1116
## [1.5.0-0.24b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.5.0-0.24b0) - 2021-08-26
1217

1318
- Fix documentation on well known exporters and variable OTEL_TRACES_EXPORTER which were misnamed

dev-requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pylint==2.7.1
22
flake8~=3.7
33
isort~=5.8
4-
black~=20.8b1
4+
black~=21.7b0
55
httpretty~=1.0
66
mypy==0.812
77
sphinx~=3.5.4

docs/getting-started.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Getting Started with OpenTelemetry Python
2-
=========================================
1+
Getting Started
2+
===============
33

44
This guide walks you through instrumenting a Python application with ``opentelemetry-python``.
55

docs/getting_started/flask_example.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ def hello():
4444
return "hello"
4545

4646

47-
app.run(debug=True, port=5000)
47+
app.run(port=5000)

docs/index.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ The Python `OpenTelemetry <https://opentelemetry.io/>`_ client.
1111
This documentation describes the :doc:`opentelemetry-api <api/api>`,
1212
:doc:`opentelemetry-sdk <sdk/sdk>`, and several `integration packages <#integrations>`_.
1313

14-
**Please note** that this library is currently in _beta_, and shouldn't
15-
generally be used in production environments.
14+
The library is currently stable for tracing. Support for `metrics <https://github.com/open-telemetry/opentelemetry-python/tree/metrics>`_
15+
and `logging <https://github.com/open-telemetry/opentelemetry-python/tree/logs>`_ is currently under development and is considered
16+
experimental.
1617

1718
Requirement
1819
-----------

exporter/opentelemetry-exporter-jaeger/tests/test_jaeger.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# pylint:disable=no-member
2424
class TestJaegerExporter(unittest.TestCase):
2525
def test_constructors(self):
26-
""" Test ensures both exporters can co-exist"""
26+
"""Test ensures both exporters can co-exist"""
2727
try:
2828
grpc.JaegerExporter()
2929
thrift.JaegerExporter()

opentelemetry-api/src/opentelemetry/baggage/propagation/__init__.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
# limitations under the License.
1414
#
1515
import typing
16-
import urllib.parse
16+
from urllib.parse import quote_plus, unquote_plus
1717

18-
from opentelemetry import baggage
18+
from opentelemetry.baggage import get_all, set_baggage
1919
from opentelemetry.context import get_current
2020
from opentelemetry.context.context import Context
2121
from opentelemetry.propagators import textmap
@@ -54,20 +54,20 @@ def extract(
5454
baggage_entries = header.split(",")
5555
total_baggage_entries = self._MAX_PAIRS
5656
for entry in baggage_entries:
57-
if total_baggage_entries <= 0:
58-
return context
59-
total_baggage_entries -= 1
6057
if len(entry) > self._MAX_PAIR_LENGTH:
6158
continue
6259
try:
6360
name, value = entry.split("=", 1)
6461
except Exception: # pylint: disable=broad-except
6562
continue
66-
context = baggage.set_baggage(
67-
urllib.parse.unquote(name).strip(),
68-
urllib.parse.unquote(value).strip(),
63+
context = set_baggage(
64+
unquote_plus(name).strip(),
65+
unquote_plus(value).strip(),
6966
context=context,
7067
)
68+
total_baggage_entries -= 1
69+
if total_baggage_entries == 0:
70+
break
7171

7272
return context
7373

@@ -82,7 +82,7 @@ def inject(
8282
See
8383
`opentelemetry.propagators.textmap.TextMapPropagator.inject`
8484
"""
85-
baggage_entries = baggage.get_all(context=context)
85+
baggage_entries = get_all(context=context)
8686
if not baggage_entries:
8787
return
8888

@@ -97,7 +97,7 @@ def fields(self) -> typing.Set[str]:
9797

9898
def _format_baggage(baggage_entries: typing.Mapping[str, object]) -> str:
9999
return ",".join(
100-
key + "=" + urllib.parse.quote_plus(str(value))
100+
quote_plus(str(key)) + "=" + quote_plus(str(value))
101101
for key, value in baggage_entries.items()
102102
)
103103

opentelemetry-api/src/opentelemetry/context/context.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def attach(self, context: Context) -> object:
3939

4040
@abstractmethod
4141
def get_current(self) -> Context:
42-
"""Returns the current `Context` object. """
42+
"""Returns the current `Context` object."""
4343

4444
@abstractmethod
4545
def detach(self, token: object) -> None:

opentelemetry-api/src/opentelemetry/context/contextvars_context.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def attach(self, context: Context) -> object:
4444
return self._current_context.set(context)
4545

4646
def get_current(self) -> Context:
47-
"""Returns the current `Context` object. """
47+
"""Returns the current `Context` object."""
4848
return self._current_context.get()
4949

5050
def detach(self, token: object) -> None:

opentelemetry-api/tests/baggage/test_baggage_propagation.py

+63-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
from unittest.mock import Mock, patch
1919

2020
from opentelemetry import baggage
21-
from opentelemetry.baggage.propagation import W3CBaggagePropagator
21+
from opentelemetry.baggage.propagation import (
22+
W3CBaggagePropagator,
23+
_format_baggage,
24+
)
2225
from opentelemetry.context import get_current
2326

2427

@@ -106,6 +109,55 @@ def test_header_contains_pair_too_long(self):
106109
expected = {"key1": "value1", "key3": "value3"}
107110
self.assertEqual(self._extract(header), expected)
108111

112+
def test_extract_unquote_plus(self):
113+
self.assertEqual(
114+
self._extract("key+key=value+value"), {"key key": "value value"}
115+
)
116+
self.assertEqual(
117+
self._extract("key%2Fkey=value%2Fvalue"),
118+
{"key/key": "value/value"},
119+
)
120+
121+
def test_header_max_entries_skip_invalid_entry(self):
122+
123+
self.assertEqual(
124+
self._extract(
125+
",".join(
126+
[
127+
f"key{index}=value{index}"
128+
if index != 2
129+
else (
130+
f"key{index}="
131+
f"value{'s' * (W3CBaggagePropagator._MAX_PAIR_LENGTH + 1)}"
132+
)
133+
for index in range(W3CBaggagePropagator._MAX_PAIRS + 1)
134+
]
135+
)
136+
),
137+
{
138+
f"key{index}": f"value{index}"
139+
for index in range(W3CBaggagePropagator._MAX_PAIRS + 1)
140+
if index != 2
141+
},
142+
)
143+
self.assertEqual(
144+
self._extract(
145+
",".join(
146+
[
147+
f"key{index}=value{index}"
148+
if index != 2
149+
else f"key{index}xvalue{index}"
150+
for index in range(W3CBaggagePropagator._MAX_PAIRS + 1)
151+
]
152+
)
153+
),
154+
{
155+
f"key{index}": f"value{index}"
156+
for index in range(W3CBaggagePropagator._MAX_PAIRS + 1)
157+
if index != 2
158+
},
159+
)
160+
109161
def test_inject_no_baggage_entries(self):
110162
values = {}
111163
output = self._inject(values)
@@ -140,7 +192,7 @@ def test_inject_non_string_values(self):
140192
self.assertIn("key2=123", output)
141193
self.assertIn("key3=123.567", output)
142194

143-
@patch("opentelemetry.baggage.propagation.baggage")
195+
@patch("opentelemetry.baggage.propagation.get_all")
144196
@patch("opentelemetry.baggage.propagation._format_baggage")
145197
def test_fields(self, mock_format_baggage, mock_baggage):
146198

@@ -154,3 +206,12 @@ def test_fields(self, mock_format_baggage, mock_baggage):
154206
inject_fields.add(mock_call[1][1])
155207

156208
self.assertEqual(inject_fields, self.propagator.fields)
209+
210+
def test__format_baggage(self):
211+
self.assertEqual(
212+
_format_baggage({"key key": "value value"}), "key+key=value+value"
213+
)
214+
self.assertEqual(
215+
_format_baggage({"key/key": "value/value"}),
216+
"key%2Fkey=value%2Fvalue",
217+
)

opentelemetry-semantic-conventions/README.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ Installation
1818
Code Generation
1919
---------------
2020

21-
These files were generated automatically from code in opentelemetry-semantic-conventions_.
21+
These files were generated automatically from code in semconv_.
2222
To regenerate the code, run ``../scripts/semconv/generate.sh``.
2323

24-
To build against a new release or specific commit of opentelemetry-semantic-conventions_,
24+
To build against a new release or specific commit of opentelemetry-specification_,
2525
update the ``SPEC_VERSION`` variable in
2626
``../scripts/semconv/generate.sh``. Then run the script and commit the changes.
2727

28-
.. _opentelemetry-semantic-conventions: https://github.com/open-telemetry/opentelemetry-semantic-conventions
28+
.. _opentelemetry-specification: https://github.com/open-telemetry/opentelemetry-specification
29+
.. _semconv: https://github.com/open-telemetry/opentelemetry-python/tree/main/scripts/semconv
2930

3031

3132
References

0 commit comments

Comments
 (0)