Event recording metrics for a whole API call.
@returns {object} a subset of api call metrics
@api private
170755
function apiCallEvent(request) {
    var api = request.service.api.operations[request.operation];
    var monitoringEvent = {
      Type: 'ApiCall',
      Api: api ? api.name : request.operation,
      Version: 1,
      Service: request.service.api.serviceId || request.service.api.endpointPrefix,
      Region: request.httpRequest.region,
      MaxRetriesExceeded: 0,
      UserAgent: request.httpRequest.getUserAgent(),
    };
    var response = request.response;
    if (response.httpResponse.statusCode) {
      monitoringEvent.FinalHttpStatusCode = response.httpResponse.statusCode;
    }
    if (response.error) {
      var error = response.error;
      var statusCode = response.httpResponse.statusCode;
      if (statusCode > 299) {
        if (error.code) monitoringEvent.FinalAwsException = error.code;
        if (error.message) monitoringEvent.FinalAwsExceptionMessage = error.message;
      } else {
        if (error.code || error.name) monitoringEvent.FinalSdkException = error.code || error.name;
        if (error.message) monitoringEvent.FinalSdkExceptionMessage = error.message;
      }
    }
    return monitoringEvent;
  }
763084
function () {
                var eventListeners = this._cfg ? this._cfg.on : null;
                if (eventListeners) {
                    for (var listener in eventListeners) {
                        if (eventListeners.hasOwnProperty(listener)) {
                            eventListeners[listener] = this.$normCallback(eventListeners[listener]);
                        }
                    }
                }
            }
1317226
function() {
    for (var i = 0, len = this.events.length; i < len; i++) {
      if (this.events[i].streamRevision > this.lastRevision) {
        this.lastRevision = this.events[i].streamRevision;
      }
    }

    return this.lastRevision;
  }
407958
function getMemoryUsage(unitInfo) {
  const data = process.memoryUsage();
  const keys = Object.keys(data);
  const result = {};
  keys.forEach((key) => {
    result[key] = format(data[key], unitInfo);
  });
  return result;
}
873091
function getEventSources(event) {
  return event && Array.isArray(event.Records) ? event.Records.map(getEventSource) : [];
}
529133
function Metric(worker) {

  var tasksExecutedCount = 0;
  var pollCount = 0;

  var executionTime = 0;
  var pollTime = 0;
  var idleTime = 0;

  var activeTasks = 0;

  worker.on('executeTask', function() {
    activeTasks++;
  });

  worker.on('executeTask:done', function(task, durationMs) {
    tasksExecutedCount++;
    activeTasks--;
    executionTime += durationMs;
  });

  worker.on('poll', function() {
    pollCount++;
  });

  worker.on('poll:done', function(reason, durationMs) {
    pollTime += durationMs;
  });

  worker.on('reschedule', function(waitMs) {
    idleTime += waitMs;
  });


  function printStats() {
    debug('stats', {
      executionTime,
      pollTime,
      idleTime,
      pollCount,
      tasksExecutedCount,
      activeTasks
    });

    executionTime = 0;
    pollTime = 0;
    idleTime = 0;
    pollCount = 0;
    tasksExecutedCount = 0;
  }

  var timer;

  worker.on('start', () => {
    printStats();

    timer = setInterval(printStats, 5000);
  });

  worker.on('stop', () => {
    if (timer) {
      clearInterval(timer);
    }

    timer = null;
  });
}
1018400
function() {
    dom.hide(this.$startHelp);
    dom.hide(this.$results);
    dom.hide(this.$measureTasks);
    dom.hide(this.$measuringPrompt);
    dom.show(this.$startPrompt);
  }
658971
def get_metric(run_id, metric_id):
    
    data = current_app.config["data"]  # type: DataStorage
    dao = data.get_metrics_dao()
    metric = dao.get(run_id, metric_id)

    return Response(render_template(
        "api/metric.js",
        run_id=metric["run_id"],
        metric_id=metric["metric_id"],
        name=metric["name"],
        steps=metric["steps"],
        timestamps=metric["timestamps"],
        values=metric["values"]),
        mimetype="application/json")
94814
function(obj, methodName, methodArgs, probeData) {
        // Start metrics
        that.metricsProbeStart(probeData);
        that.requestProbeStart(probeData);
        // End metrics
        aspect.aroundCallback(
          methodArgs,
          probeData,
          function(target, args, probeData) {
            // Get HTTP request method from options
            var ri = getRequestItems(methodArgs[0]);
            that.metricsProbeEnd(probeData, ri.requestMethod, ri.urlRequested, args[0], ri.headers);
            that.requestProbeEnd(probeData, ri.requestMethod, ri.urlRequested, args[0], ri.headers);
          },
          function(target, args, probeData, ret) {
            // Don't need to do anything after the callback
            return ret;
          }
        );
      }
610348
function () {
  function PowerAssertRecorder() {
    this.captured = [];
  }

  PowerAssertRecorder.prototype._capt = function _capt (value, espath) {
    this.captured.push({value: value, espath: espath});
    return value;
  };

  PowerAssertRecorder.prototype._expr = function _expr (value, source) {
    var capturedValues = this.captured;
    this.captured = [];
    return {
      powerAssertContext: {
        value: value,
        events: capturedValues
      },
      source: source
    };
  };

  return PowerAssertRecorder;
}
968219
function Analytics() {
  this._options({});
  this.Integrations = {};
  this._integrations = {};
  this._readied = false;
  this._timeout = 300;
  // XXX: BACKWARDS COMPATIBILITY
  this._user = user;
  this.log = debug('analytics.js');
  bindAll(this);

  var self = this;
  this.on('initialize', function(settings, options) {
    if (options.initialPageview) self.page();
    self._parseQuery(window.location.search);
  });
}
234629
function (globalEasing) {

        var self = this;
        var clipCount = 0;

        var oneTrackDone = function() {
            clipCount--;
            if (clipCount === 0) {
                self._doneCallback();
            }
        };

        var lastClip;
        for (var propName in this._tracks) {
            var clip = createTrackClip(
                this, globalEasing, oneTrackDone,
                this._tracks[propName], propName, self._interpolater, self._maxTime
            );
            if (clip) {
                this._clipList.push(clip);
                clipCount++;

                // If start after added to animation
                if (this.animation) {
                    this.animation.addClip(clip);
                }

                lastClip = clip;
            }
        }

        // Add during callback on the last clip
        if (lastClip) {
            var oldOnFrame = lastClip.onframe;
            lastClip.onframe = function (target, percent) {
                oldOnFrame(target, percent);

                for (var i = 0; i < self._onframeList.length; i++) {
                    self._onframeList[i](target, percent);
                }
            };
        }

        if (!clipCount) {
            this._doneCallback();
        }
        return this;
    }
71635
function () {

    const oThis = this;

    const callback = async function (response) {
      if (response.isFailure()) {
        return response;
      }
      return responseHelper.successWithData({allTimeStakedAmount: response.data.getTotalStake});
    };

    return oThis._callMethod('getTotalStake').then(callback);

  }
1368137
function getPerformanceTimingData() {
        var PerformanceObj = {
            'redirecting': performance.timing.fetchStart - performance.timing.navigationStart,
            'dnsconnect': performance.timing.requestStart - performance.timing.fetchStart,
            'request': performance.timing.responseStart - performance.timing.requestStart,
            'response': performance.timing.responseEnd - performance.timing.responseStart,
            'domprocessing': performance.timing.domComplete - performance.timing.responseEnd,
            'load': performance.timing.loadEventEnd - performance.timing.loadEventStart
        };

        /**
         * Obtaining the transferred kb of resources inluding estimated document size.
         */
        if (window.performance && window.performance.getEntriesByType) {
            var resource;
            var resources = window.performance.getEntriesByType('resource');
            var documentSize = unescape(encodeURIComponent(document.documentElement.innerHTML)).length / 4.2;
            var byteTotal = 0;
            for (var i = 0; i < resources.length; i++) {
                resource = resources[i];
                byteTotal = byteTotal + resource.transferSize;
            }
            PerformanceObj.transferbytes = byteTotal + Math.round(documentSize);
            PerformanceObj.transferrequests = resources.length + 1;
        }

        return PerformanceObj;
    }
312221
function getEvents(duration){

    if (gazeCallback == null){

        return [];
    
    }

    let gaze = gazeCallback();

    if (!gaze){

        return [];

    }

    const extra = {
        'ik': ['Time'],
        'iv': [utils.getDataPointDuration(duration)],
        'fk': [],
        'fv': []
    };

    return [['vadrGaze', gaze, extra]];

}
930338
function metricStart(ctx) {
	ctx.startTime = Date.now();
	ctx.startHrTime = process.hrtime();
	ctx.duration = 0;

	if (ctx.metrics) {
		const payload = generateMetricPayload(ctx);
		ctx.broker.emit("metrics.trace.span.start", payload);
	}
}
1189344
function() {
    var callbacks = this._callbacks;
    var contexts = this._contexts;
    if (callbacks) {
      ("production" !== "development" ? invariant(
        callbacks.length === contexts.length,
        'Mismatched list of contexts in callback queue'
      ) : invariant(callbacks.length === contexts.length));
      this._callbacks = null;
      this._contexts = null;
      for (var i = 0, l = callbacks.length; i < l; i++) {
        callbacks[i].call(contexts[i]);
      }
      callbacks.length = 0;
      contexts.length = 0;
    }
  }