public MetricWrapper(ILambdaContext context, List <Dimension> dimensions, String authToken) { int timeoutMs = 300; //default timeout 300ms if (int.TryParse(GetEnvironmentVariable(TIMEOUT_MS), out int intValue)) { timeoutMs = intValue; } // create endpoint SignalFxLambdaEndpoint signalFxEndpoint = new SignalFxLambdaEndpoint(); // create reporter with endpoint reporter = new SignalFxReporter(signalFxEndpoint.ToString(), authToken, timeoutMs); // get default dimensions defaultDimensions = GetDefaultDimensions(context); // set wrapper singleton context MetricSender.setWrapper(this); watch = System.Diagnostics.Stopwatch.StartNew(); sendMetricCounter(METRIC_NAME_INVOCATIONS, MetricType.COUNTER); if (isColdStart) { isColdStart = false; sendMetricCounter(METRIC_NAME_COLD_STARTS, MetricType.COUNTER); } }
private void sendMetric(string metricName, MetricType metricType, Datum datum) { DataPoint dp = new DataPoint(); dp.metric = METRIC_NAME_PREFIX + metricName; dp.metricType = metricType; dp.value = datum; MetricSender.sendMetric(dp); }