SignalFx Lambda Python Wrapper
Project description
# SignalFx Python Lambda Wrapper
SignalFx Python Lambda Wrapper.
## Usage
The SignalFx Java Lambda Wrapper is a wrapper around an AWS Lambda Python function handler, used to instrument execution of the function and send metrics to SignalFx.
### Installation
To install from PyPi
```
$ pip install pip install signalfx_lambda
```
### Environment Variables
```
SIGNALFX_AUTH_TOKEN=access token
SIGNALFX_INGEST_ENDPOINT=[optional]
```
### Wrapping a function
Decorate your handler with @signalfx_lambda.wrapper
```
import signalfx_lambda
@signalfx_lambda.wrapper
def handler(event, context):
# your code
```
### Metrics and dimensions sent by the wrapper
The Lambda wrapper sends the following metrics to SignalFx:
| Metric Name | Type | Description |
| ------------- | ------------- | ---|
| function.invocations | Counter | Count number of Lambda invocations|
| function.cold_starts | Counter | Count number of cold starts|
| function.errors | Counter | Count number of errors from underlying Lambda handler|
| function.duration | Gauge | Milliseconds in execution time of underlying Lambda handler|
The Lambda wrapper adds the following dimensions to all data points sent to SignalFx:
| Dimension | Description |
| ------------- | ---|
| lambda_arn | ARN of the Lambda function instance |
| aws_region | AWS Region |
| aws_account_id | AWS Account ID |
| aws_function_name | AWS Function Name |
| aws_function_version | AWS Function Version |
| aws_function_qualifier | AWS Function Version Qualifier (version or version alias if it is not an event source mapping Lambda invocation) |
| event_source_mappings | AWS Function Name (if it is an event source mapping Lambda invocation) |
| aws_execution_env | AWS execution environment (e.g. AWS_Lambda_python3.6) |
| function_wrapper_version | SignalFx function wrapper qualifier (e.g. signalfx_lambda_0.0.2) |
| metric_source | The literal value of 'lambda_wrapper' |
### Sending custom metric from the Lambda function
```
import signalfx_lambda
# sending application_performance metric with value 100 and dimension abc:def
signalfx_lambda.send_gauge('application_performance', 100, {'abc':'def'})
# sending counter metric with no dimension
signalfx_lambda.send_counter('database_calls', 1)
```
### Testing it out locally
Use python-lambda-local
```
pip install python-lambda-local
```
```
python-lambda-local tests/test.py tests/event.json -a 'arn:aws:lambda:us-east-1:accountId:function:functionNamePython:$LATEST'
```
### Packaging
```
python setup.py bdist_wheel --universal
```
### License
Apache Software License v2. Copyright © 2014-2017 SignalFx
SignalFx Python Lambda Wrapper.
## Usage
The SignalFx Java Lambda Wrapper is a wrapper around an AWS Lambda Python function handler, used to instrument execution of the function and send metrics to SignalFx.
### Installation
To install from PyPi
```
$ pip install pip install signalfx_lambda
```
### Environment Variables
```
SIGNALFX_AUTH_TOKEN=access token
SIGNALFX_INGEST_ENDPOINT=[optional]
```
### Wrapping a function
Decorate your handler with @signalfx_lambda.wrapper
```
import signalfx_lambda
@signalfx_lambda.wrapper
def handler(event, context):
# your code
```
### Metrics and dimensions sent by the wrapper
The Lambda wrapper sends the following metrics to SignalFx:
| Metric Name | Type | Description |
| ------------- | ------------- | ---|
| function.invocations | Counter | Count number of Lambda invocations|
| function.cold_starts | Counter | Count number of cold starts|
| function.errors | Counter | Count number of errors from underlying Lambda handler|
| function.duration | Gauge | Milliseconds in execution time of underlying Lambda handler|
The Lambda wrapper adds the following dimensions to all data points sent to SignalFx:
| Dimension | Description |
| ------------- | ---|
| lambda_arn | ARN of the Lambda function instance |
| aws_region | AWS Region |
| aws_account_id | AWS Account ID |
| aws_function_name | AWS Function Name |
| aws_function_version | AWS Function Version |
| aws_function_qualifier | AWS Function Version Qualifier (version or version alias if it is not an event source mapping Lambda invocation) |
| event_source_mappings | AWS Function Name (if it is an event source mapping Lambda invocation) |
| aws_execution_env | AWS execution environment (e.g. AWS_Lambda_python3.6) |
| function_wrapper_version | SignalFx function wrapper qualifier (e.g. signalfx_lambda_0.0.2) |
| metric_source | The literal value of 'lambda_wrapper' |
### Sending custom metric from the Lambda function
```
import signalfx_lambda
# sending application_performance metric with value 100 and dimension abc:def
signalfx_lambda.send_gauge('application_performance', 100, {'abc':'def'})
# sending counter metric with no dimension
signalfx_lambda.send_counter('database_calls', 1)
```
### Testing it out locally
Use python-lambda-local
```
pip install python-lambda-local
```
```
python-lambda-local tests/test.py tests/event.json -a 'arn:aws:lambda:us-east-1:accountId:function:functionNamePython:$LATEST'
```
### Packaging
```
python setup.py bdist_wheel --universal
```
### License
Apache Software License v2. Copyright © 2014-2017 SignalFx
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for signalfx_lambda-0.0.4-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8149ab5b26090022a468259f93c171950e419bfd983d7d5b25ca3c5efaf7b9f0 |
|
MD5 | 8a42f2c99fbeb4b431b1c4d2bdcc1e7a |
|
BLAKE2b-256 | 5639d11b0b8be0780ae5508778084803d7aa269ca430c99ada4040552e80d32b |