public MetricWrapper(ExecutionContext context,
                             List <Dimension> dimensions,
                             String authToken)
        {
            int timeoutMs = 300;             //default timeout 300ms

            try {
                timeoutMs = Int32.Parse(GetEnvironmentVariable(TIMEOUT_MS));
            } catch (Exception e) {
                //ignore and use default timeout
            }

            // create endpoint
            SignalFxAzureFuncEndpoint signalFxEndpoint = new SignalFxAzureFuncEndpoint();


            // 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);
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
 public SignalFxReport(ISignalFxReporter sender, string sourceDimension, string defaultSource, IDictionary <string, string> defaultDimensions, int maxDatapointsPerMessage, ISet <MetricDetails> metricDetails)
 {
     this.sender                  = sender;
     this.sourceDimension         = sourceDimension;
     this.defaultSource           = defaultSource;
     this.defaultDimensions       = defaultDimensions;
     this.maxDatapointsPerMessage = maxDatapointsPerMessage;
     this.metricDetails           = metricDetails;
 }
Ejemplo n.º 4
0
        public MetricWrapper(List <KeyValuePair <string, string> > commonTags, ISignalFxReporter reporter = null)
        {
            _defaultDimensions = GetDefaultDimensions(commonTags);
            _metricsBatch      = new List <DataPoint>(4);
            _reporter          = reporter ?? s_reporter;

            _watch = System.Diagnostics.Stopwatch.StartNew();
            AddMetricCounter(METRIC_NAME_INVOCATIONS, MetricType.COUNTER);
            if (s_isColdStart)
            {
                s_isColdStart = false;
                AddMetricCounter(METRIC_NAME_COLD_STARTS, MetricType.COUNTER);
            }
        }
Ejemplo n.º 5
0
        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);
        }
        public void Configure(string collectorName, XElement configElement, ISystemMetricsService systemMetrics)
        {
            _completionTask = new Task(() => IsActive = false);
            _log            = SuperCheapIOC.Resolve <ILog>();


            _config   = parseConfig(configElement);
            _reporter = new SignalFxReporter(_config.BaseURI, _config.ApiToken, _config.PostTimeout);

            _processBlock = new ActionBlock <Bucket>(bucket => ProcessBucket(bucket), Utility.UnboundedExecution());
            _batchBlock   = new BatchBlock <TypeDatapoint>(_config.MaxBatchSize);
            _outputBlock  = new ActionBlock <TypeDatapoint[]>(datapoint => ProcessDatapoints(datapoint), Utility.OneAtATimeExecution());
            _batchBlock.LinkTo(_outputBlock);

            _triggerBatchTimer = new Timer((state) => trigger(state), null, TimeSpan.FromSeconds(1), _config.MaxTimeBetweenBatches);
            IsActive           = true;
        }
Ejemplo n.º 7
0
 public MetricWrapper(ILambdaContext context, ISignalFxReporter reporter = null)
     : this(context.ExtractCommonTags(), reporter)
 {
 }