Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

span context: set the default recorded flag to 0, and fix default trace options bug #474

Merged
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