Skip to content

Commit

Permalink
add plaintext for lightstep
Browse files Browse the repository at this point in the history
set OPENTRACING_LIGHTSTEP_COLLECTOR_SCHEME=http to get this.
Can be used to connect to satellites offering just http connections
  • Loading branch information
vetinari committed Oct 5, 2020
1 parent cc2c2b7 commit 802f602
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
10 changes: 9 additions & 1 deletion opentracing_utils/tracers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,21 @@ def init_opentracing_tracer(tracer, **kwargs):
verbosity = kwargs.pop(
'verbosity',
int(os.environ.get('OPENTRACING_LIGHTSTEP_VERBOSITY', 0)))
scheme = kwargs.pop(
'collector_scheme',
os.environ.get('OPENTRACING_LIGHTSTEP_COLLECTOR_SCHEME', 'https'))

if not access_token:
logger.warning('Initializing LightStep tracer with no access_token!')

opentracing_encryption = "tls"
if scheme == "http":
opentracing_encryption = "none"

opentracing.tracer = lightstep.Tracer(
component_name=component_name, access_token=access_token, collector_host=collector_host,
collector_port=collector_port, verbosity=verbosity, **kwargs)
collector_port=collector_port, opentracing_encryption=opentracing_encryption, verbosity=verbosity,
**kwargs)
elif tracer == OPENTRACING_JAEGER:
from jaeger_client import Config

Expand Down
22 changes: 20 additions & 2 deletions tests/test_tracers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_init_lightstep(monkeypatch):

tracer.assert_called_once_with(
component_name='test_lightstep', access_token=None, collector_host='collector.lightstep.com',
collector_port=443, verbosity=2)
collector_port=443, opentracing_encryption="tls", verbosity=2)


def test_init_lightstep_env_vars(monkeypatch):
Expand All @@ -61,7 +61,25 @@ def test_init_lightstep_env_vars(monkeypatch):

tracer.assert_called_once_with(
component_name='component', access_token='1234', collector_host='tracer.example.org',
collector_port=8443, verbosity=1)
collector_port=8443, opentracing_encryption="tls", verbosity=1)


def test_init_lightstep_plaintext(monkeypatch):
tracer = MagicMock()

monkeypatch.setattr('lightstep.Tracer', tracer)
monkeypatch.setenv('OPENTRACING_LIGHTSTEP_COMPONENT_NAME', 'component')
monkeypatch.setenv('OPENTRACING_LIGHTSTEP_ACCESS_TOKEN', '1234')
monkeypatch.setenv('OPENTRACING_LIGHTSTEP_COLLECTOR_HOST', 'tracer.example.org')
monkeypatch.setenv('OPENTRACING_LIGHTSTEP_COLLECTOR_PORT', '8443')
monkeypatch.setenv('OPENTRACING_LIGHTSTEP_COLLECTOR_SCHEME', 'http')
monkeypatch.setenv('OPENTRACING_LIGHTSTEP_VERBOSITY', '1')

init_opentracing_tracer(OPENTRACING_LIGHTSTEP)

tracer.assert_called_once_with(
component_name='component', access_token='1234', collector_host='tracer.example.org',
collector_port=8443, opentracing_encryption="none", verbosity=1)


@pytest.mark.skipif(six.PY3, reason='Jaeger does not support PY3')
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ deps =
commands=
python setup.py install
py.test -v tests
flake8 .
flake8 --ignore=E402 .
codecov -e TOXENV

0 comments on commit 802f602

Please sign in to comment.