AWS has launched the AWS Lambda Telemetry API, a brand new method for extensions to obtain enhanced operate telemetry from the Lambda service. The brand new API simplifies amassing traces, logs, and customized and enhanced metrics from Lambda features. Together with a number of instance extensions, there are a number of extensions accessible from third events together with Datadog, Dynatrace, Serverless, and Sumo Logic.
The brand new API permits extensions to subscribe to platform telemetry, operate logs, and extension logs. Platform telemetry contains logs, metrics, and traces that describe occasions and errors associated to the lambda atmosphere runtime lifecycle, the extension lifecycle, and the operate invocation. Operate logs are customized logs generated by the Lambda operate code and extensions logs are related however generated by the Lambda extension.
The API schema is semantically suitable with OpenTelemetry (OTel). Occasions from the Telemetry API can be utilized to construct and report OTel spans. AWS notes that single Occasion objects shouldn’t be mapped to a single OTel span. For instance, the Telemetry API occasions
runtimeReport symbolize a single operate invocation and ought to be represented as a single OTel span.
With the discharge of the brand new API, plenty of AWS companions have launched extensions. Datadog has launched a Lambda extension that simplifies measuring chilly begin spans and gives extra enhanced metrics into the Datadog console. Serverless launched Serverless Console V.2 which makes use of the brand new Telemetry API to gather initialization, invocation, and post-processing instances for Lambda operate calls. The brand new knowledge permits the Serverless Console to current a brand new consumer expertise metric that illustrates how lengthy it takes for the AWS Lambda operate to return a response.
It is usually potential to create customized extensions and there are a number of examples to assist information growth. There are examples in Python, Go, Node.js, Java, C#, and Rust. The examples cowl plenty of use circumstances together with adaptive batching and a crash uploader.
Lambda extensions run as an impartial course of within the execution atmosphere and can proceed to run after the operate invocation is full. As extensions run as a special course of than the operate code, it’s potential to put in writing them in a special language from the operate code. Julian Wooden, Senior Developer Advocate with AWS, recommends “implementing extensions utilizing a compiled language as a self-contained binary. This makes the extension suitable with all of the supported runtimes.”
Extensions leveraging the Telemetry API observe this lifecycle:
To begin, the extension registers by way of the Lambda Extension API and subscribes to obtain the
SHUTDOWN occasions. The extension begins a telemetry listener both by way of TCP or HTTP, with HTTP being the beneficial selection. As soon as began, the extension makes use of the Telemetry API to subscribe to the specified occasion streams. Lastly, the Lambda service will
POST telemetry stream knowledge to the listener.
Extensions utilizing the Telemetry API share the identical pricing mannequin as Lambda features that means that prices are incurred for requests served in addition to the compute time used to run the extension. The AWS Lambda Telemetry API supersedes the prevailing AWS Lambda Logs API. Whereas the Logs API can nonetheless be used it’s endorsed to modify to utilizing the brand new Telemetry API. Extra details about the brand new API is obtainable from the AWS weblog.