Пример #1
0
        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);
            }
        }
Пример #2
0
        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);
        }