Skip to content

Commit

Permalink
Fix default trace options and default (#474)
Browse files Browse the repository at this point in the history
Change default trace options as not to force sampling.
  • Loading branch information
wsabransky authored and c24t committed Apr 2, 2019
1 parent 1de5779 commit 0aa5525
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def test_translate_to_jaeger(self):
operationName='test1',
startTime=1502820146071158,
duration=10000000,
flags=1,
flags=0,
tags=[
jaeger.Tag(
key='key_bool', vType=jaeger.TagType.BOOL,
Expand Down
11 changes: 4 additions & 7 deletions opencensus/trace/span_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,16 @@
import six
import uuid

from opencensus.trace import trace_options
from opencensus.trace import trace_options as trace_options_module

_INVALID_TRACE_ID = '0' * 32
INVALID_SPAN_ID = '0' * 16

TRACE_ID_PATTERN = re.compile('[0-9a-f]{32}?')
SPAN_ID_PATTERN = re.compile('[0-9a-f]{16}?')

# Default options, enable tracing
DEFAULT_OPTIONS = 1

# Default trace options
DEFAULT = trace_options.TraceOptions(DEFAULT_OPTIONS)
# Default options, don't force sampling
DEFAULT_OPTIONS = '0'


class SpanContext(object):
Expand Down Expand Up @@ -65,7 +62,7 @@ def __init__(
trace_id = generate_trace_id()

if trace_options is None:
trace_options = DEFAULT
trace_options = trace_options_module.TraceOptions(DEFAULT_OPTIONS)

self.from_header = from_header
self.trace_id = self._check_trace_id(trace_id)
Expand Down
5 changes: 2 additions & 3 deletions tests/unit/trace/test_tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ def test_should_sample_not_sampled(self):

self.assertFalse(sampled)

def get_tracer_noop_tracer(self):
def test_get_tracer_noop_tracer(self):
from opencensus.trace.tracers import noop_tracer

sampler = mock.Mock()
sampler.should_sample.return_value = False
tracer = tracer_module.Tracer(sampler=sampler)
Expand All @@ -102,7 +101,7 @@ def get_tracer_noop_tracer(self):

assert isinstance(result, noop_tracer.NoopTracer)

def get_tracer_context_tracer(self):
def test_get_tracer_context_tracer(self):
from opencensus.trace.tracers import context_tracer

sampler = mock.Mock()
Expand Down

0 comments on commit 0aa5525

Please sign in to comment.