Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into fix_b3_missing_headers
Browse files Browse the repository at this point in the history
  • Loading branch information
cshowe committed Dec 31, 2018
2 parents 54e3e5b + 22859a3 commit 378d74d
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ after_success:
- if [ "$COVER" = "1" ]; then codecov -v ; fi

after_failure:
- timeout 5 if [ "$CROSSDOCK" = "1" ]; then make crossdock-logs ; fi
- if [ "$CROSSDOCK" = "1" ]; then make crossdock-logs ; fi
18 changes: 17 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,28 @@
History
-------

3.11.1 (unreleased)
3.13.1 (unreleased)
-------------------

- Nothing changed yet.


3.13.0 (2018-12-04)
-------------------

- Mark reporter_queue_size Config option as valid (#209) <Tim Joseph Dumol>
- Allow setting of the Jaeger Agent Host via environment variable (#218) <Tim Stoop>
- Wrap parsing of throttling response in try block to avoid errors (#219) <Isaac Hier>


3.12.0 (2018-11-02)
-------------------

- Support deleting key from baggage (#216) <TianYi ZHU>
- Preserve datatype of tag values (#213) <Trond Hindenes>
- Support `jaeger-baggage` header for ad-hoc baggage (#207) <Yuri Shkuro>


3.11.0 (2018-08-02)
-------------------

Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ We gratefully welcome improvements to documentation as well as to code.

## Developing

Jaeger Python client currently only supports Python 2.7.

This repository uses [virtualenv](https://pypi.python.org/pypi/virtualenv) and `pip` to manage dependencies.
To install all dependencies, run:

Expand All @@ -37,7 +35,9 @@ It can be fixed with:

```
pip uninstall pycurl
pip install --install-option="--with-openssl" --install-option="--openssl-dir=/usr/local/opt/openssl" pycurl
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
pip install --no-cache-dir --compile --ignore-installed --install-option="--with-openssl" pycurl
```

## Making A Change
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ bootstrap:
pip install virtualenv
python setup.py develop


.PHONY: test
test: clean
$(pytest) $(test_args) --benchmark-skip
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov] [![PyPI version][pypi-img]][pypi] [![FOSSA Status][fossa-img]][fossa]
[![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov] [![PyPI Version][pypi-img]][pypi] [![Python Version][pythonversion-img]][pythonversion] [![FOSSA Status][fossa-img]][fossa]

# Jaeger Bindings for Python OpenTracing API

Expand Down Expand Up @@ -166,5 +166,7 @@ Please make sure your framework does the same.
[cov]: https://codecov.io/gh/jaegertracing/jaeger-client-python
[pypi-img]: https://badge.fury.io/py/jaeger-client.svg
[pypi]: https://badge.fury.io/py/jaeger-client
[pythonversion-img]: https://img.shields.io/pypi/pyversions/jaeger-client.svg
[pythonversion]: https://pypi.org/project/jaeger-client
[fossa-img]: https://app.fossa.io/api/projects/git%2Bgithub.51.al%2Fjaegertracing%2Fjaeger-client-python.svg?type=shield
[fossa]: https://app.fossa.io/projects/git%2Bgithub.51.al%2Fjaegertracing%2Fjaeger-client-python?ref=badge_shield
2 changes: 1 addition & 1 deletion crossdock/rules.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
XDOCK_YAML=crossdock/docker-compose.yml
TRACETEST_THRIFT=idl/thrift/crossdock/tracetest.thrift
JAEGER_COMPOSE_URL=https://github.com/jaegertracing/jaeger/master/docker-compose/jaeger-docker-compose.yml
JAEGER_COMPOSE_URL=https://github.com/jaegertracing/jaeger/master/crossdock/jaeger-docker-compose.yml
XDOCK_JAEGER_YAML=crossdock/jaeger-docker-compose.yml

.PHONY: clean-compile
Expand Down
2 changes: 1 addition & 1 deletion jaeger_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import jaeger_client.thrift_gen as modpath
sys.path.append(modpath.__path__[0])

__version__ = '3.11.1.dev0'
__version__ = '3.13.1.dev0'

from .tracer import Tracer # noqa
from .config import Config # noqa
Expand Down
6 changes: 6 additions & 0 deletions jaeger_client/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def _validate_config(self, config):
'tags',
'enabled',
'reporter_batch_size',
'reporter_queue_size',
'propagation',
'max_tag_value_length',
'reporter_flush_interval',
Expand Down Expand Up @@ -259,6 +260,11 @@ def local_agent_reporting_host(self):
try:
return self.local_agent_group()['reporting_host']
except:
pass

if os.getenv('JAEGER_AGENT_HOST') is not None:
return os.getenv('JAEGER_AGENT_HOST')
else:
return DEFAULT_REPORTING_HOST

@property
Expand Down
5 changes: 4 additions & 1 deletion jaeger_client/span_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ def baggage(self):

def with_baggage_item(self, key, value):
baggage = dict(self._baggage)
baggage[key] = value
if value is not None:
baggage[key] = value
else:
baggage.pop(key, None)
return SpanContext(
trace_id=self.trace_id,
span_id=self.span_id,
Expand Down
5 changes: 2 additions & 3 deletions jaeger_client/throttler.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,15 @@ def _request_callback(self, future):
throttling_response = json.loads(response_body)
self.logger.debug('Received throttling response: %s',
throttling_response)
self._update_credits(throttling_response)
self.metrics.throttler_update_success(1)
except Exception as e:
self.metrics.throttler_update_failure(1)
self.error_reporter.error(
'Fail to parse throttling credits response '
'Failed to parse throttling credits response '
'from jaeger-agent: %s [%s]', e, response_body)
return

self._update_credits(throttling_response)

def _update_credits(self, response):
with self.lock:
for op_balance in response['balances']:
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
],
install_requires=[
Expand All @@ -53,7 +54,8 @@
'tests': [
'mock==1.0.1',
'pycurl>=7.43,<8',
'pytest>=3.6.0',
# pinned to avoid RemovedInPytest4Warning
'pytest>=3.7.0,<3.8.0',
'pytest-cov==2.5.1',
'coverage<4.4', # can remove after https://bitbucket.org/ned/coveragepy/issues/581/44b1-44-breaking-in-ci
'pytest-timeout==1.3.1',
Expand Down
8 changes: 8 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ def test_agent_reporting_host(self):
c = Config({'local_agent': {'reporting_host': 'jaeger.local'}}, service_name='x')
assert c.local_agent_reporting_host == 'jaeger.local'

os.environ['JAEGER_AGENT_HOST'] = 'jaeger-env.local'
c = Config({}, service_name='x')
assert c.local_agent_reporting_host == 'jaeger-env.local'

def test_max_tag_value_length(self):
c = Config({}, service_name='x')
assert c.max_tag_value_length == constants.MAX_TAG_VALUE_LENGTH
Expand Down Expand Up @@ -131,6 +135,10 @@ def test_for_unexpected_config_entries(self):
with self.assertRaises(Exception):
_ = Config({"unexpected":"value"}, validate=True)

def test_reporter_queue_size_valid(self):
config = Config({"reporter_queue_size": 100}, service_name='x', validate=True)
assert config.reporter_queue_size == 100

def test_missing_service_name(self):
with self.assertRaises(ValueError):
_ = Config({})
Expand Down
13 changes: 12 additions & 1 deletion tests/test_span.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def test_baggage():
span.set_baggage_item('X_y', '123')
assert span.get_baggage_item('X_y') == '123'
assert span.get_baggage_item('x-Y') is None
span.set_baggage_item('nonExistingKey', None).set_baggage_item('z', None)
assert 'z' not in span.context.baggage


def _fields_to_dict(span_log):
Expand All @@ -63,6 +65,12 @@ def test_baggage_logs():
assert _fields_to_dict(span.logs[1]) == {
"event": "baggage", "key": "x", "value": "b", "override": "true",
}
span.set_baggage_item('x', None) # deletion
assert span.get_baggage_item('x') is None
assert len(span.logs) == 3
assert _fields_to_dict(span.logs[2]) == {
"event": "baggage", "key": "x", "value": "None", "override": "true"
}


def test_is_rpc():
Expand Down Expand Up @@ -100,6 +108,7 @@ def test_sampling_priority(tracer):
span.set_tag(ext_tags.SAMPLING_PRIORITY, 'test')
assert span.is_sampled() is False


def test_span_logging(tracer):
tpl = collections.namedtuple(
'Test',
Expand Down Expand Up @@ -229,16 +238,18 @@ def test_span_tag_value_max_length(tracer):
assert span.tags[tag_n].key == 'x'
assert span.tags[tag_n].vStr == 'x' * 42


def test_span_tag_bool(tracer):
span = tracer.start_span(operation_name='y')
span.set_tag('y', True)
tag_n = len(span.tags) - 1
assert span.tags[tag_n].key == 'y'
assert span.tags[tag_n].vBool is True


def test_span_tag_long(tracer):
span = tracer.start_span(operation_name='z')
span.set_tag('z', 200)
tag_n = len(span.tags) - 1
assert span.tags[tag_n].key == 'z'
assert span.tags[tag_n].vLong == 200
assert span.tags[tag_n].vLong == 200
6 changes: 6 additions & 0 deletions tests/test_span_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def test_parent_id_to_none():
ctx1 = SpanContext(trace_id=1, span_id=2, parent_id=0, flags=1)
assert ctx1.parent_id is None


def test_with_baggage_items():
baggage1 = {'x': 'y'}
ctx1 = SpanContext(trace_id=1, span_id=2, parent_id=3, flags=1,
Expand All @@ -34,6 +35,11 @@ def test_with_baggage_items():
baggage1['a'] = 'b'
assert ctx1.baggage == ctx2.baggage

ctx3 = ctx2.with_baggage_item('a', None)
assert ctx2.baggage != ctx3.baggage
baggage1.pop('a')
assert ctx3.baggage == baggage1


def test_is_debug_id_container_only():
ctx = SpanContext.with_debug_id('value1')
Expand Down
2 changes: 1 addition & 1 deletion tests/test_throttler.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ def test_throttler_request_callback():
throttler._request_callback(future)
assert throttler.credits['test-operation'] == 2.0

future.result.return_value.body = 'bad json'
future.result.return_value.body = '{ "bad": "json" }'
throttler._request_callback(future)
assert throttler.error_reporter.error.call_count == 2

0 comments on commit 378d74d

Please sign in to comment.