Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit 0aa5525

Browse files
wsabranskyc24t
authored andcommitted
Fix default trace options and default (#474)
Change default trace options as not to force sampling.
1 parent 1de5779 commit 0aa5525

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

contrib/opencensus-ext-jaeger/tests/test_jaeger_exporter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def test_translate_to_jaeger(self):
311311
operationName='test1',
312312
startTime=1502820146071158,
313313
duration=10000000,
314-
flags=1,
314+
flags=0,
315315
tags=[
316316
jaeger.Tag(
317317
key='key_bool', vType=jaeger.TagType.BOOL,

opencensus/trace/span_context.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,16 @@
1919
import six
2020
import uuid
2121

22-
from opencensus.trace import trace_options
22+
from opencensus.trace import trace_options as trace_options_module
2323

2424
_INVALID_TRACE_ID = '0' * 32
2525
INVALID_SPAN_ID = '0' * 16
2626

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

30-
# Default options, enable tracing
31-
DEFAULT_OPTIONS = 1
32-
33-
# Default trace options
34-
DEFAULT = trace_options.TraceOptions(DEFAULT_OPTIONS)
30+
# Default options, don't force sampling
31+
DEFAULT_OPTIONS = '0'
3532

3633

3734
class SpanContext(object):
@@ -65,7 +62,7 @@ def __init__(
6562
trace_id = generate_trace_id()
6663

6764
if trace_options is None:
68-
trace_options = DEFAULT
65+
trace_options = trace_options_module.TraceOptions(DEFAULT_OPTIONS)
6966

7067
self.from_header = from_header
7168
self.trace_id = self._check_trace_id(trace_id)

tests/unit/trace/test_tracer.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,8 @@ def test_should_sample_not_sampled(self):
9191

9292
self.assertFalse(sampled)
9393

94-
def get_tracer_noop_tracer(self):
94+
def test_get_tracer_noop_tracer(self):
9595
from opencensus.trace.tracers import noop_tracer
96-
9796
sampler = mock.Mock()
9897
sampler.should_sample.return_value = False
9998
tracer = tracer_module.Tracer(sampler=sampler)
@@ -102,7 +101,7 @@ def get_tracer_noop_tracer(self):
102101

103102
assert isinstance(result, noop_tracer.NoopTracer)
104103

105-
def get_tracer_context_tracer(self):
104+
def test_get_tracer_context_tracer(self):
106105
from opencensus.trace.tracers import context_tracer
107106

108107
sampler = mock.Mock()

0 commit comments

Comments
 (0)