internal void FunctionCompleted(FunctionStartedEvent functionStartedEvent)
            {
                var  functionStage     = (functionStartedEvent.Success == false) ? ExecutionStage.Failed : ExecutionStage.Succeeded;
                long executionTimeInMS = (long)functionStartedEvent.Duration.TotalMilliseconds;

                var monitoringEvent = new FunctionMetrics(functionStartedEvent.FunctionMetadata.Name, functionStage, executionTimeInMS);

                _functionMetricsQueue.Enqueue(monitoringEvent);
                var key = GetDictionaryKey(functionStartedEvent.FunctionMetadata.Name, functionStartedEvent.InvocationId);

                if (_runningFunctions.ContainsKey(key))
                {
                    lock (_functionMetricEventLockObject)
                    {
                        if (_runningFunctions.ContainsKey(key))
                        {
                            var functionInfo = _runningFunctions[key];
                            functionInfo.ExecutionStage = ExecutionStage.Finished;
                            functionInfo.Success        = functionStartedEvent.Success;

                            var endTime = functionStartedEvent.Timestamp + functionStartedEvent.Duration;
                            functionInfo.EndTime = functionStartedEvent.Timestamp + functionStartedEvent.Duration;

                            RaiseFunctionMetricEvent(functionInfo, _runningFunctions.Keys.Count, endTime);
                            _runningFunctions.Remove(key);
                        }
                    }
                }
            }
Beispiel #2
0
            internal void FunctionStarted(FunctionStartedEvent startedEvent)
            {
                totalExecutionCount++;
                runningFunctionCount++;

                var metricEventPerFunction = new FunctionMetrics(startedEvent.FunctionMetadata.Name, ExecutionStage.Started, 0);

                functionMetricsQueue.Enqueue(metricEventPerFunction);
            }
Beispiel #3
0
            internal void FunctionCompleted(FunctionStartedEvent startedEvent)
            {
                Interlocked.Decrement(ref _activeFunctionCount);

                var  functionStage     = !startedEvent.Success ? ExecutionStage.Failed : ExecutionStage.Succeeded;
                long executionTimeInMS = (long)startedEvent.Duration.TotalMilliseconds;
                var  monitoringEvent   = new FunctionMetrics(startedEvent.FunctionMetadata.Name, functionStage, executionTimeInMS);

                _functionMetricsQueue.Enqueue(monitoringEvent);

                RaiseFunctionMetricEvent(startedEvent, _activeFunctionCount, DateTime.UtcNow);
            }
Beispiel #4
0
            internal void FunctionStarted(FunctionStartedEvent startedEvent)
            {
                _totalExecutionCount++;
                Interlocked.Increment(ref _activeFunctionCount);

                var monitoringEvent = new FunctionMetrics(startedEvent.FunctionMetadata.Name, ExecutionStage.Started, 0);

                _functionMetricsQueue.Enqueue(monitoringEvent);

                lock (_runningFunctionsSyncLock)
                {
                    _runningFunctions.Add(startedEvent);
                }
            }
            internal void FunctionStarted(FunctionStartedEvent startedEvent)
            {
                _totalExecutionCount++;

                var monitoringEvent = new FunctionMetrics(startedEvent.FunctionMetadata.Name, ExecutionStage.Started, 0);

                _functionMetricsQueue.Enqueue(monitoringEvent);

                var key         = GetDictionaryKey(startedEvent.FunctionMetadata.Name, startedEvent.InvocationId);
                var triggerType = startedEvent.FunctionMetadata.Trigger?.Type;
                var value       = new RunningFunctionInfo(startedEvent.FunctionMetadata.Name, startedEvent.InvocationId, startedEvent.Timestamp, startedEvent.Success, triggerType);

                _runningFunctions.AddOrUpdate(key, value, (k, v) => value);
            }
Beispiel #6
0
            internal void FunctionCompleted(FunctionStartedEvent completedEvent)
            {
                if (runningFunctionCount > 0)
                {
                    runningFunctionCount--;
                }

                var  functionStage     = (completedEvent.Success == false) ? ExecutionStage.Failed : ExecutionStage.Succeeded;
                long executionTimeInMS = (long)completedEvent.EndTime.Subtract(completedEvent.StartTime).TotalMilliseconds;

                var monitoringEvent = new FunctionMetrics(completedEvent.FunctionMetadata.Name, functionStage, executionTimeInMS);

                functionMetricsQueue.Enqueue(monitoringEvent);
            }
            internal void FunctionStarted(FunctionStartedEvent startedEvent)
            {
                _totalExecutionCount++;

                var metricEventPerFunction = new FunctionMetrics(startedEvent.FunctionMetadata.Name, ExecutionStage.Started, 0);

                _functionMetricsQueue.Enqueue(metricEventPerFunction);
                var key = GetDictionaryKey(startedEvent.FunctionMetadata.Name, startedEvent.InvocationId);

                if (!_runningFunctions.ContainsKey(key))
                {
                    lock (_functionMetricEventLockObject)
                    {
                        if (!_runningFunctions.ContainsKey(key))
                        {
                            _runningFunctions.Add(key, new RunningFunctionInfo(startedEvent.FunctionMetadata.Name, startedEvent.InvocationId, startedEvent.Timestamp, startedEvent.Success));
                        }
                    }
                }
            }
            internal void FunctionCompleted(FunctionStartedEvent startedEvent)
            {
                var  functionStage     = (startedEvent.Success == false) ? ExecutionStage.Failed : ExecutionStage.Succeeded;
                long executionTimeInMS = (long)startedEvent.Duration.TotalMilliseconds;
                var  monitoringEvent   = new FunctionMetrics(startedEvent.FunctionMetadata.Name, functionStage, executionTimeInMS);

                _functionMetricsQueue.Enqueue(monitoringEvent);

                var key = GetDictionaryKey(startedEvent.FunctionMetadata.Name, startedEvent.InvocationId);

                if (_runningFunctions.TryRemove(key, out RunningFunctionInfo functionInfo))
                {
                    functionInfo.ExecutionStage = ExecutionStage.Finished;
                    functionInfo.Success        = startedEvent.Success;
                    var endTime = startedEvent.Timestamp + startedEvent.Duration;
                    functionInfo.EndTime = startedEvent.Timestamp + startedEvent.Duration;

                    RaiseFunctionMetricEvent(functionInfo, _runningFunctions.Keys.Count, endTime);
                }
            }