File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,29 @@ def test_non_initialized():
85
85
86
86
assert temp_context .get_trace_entity () == subsegment
87
87
88
+ def test_lambda_passthrough ():
89
+ # Hold previous environment value
90
+ temp_header_var = os .environ [lambda_launcher .LAMBDA_TRACE_HEADER_KEY ]
91
+ del os .environ [lambda_launcher .LAMBDA_TRACE_HEADER_KEY ]
92
+
93
+ # Set header to lambda passthrough style header
94
+ os .environ [lambda_launcher .LAMBDA_TRACE_HEADER_KEY ] = "Root=%s;Lineage=10:1234abcd:3" % TRACE_ID
95
+
96
+ temp_context = lambda_launcher .LambdaContext ()
97
+ dummy_segment = temp_context .get_trace_entity ()
98
+ subsegment = Subsegment ("TestSubsegment" , "local" , dummy_segment )
99
+ temp_context .put_subsegment (subsegment )
100
+
101
+ assert temp_context .get_trace_entity () == dummy_segment
102
+
103
+ # Reset header value and ensure behaviour returns to normal
104
+ del os .environ [lambda_launcher .LAMBDA_TRACE_HEADER_KEY ]
105
+ os .environ [lambda_launcher .LAMBDA_TRACE_HEADER_KEY ] = temp_header_var
106
+ temp_context .put_subsegment (subsegment )
107
+
108
+ assert temp_context .get_trace_entity () == subsegment
109
+
110
+
88
111
89
112
def test_set_trace_entity ():
90
113
segment = context .get_trace_entity ()
You can’t perform that action at this time.
0 commit comments