AWS Lambda has become a core technology in the shift to cloud-native application development, eliminating infrastructure management and fixed costs. But there are trade-offs with serverless environments. Not having access to the production infrastructure can make debugging difficult and there are a lot of moving parts, adding distributed complexity. Monitoring serverless functions in production requires observability beyond CloudWatch logs and metrics. End-to-end, low-maintenance distributed tracing is essential to understand performance issues and troubleshoot cloud-native application development. This is why we’re excited to announce Splunk OpenTelemetry Java Lambda Wrapper is available in beta!
OpenTelemetry Java Lambda Wrappers enable frictionless, automatic instrumentation, and support incoming and outgoing context propagation using open standards such as B3. Splunk OpenTelemetry Java Wrappers are distributed as AWS Lambda layers which are published and hosted by Splunk in all AWS regions — making integration fast and easy.
Splunk OpenTelemetry Java Lambda Wrappers add value compared to general OTEL wrappers by providing:
The Splunk OpenTelemetry Java Lambda Wrapper is a distribution of the wrappers in the OpenTelemetry AWS Lambda Instrumentation that enables you to export spans from an AWS Lambda function with Java to Splunk APM without any code changes to your Lambda functions. You can choose between two ways to send your data to us:
There are two options to use the Splunk Lambda wrapper:
Splunk also provides a Serverless Application Model (SAM) template for deploying the Lambda wrapper with a Lambda handler or a Lambda layer. You can find more information and examples on the GitHub page for Splunk Open Telemetry Java Lambda Wrapper. In this blog, we’ll show you how to deploy the wrapper with a Lambda layer for frictionless instrumentation.
Add a layer that includes the Splunk Lambda wrapper to your Lambda function. A layer is code and other content that you can run without including it in your deployment package. Splunk provides layers in all supported regions you can freely use.
You can also deploy the layer with a SAM template.
To reduce the size of the deployment package, make sure that your Lambda artifact doesn't contain the wrapper.
Follow these steps to configure a Splunk Lambda wrapper to export spans to Splunk APM with a layer that Splunk provides.
Set the OTEL_INSTRUMENTATION_AWS_LAMBDA_HANDLER environment variable in your Lambda function code:
OTEL_INSTRUMENTATION_AWS_LAMBDA_HANDLER="package.ClassName::methodName"
By default, the Splunk Lambda wrapper uses B3 context propagation. If you want to change this, set the OTEL_PROPAGATORS environment variable in your Lambda function code. For more information about available context propagators, see the Propagator settings for the OpenTelemetry Java Instrumentation.
By default, the Splunk Lambda wrapper uses a jaeger-thrift exporter to send traces to Splunk APM. If you want to use this exporter, set these environment variables in your Lambda function code:
OTEL_EXPORTER_JAEGER_ENDPOINT="http://yourEndpoint:9080/v1/trace"
OTEL_EXPORTER_JAEGER_SERVICE_NAME="serviceName"
SIGNALFX_AUTH_TOKEN="orgAccessToken"
Also, you can set span flush wait timeout, that is max time the function will wait for the spans to be ingested by the Splunk APM. Default is 1 second. Timeout is controlled with a following property (value in milliseconds):
OTEL_INSTRUMENTATION_AWS_LAMBDA_FLUSH_TIMEOUT: 30000
If you want to use a different exporter, set the OTEL_EXPORTERS environment variable. Other exporters have their own configuration settings. For more information, see the OpenTelemetry Instrumentation for Java on GitHub.
Set the environment in Splunk APM for the service with the OTEL_RESOURCE_ATTRIBUTES environment variable:
OTEL_RESOURCE_ATTRIBUTES="environment=yourEnvironment"
Save your settings and call the Lambda function.
The Splunk Lambda wrapper automatically adds span tags to trace data it exports. These are the available span tags for AWS metadata. For more information, see the OpenTelemetry Specification.
You’ll need to set environment variables for the Lambda function. These environment variables control logging:
You also have the option to add the wrapper as a dependency to the Lambda function. A Splunk Lambda wrapper wraps around an existing AWS Lambda Java function handler. This approach doesn't require any code changes to your Lambda function. When you deploy the Lambda wrapper with a Lambda handler, you add it as a dependency to your Lambda function. Whenever the Lambda function is invoked, it runs the Lambda wrapper which in turn calls your code. You can find more information about how to deploy via this method in Github.
After successfully completing the setup each invocation of your Lambda should create a single span with all appropriate tags, delivered directly to your APM dashboard, tied with other spans in your trace. You can find more information and examples in our docs on Github. Get started today!
The Splunk platform removes the barriers between data and action, empowering observability, IT and security teams to ensure their organizations are secure, resilient and innovative.
Founded in 2003, Splunk is a global company — with over 7,500 employees, Splunkers have received over 1,020 patents to date and availability in 21 regions around the world — and offers an open, extensible data platform that supports shared data across any environment so that all teams in an organization can get end-to-end visibility, with context, for every interaction and business process. Build a strong data foundation with Splunk.