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 readonly ISignalFxReporter _reporter; // Separated from the static to facilitate tests static MetricWrapper() { int timeoutMs = 300; //default timeout 300ms if (int.TryParse(Environment.GetEnvironmentVariable(TIMEOUT_MS), out int intValue)) { timeoutMs = intValue; } // create endpoint SignalFxLambdaEndpoint signalFxEndpoint = new SignalFxLambdaEndpoint(); // create reporter with endpoint s_reporter = new SignalFxReporter(signalFxEndpoint.ToString(), Environment.GetEnvironmentVariable(AUTH_TOKEN), timeoutMs); }