Skip to content

Commit

Permalink
Added proper TraceID in dummy segments (#223)
Browse files Browse the repository at this point in the history
* Added proper TraceID in dummy segments

* Added test case to check valid TraceID
  • Loading branch information
bhautikpip authored Apr 24, 2020
1 parent 2d12c83 commit 672062f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion aws_xray_sdk/core/models/dummy_entities.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .traceid import TraceId
from .segment import Segment
from .subsegment import Subsegment

Expand All @@ -13,7 +14,7 @@ class DummySegment(Segment):
"""
def __init__(self, name='dummy'):

super(DummySegment, self).__init__(name=name, traceid='dummy')
super(DummySegment, self).__init__(name=name, traceid=TraceId().to_id())
self.sampled = False

def set_aws(self, aws_meta):
Expand Down
11 changes: 9 additions & 2 deletions tests/test_dummy_entites.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


def test_not_sampled():

segment = DummySegment()
subsegment = DummySubsegment(segment)

Expand All @@ -12,7 +11,6 @@ def test_not_sampled():


def test_no_ops():

segment = DummySegment()
segment.put_metadata('key', 'value')
segment.put_annotation('key', 'value')
Expand Down Expand Up @@ -63,3 +61,12 @@ def test_invalid_entity_name():

assert segment.name == 'DummySegment Test'
assert subsegment.name == 'DummySubsegment'


def test_dummy_segment_trace_id():
segment = DummySegment()

assert segment.trace_id != 'dummy'
assert '-' in segment.trace_id
# checking version of trace id
assert segment.trace_id[:1] == '1'

0 comments on commit 672062f

Please sign in to comment.