File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
main/java/com/google/cloud/logging
test/java/com/google/cloud/logging Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,10 @@ private static Resource detectResourceType() {
169169 return Resource .Global ;
170170 }
171171
172+ if (getter .getEnv ("FUNCTION_SIGNATURE_TYPE" ) != null
173+ && getter .getEnv ("FUNCTION_TARGET" ) != null ) {
174+ return Resource .CloudFunction ;
175+ }
172176 if (getter .getEnv ("K_SERVICE" ) != null
173177 && getter .getEnv ("K_REVISION" ) != null
174178 && getter .getEnv ("K_CONFIGURATION" ) != null ) {
@@ -179,10 +183,6 @@ private static Resource detectResourceType() {
179183 && getter .getEnv ("GAE_VERSION" ) != null ) {
180184 return Resource .AppEngine ;
181185 }
182- if (getter .getEnv ("FUNCTION_SIGNATURE_TYPE" ) != null
183- && getter .getEnv ("FUNCTION_TARGET" ) != null ) {
184- return Resource .CloudFunction ;
185- }
186186 if (getter .getAttribute ("instance/attributes/cluster-name" ) != null ) {
187187 return Resource .K8sContainer ;
188188 }
Original file line number Diff line number Diff line change @@ -243,6 +243,10 @@ public void testResourceTypeCloudFunction() {
243243 expect (getterMock .getEnv ("FUNCTION_SIGNATURE_TYPE" )).andReturn (MOCKED_NON_EMPTY ).once ();
244244 expect (getterMock .getEnv ("FUNCTION_TARGET" )).andReturn (MOCKED_NON_EMPTY ).once ();
245245 expect (getterMock .getEnv ("K_SERVICE" )).andReturn (MockedFunctionName ).anyTimes ();
246+ expect (getterMock .getEnv ("K_REVISION" )).andReturn (MockedFunctionName + ".1" ).anyTimes ();
247+ expect (getterMock .getEnv ("K_CONFIGURATION" ))
248+ .andReturn (MockedFunctionName + "-config" )
249+ .anyTimes ();
246250 expect (getterMock .getEnv (anyString ())).andReturn (null ).anyTimes ();
247251 replay (getterMock );
248252 // exercise
You can’t perform that action at this time.
0 commit comments