@@ -50,12 +50,13 @@ void shouldSetLambdaContextWhenEnabled() {
5050 requestHandler .handleRequest (new Object (), context );
5151
5252 assertThat (ThreadContext .getImmutableContext ())
53- .hasSize (5 )
53+ .hasSize (6 )
5454 .containsEntry (DefaultLambdaFields .FUNCTION_ARN .getName (), "testArn" )
5555 .containsEntry (DefaultLambdaFields .FUNCTION_MEMORY_SIZE .getName (), "10" )
5656 .containsEntry (DefaultLambdaFields .FUNCTION_VERSION .getName (), "1" )
5757 .containsEntry (DefaultLambdaFields .FUNCTION_NAME .getName (), "testFunction" )
58- .containsKey ("coldStart" );
58+ .containsKey ("coldStart" )
59+ .containsKey ("service" );
5960 }
6061
6162 @ Test
@@ -65,26 +66,27 @@ void shouldSetLambdaContextForStreamHandlerWhenEnabled() throws IOException {
6566 requestStreamHandler .handleRequest (new ByteArrayInputStream (new byte []{}), new ByteArrayOutputStream (), context );
6667
6768 assertThat (ThreadContext .getImmutableContext ())
68- .hasSize (5 )
69+ .hasSize (6 )
6970 .containsEntry (DefaultLambdaFields .FUNCTION_ARN .getName (), "testArn" )
7071 .containsEntry (DefaultLambdaFields .FUNCTION_MEMORY_SIZE .getName (), "10" )
7172 .containsEntry (DefaultLambdaFields .FUNCTION_VERSION .getName (), "1" )
7273 .containsEntry (DefaultLambdaFields .FUNCTION_NAME .getName (), "testFunction" )
73- .containsKey ("coldStart" );
74+ .containsKey ("coldStart" )
75+ .containsKey ("service" );
7476 }
7577
7678 @ Test
7779 void shouldSetColdStartFlag () throws IOException {
7880 requestStreamHandler .handleRequest (new ByteArrayInputStream (new byte []{}), new ByteArrayOutputStream (), context );
7981
8082 assertThat (ThreadContext .getImmutableContext ())
81- .hasSize (5 )
83+ .hasSize (6 )
8284 .containsEntry ("coldStart" , "true" );
8385
8486 requestStreamHandler .handleRequest (new ByteArrayInputStream (new byte []{}), new ByteArrayOutputStream (), context );
8587
8688 assertThat (ThreadContext .getImmutableContext ())
87- .hasSize (5 )
89+ .hasSize (6 )
8890 .containsEntry ("coldStart" , "false" );
8991 }
9092
@@ -125,7 +127,7 @@ void shouldLogEventForHandler() {
125127 requestHandler .handleRequest (new Object (), context );
126128
127129 assertThat (ThreadContext .getImmutableContext ())
128- .hasSize (5 );
130+ .hasSize (6 );
129131 }
130132
131133 @ Test
@@ -142,7 +144,16 @@ void shouldLogEventForStreamAndLambdaStreamIsValid() throws IOException {
142144 .isEqualTo ("{\" test\" :\" payload\" }" );
143145
144146 assertThat (ThreadContext .getImmutableContext ())
145- .hasSize (5 );
147+ .hasSize (6 );
148+ }
149+
150+ @ Test
151+ void shouldLogServiceNameWhenEnvVarSet () {
152+ requestHandler .handleRequest (new Object (), context );
153+
154+ assertThat (ThreadContext .getImmutableContext ())
155+ .hasSize (6 )
156+ .containsEntry ("service" , "testService" );
146157 }
147158
148159 private void setupContext () {
0 commit comments