ℹ️ SignalFx was acquired by Splunk in October 2019. See Splunk SignalFx for more information.
The SignalFx Java Azure Function Wrapper is deprecated and will reach End of Support on Jan 20, 2024. After that date, this repository will be archived and no longer receive updates. Until then, only critical security fixes and bug fixes will be provided.
SignalFx Java Azure Function Wrapper.
- Java 7+
The SignalFx Java Azure Function Wrapper is a wrapper around an Azure Function, used to instrument execution of the function and send metrics to SignalFx.
<dependency>
<groupId>com.signalfx.public</groupId>
<artifactId>signalfx-azure-functions</artifactId>
<version>0.0.1</version>
</dependency>
By default, this function wrapper will send to the us0
realm. If you are
not in this realm you will need to set the SIGNALFX_API_HOSTNAME
environment
variable to the correct realm ingest endpoint (https://ingest.{REALM}.signalfx.com).
To determine what realm you are in, check your profile page in the SignalFx
web application (click the avatar in the upper right and click My Profile).
Wrap the code inside the handler as followed:
import com.signalfx.azurefunctions.wrapper.MetricWrapper;
@FunctionName("Hello-SignalFx")
public HttpResponseMessage<String> hello(HttpRequestMessage<Optional<String>> request,
final ExecutionContext context) {
MetricWrapper wrapper = new MetricWrapper(context);
...
// your code
...
} catch (Exception e) {
wrapper.error();
} finally {
wrapper.close();
}
}
Set the Azure Function environment variables as follows:
- Set authentication token:
SIGNALFX_AUTH_TOKEN=signalfx token
- Optional parameters available:
SIGNALFX_API_HOSTNAME=[ingest.us0.signalfx.com]
SIGNALFX_API_PORT=[443]
SIGNALFX_API_SCHEME=[https]
SIGNALFX_SEND_TIMEOUT=milliseconds for signalfx client timeout [2000]
The Azure Function Wrapper sends the following metrics to SignalFx:
Metric Name | Type | Description |
---|---|---|
azure.function.invocations | Counter | Count number of function invocations |
azure.function.errors | Counter | Count number of errors from underlying function |
azure.function.duration | Gauge | Milliseconds in execution time of underlying function |
The function wrapper adds the following dimensions to all data points sent to SignalFx:
Dimension | Description |
---|---|
azure_region | Azure Region where the function is executed |
azure_function_name | Name of the function |
azure_resource_name | Name of the function app where the function is running |
function_wrapper_version | SignalFx Function Wrapper qualifier (e.g. signalfx-azurefunction-0.0.11) |
is_Azure_Function | Used to differentiate between Azure App Service and Azure Function metrics |
metric_source | The literal value of 'azure_function_wrapper' |
// construct data point builder
SignalFxProtocolBuffers.DataPoint.Builder builder =
SignalFxProtocolBuffers.DataPoint.newBuilder()
.setMetric("my.custom.metric")
.setMetricType(SignalFxProtocolBuffers.MetricType.GAUGE)
.setValue(
SignalFxProtocolBuffers.Datum.newBuilder()
.setDoubleValue(100));
// add custom dimension
builder.addDimensionsBuilder().setKey("applicationName").setValue("CoolApp").build();
// send the metric
MetricSender.sendMetric(builder);
-
Follow the Azure instructions to run functions locally https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-java-maven
-
Install as shown above by adding the dependency to pom.xml
Apache Software License v2. Copyright © 2014-2017 SignalFx