0.0.10 • Published 6 years ago

signalfx-azure-functions v0.0.10

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
6 years ago

SignalFx Node Azure Function Wrapper

SignalFx Node Azure Function Wrapper.

Usage

The SignalFx NodeJS Azure Function Wrapper is a wrapper around an Azure Function NodeJS function handler, used to instrument execution of the function and send metrics to SignalFx.

Installation

Use the hosted package:

{
  "name": "my-module",
  "dependencies": {
    "signalfx-azure-functions": "^0.0.10"
  }
}

Wrap your function handler

'use strict';

const signalFxAzureFunction = require('signalfx-azure-functions');

module.exports = signalFxAzureFunction.wrapper((context, some_binding_obj, callback) => {
  context.res = myFunc(context, some_binding_obj);
  callback();
});
  • By default, only 1 binding trigger object is passed through the wrapper. If you have multiple, you may need to modify your function to access them through the context object (e.g. context.bindings.myInput).
  • The function wrapper will call context.done() in the callback itself.

Environment Variables

 SIGNALFX_AUTH_TOKEN=signalfx token

Optional parameters available:

SIGNALFX_SEND_TIMEOUT=milliseconds for signalfx client timeout [1000]

# Change the ingest endpoint URL:
SIGNALFX_INGEST_ENDPOINT=[https://pops.signalfx.com]

Metrics and dimensions sent by the wrapper

The function wrapper sends the following metrics to SignalFx:

Metric NameTypeDescription
azure.function.invocationsCounterCount number of function invocations
azure.function.errorsCounterCount number of errors from underlying function handler
azure.function.durationGaugeMilliseconds in execution time of underlying function handler

The function wrapper adds the following dimensions to all data points sent to SignalFx:

DimensionDescription
azure_regionAzure region where the function is executed
azure_function_nameName of the function
azure_resource_nameName of the function app where the function is running
function_wrapper_versionSignalFx function wrapper qualifier (e.g. signalfx-azurefunction-0.0.11)
is_Azure_FunctionUsed to differentiate between Azure App Service and Azure Function metrics
metric_sourceThe literal value of 'azure_function_wrapper'

Sending a metric from the Azure function

'use strict';

const signalFxAzureFunction = require('signalfx-azure-functions');

module.exports = signalFxAzureFunction.wrapper((context, some_binding_obj, callback) => {
  ....
  signalFxAzureFunction.helper.sendGauge('gauge.name', value);
  callback();
});

Deployment

Run npm pack to package the module with the configuration in package.json.

Testing locally

1) Set up the local Azure Function runtime: https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local

2) Add the environment variables described above to your local.settings.json

3) Wrap function as stated above, run the runtime.

License

Apache Software License v2. Copyright © 2014-2017 SignalFx