@@ -5,6 +5,7 @@ linkTitle: Observing Lambdas
5
5
date : 2025-01-24
6
6
cSpell:ignore : Dominik
7
7
---
8
+
8
9
Getting telemetry data out of modern applications is very straightforward (or at
9
10
least it should be). You set up a collector which either receives data from your
10
11
application or asks it to provide an up-to-date state of various counters. This
@@ -17,13 +18,13 @@ AWS Lambda.
17
18
In this execution model, functions are called directly, and the environment is
18
19
frozen afterward. You’re only billed for actual execution time and no longer
19
20
need a server to wait for incoming requests. This is also where the term
20
- serverless comes from. Keeping the function alive until metrics can be
21
- collected isn’t really an option and even if you were willing to pay for that,
22
- different invocations will have a completely separate context and not
23
- necessarily know about all the other executions happening simultaneously. You
24
- might now be saying: "I'll just push all the data at the end of my execution, no
25
- issues here!", but that doesn’t solve the issue. You’ll still have to pay for
26
- the time it takes to send the data and with many invocations, this adds up.
21
+ serverless comes from. Keeping the function alive until metrics can be collected
22
+ isn’t really an option and even if you were willing to pay for that, different
23
+ invocations will have a completely separate context and not necessarily know
24
+ about all the other executions happening simultaneously. You might now be
25
+ saying: "I'll just push all the data at the end of my execution, no issues
26
+ here!", but that doesn’t solve the issue. You’ll still have to pay for the time
27
+ it takes to send the data and with many invocations, this adds up.
27
28
28
29
But there is another way! Lambda extension layers allow you to run any process
29
30
alongside your code, sharing the execution runtime and providing additional
@@ -37,10 +38,12 @@ of the Lambda lifecycle and ensures your telemetry gets to the storage layer.
37
38
When your function is called for the first time, the extension layer starts an
38
39
instance of the OpenTelemetry Collector. The Collector build is a stripped down
39
40
version, providing only components necessary in the context of Lambda. It
40
- registers with the Lambda [ Extensions API] ( https://docs.aws.amazon.com/lambda/latest/dg/runtimes-extensions-api.html )
41
- and [ Telemetry API] ( https://docs.aws.amazon.com/lambda/latest/dg/telemetry-api.html ) . By doing
42
- this, it receives notifications whenever your function is executed, emits a
43
- logline, or the execution context is about to be shut down.
41
+ registers with the Lambda
42
+ [ Extensions API] ( https://docs.aws.amazon.com/lambda/latest/dg/runtimes-extensions-api.html )
43
+ and
44
+ [ Telemetry API] ( https://docs.aws.amazon.com/lambda/latest/dg/telemetry-api.html ) .
45
+ By doing this, it receives notifications whenever your function is executed,
46
+ emits a logline, or the execution context is about to be shut down.
44
47
45
48
### This is where the magic happens
46
49
@@ -54,11 +57,10 @@ its thing.
54
57
55
58
{{< figure src="diagram-execution-timing.svg" caption="Diagram showcasing how execution timing differs with and without a Collector">}}
56
59
57
-
58
60
## How can I use it?
59
61
60
- As of November 2024, the opentelemetry-lambda project publishes [ releases of the
61
- Collector extension layer] ( https://github.com/open-telemetry/opentelemetry-lambda/releases/tag/layer-collector%2F0.12.0 ) .
62
+ As of November 2024, the opentelemetry-lambda project publishes
63
+ [ releases of the Collector extension layer] ( https://github.com/open-telemetry/opentelemetry-lambda/releases/tag/layer-collector%2F0.12.0 ) .
62
64
It can be configured through a configuration file hosted either in an S3 bucket
63
65
or on an arbitrary HTTP server. It is also possible to bundle the configuration
64
66
file with your Lambda code. In both cases, you have tradeoffs to consider.
@@ -67,8 +69,8 @@ request needs to be made, while bundling the configuration increases the
67
69
management overhead when trying to control the configuration for multiple
68
70
Lambdas.
69
71
70
- The simplest way to get started is with an embedded configuration. For this,
71
- add a file called ` collector.yaml ` to your function. This is a regular Collector
72
+ The simplest way to get started is with an embedded configuration. For this, add
73
+ a file called ` collector.yaml ` to your function. This is a regular Collector
72
74
configuration file. To take advantage of the Lambda specific extensions, they
73
75
need to be configured. As an example, the following configuration receives
74
76
traces and logs from the Telemetry API and sends them to another endpoint:
0 commit comments