Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
signalfx_lambda-0.0.4-py2.py3-none-any.whl (6.4 kB) Copy SHA256 hash SHA256 Wheel py2.py3

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page