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

Renamed config module name to the global name (#129) #130

Merged
merged 1 commit into from
Feb 12, 2019
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
2 changes: 1 addition & 1 deletion aws_xray_sdk/core/lambda_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def put_subsegment(self, subsegment):
current_entity = self.get_trace_entity()

if not self._is_subsegment(current_entity) and current_entity.initializing:
if sdk_config_module.sdk_enabled():
if global_sdk_config.sdk_enabled():
log.warning("Subsegment %s discarded due to Lambda worker still initializing" % subsegment.name)
return

Expand Down
19 changes: 19 additions & 0 deletions tests/test_lambda_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,22 @@ def test_disable():
global_sdk_config.set_sdk_enabled(False)
segment = context.get_trace_entity()
assert not segment.sampled


def test_non_initialized():
# Context that hasn't been initialized by lambda container should not add subsegments to the facade segment.
temp_header_var = os.environ[lambda_launcher.LAMBDA_TRACE_HEADER_KEY]
del os.environ[lambda_launcher.LAMBDA_TRACE_HEADER_KEY]

temp_context = lambda_launcher.LambdaContext()
facade_segment = temp_context.get_trace_entity()
subsegment = Subsegment("TestSubsegment", "local", facade_segment)
temp_context.put_subsegment(subsegment)

assert temp_context.get_trace_entity() == facade_segment

# "Lambda" container added metadata now. Should see subsegment now.
os.environ[lambda_launcher.LAMBDA_TRACE_HEADER_KEY] = temp_header_var
temp_context.put_subsegment(subsegment)

assert temp_context.get_trace_entity() == subsegment