@@ -42,19 +42,23 @@ final class LambdaRuntime
4242 /** @var Invoker */
4343 private $ invoker ;
4444
45- public static function fromEnvironmentVariable (): self
45+ /** @var string */
46+ private $ layer ;
47+
48+ public static function fromEnvironmentVariable (string $ layer ): self
4649 {
47- return new self ((string ) getenv ('AWS_LAMBDA_RUNTIME_API ' ));
50+ return new self ((string ) getenv ('AWS_LAMBDA_RUNTIME_API ' ), $ layer );
4851 }
4952
50- public function __construct (string $ apiUrl )
53+ public function __construct (string $ apiUrl, string $ layer )
5154 {
5255 if ($ apiUrl === '' ) {
5356 die ('At the moment lambdas can only be executed in an Lambda environment ' );
5457 }
5558
5659 $ this ->apiUrl = $ apiUrl ;
5760 $ this ->invoker = new Invoker ;
61+ $ this ->layer = $ layer ;
5862 }
5963
6064 public function __destruct ()
@@ -313,7 +317,7 @@ private function postJson(string $url, $data): void
313317 * WHAT?
314318 * The data sent in the ping is anonymous.
315319 * It does not contain any identifiable data about anything (the project, users, etc.).
316- * The only data it contains is: "A Bref invocation happened".
320+ * The only data it contains is: "A Bref invocation happened using a specific layer ".
317321 * You can verify that by checking the content of the message in the function.
318322 *
319323 * HOW?
@@ -354,7 +358,7 @@ private function ping(): void
354358
355359 /**
356360 * Here is the content sent to the Bref analytics server.
357- * It signals an invocation happened.
361+ * It signals an invocation happened on which layer .
358362 * Nothing else is sent.
359363 *
360364 * `Invocations_100` is used to signal that this is 1 ping equals 100 invocations.
@@ -365,7 +369,7 @@ private function ping(): void
365369 *
366370 * See https://github.com/statsd/statsd/blob/master/docs/metric_types.md for more information.
367371 */
368- $ message = ' Invocations_100:1|c ' ;
372+ $ message = " Invocations_100:1|c \n Layer_ { $ this -> layer } _100:1|c " ;
369373
370374 $ sock = socket_create (AF_INET , SOCK_DGRAM , SOL_UDP );
371375 // This IP address is the Bref server.
0 commit comments