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

Added proper TraceID in dummy segments #223

Merged
merged 2 commits into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'