@elastic/apm-rum
Version:
Elastic APM JavaScript agent
1,301 lines (1,199 loc) • 556 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["elastic-apm-rum"] = factory();
else
root["elastic-apm-rum"] = factory();
})(window, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./src/index.js");
/******/ })
/************************************************************************/
/******/ ({
/***/ "../../node_modules/error-stack-parser/error-stack-parser.js":
/*!*****************************************************************************************************************************************************************!*\
!*** /var/lib/jenkins/workspace/ent-rum_apm-agent-rum-mbp_master/src/github.com/elastic/apm-agent-rum-js/node_modules/error-stack-parser/error-stack-parser.js ***!
\*****************************************************************************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function(root, factory) {
'use strict';
// Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, Rhino, and browsers.
/* istanbul ignore next */
if (true) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! stackframe */ "../../node_modules/stackframe/stackframe.js")], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}(this, function ErrorStackParser(StackFrame) {
'use strict';
var FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+\:\d+/;
var CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+\:\d+|\(native\))/m;
var SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code\])?$/;
function _map(array, fn, thisArg) {
if (typeof Array.prototype.map === 'function') {
return array.map(fn, thisArg);
} else {
var output = new Array(array.length);
for (var i = 0; i < array.length; i++) {
output[i] = fn.call(thisArg, array[i]);
}
return output;
}
}
function _filter(array, fn, thisArg) {
if (typeof Array.prototype.filter === 'function') {
return array.filter(fn, thisArg);
} else {
var output = [];
for (var i = 0; i < array.length; i++) {
if (fn.call(thisArg, array[i])) {
output.push(array[i]);
}
}
return output;
}
}
function _indexOf(array, target) {
if (typeof Array.prototype.indexOf === 'function') {
return array.indexOf(target);
} else {
for (var i = 0; i < array.length; i++) {
if (array[i] === target) {
return i;
}
}
return -1;
}
}
return {
/**
* Given an Error object, extract the most information from it.
*
* @param {Error} error object
* @return {Array} of StackFrames
*/
parse: function ErrorStackParser$$parse(error) {
if (typeof error.stacktrace !== 'undefined' || typeof error['opera#sourceloc'] !== 'undefined') {
return this.parseOpera(error);
} else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {
return this.parseV8OrIE(error);
} else if (error.stack) {
return this.parseFFOrSafari(error);
} else {
throw new Error('Cannot parse given Error object');
}
},
// Separate line and column numbers from a string of the form: (URI:Line:Column)
extractLocation: function ErrorStackParser$$extractLocation(urlLike) {
// Fail-fast but return locations like "(native)"
if (urlLike.indexOf(':') === -1) {
return [urlLike];
}
var regExp = /(.+?)(?:\:(\d+))?(?:\:(\d+))?$/;
var parts = regExp.exec(urlLike.replace(/[\(\)]/g, ''));
return [parts[1], parts[2] || undefined, parts[3] || undefined];
},
parseV8OrIE: function ErrorStackParser$$parseV8OrIE(error) {
var filtered = _filter(error.stack.split('\n'), function(line) {
return !!line.match(CHROME_IE_STACK_REGEXP);
}, this);
return _map(filtered, function(line) {
if (line.indexOf('(eval ') > -1) {
// Throw away eval information until we implement stacktrace.js/stackframe#8
line = line.replace(/eval code/g, 'eval').replace(/(\(eval at [^\()]*)|(\)\,.*$)/g, '');
}
var tokens = line.replace(/^\s+/, '').replace(/\(eval code/g, '(').split(/\s+/).slice(1);
var locationParts = this.extractLocation(tokens.pop());
var functionName = tokens.join(' ') || undefined;
var fileName = _indexOf(['eval', '<anonymous>'], locationParts[0]) > -1 ? undefined : locationParts[0];
return new StackFrame(functionName, undefined, fileName, locationParts[1], locationParts[2], line);
}, this);
},
parseFFOrSafari: function ErrorStackParser$$parseFFOrSafari(error) {
var filtered = _filter(error.stack.split('\n'), function(line) {
return !line.match(SAFARI_NATIVE_CODE_REGEXP);
}, this);
return _map(filtered, function(line) {
// Throw away eval information until we implement stacktrace.js/stackframe#8
if (line.indexOf(' > eval') > -1) {
line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval\:\d+\:\d+/g, ':$1');
}
if (line.indexOf('@') === -1 && line.indexOf(':') === -1) {
// Safari eval frames only have function names and nothing else
return new StackFrame(line);
} else {
var tokens = line.split('@');
var locationParts = this.extractLocation(tokens.pop());
var functionName = tokens.join('@') || undefined;
return new StackFrame(functionName,
undefined,
locationParts[0],
locationParts[1],
locationParts[2],
line);
}
}, this);
},
parseOpera: function ErrorStackParser$$parseOpera(e) {
if (!e.stacktrace || (e.message.indexOf('\n') > -1 &&
e.message.split('\n').length > e.stacktrace.split('\n').length)) {
return this.parseOpera9(e);
} else if (!e.stack) {
return this.parseOpera10(e);
} else {
return this.parseOpera11(e);
}
},
parseOpera9: function ErrorStackParser$$parseOpera9(e) {
var lineRE = /Line (\d+).*script (?:in )?(\S+)/i;
var lines = e.message.split('\n');
var result = [];
for (var i = 2, len = lines.length; i < len; i += 2) {
var match = lineRE.exec(lines[i]);
if (match) {
result.push(new StackFrame(undefined, undefined, match[2], match[1], undefined, lines[i]));
}
}
return result;
},
parseOpera10: function ErrorStackParser$$parseOpera10(e) {
var lineRE = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i;
var lines = e.stacktrace.split('\n');
var result = [];
for (var i = 0, len = lines.length; i < len; i += 2) {
var match = lineRE.exec(lines[i]);
if (match) {
result.push(
new StackFrame(
match[3] || undefined,
undefined,
match[2],
match[1],
undefined,
lines[i]
)
);
}
}
return result;
},
// Opera 10.65+ Error.stack very similar to FF/Safari
parseOpera11: function ErrorStackParser$$parseOpera11(error) {
var filtered = _filter(error.stack.split('\n'), function(line) {
return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);
}, this);
return _map(filtered, function(line) {
var tokens = line.split('@');
var locationParts = this.extractLocation(tokens.pop());
var functionCall = (tokens.shift() || '');
var functionName = functionCall
.replace(/<anonymous function(: (\w+))?>/, '$2')
.replace(/\([^\)]*\)/g, '') || undefined;
var argsRaw;
if (functionCall.match(/\(([^\)]*)\)/)) {
argsRaw = functionCall.replace(/^[^\(]+\(([^\)]*)\)$/, '$1');
}
var args = (argsRaw === undefined || argsRaw === '[arguments not available]') ?
undefined : argsRaw.split(',');
return new StackFrame(
functionName,
args,
locationParts[0],
locationParts[1],
locationParts[2],
line);
}, this);
}
};
}));
/***/ }),
/***/ "../../node_modules/opentracing/lib/constants.js":
/*!*****************************************************************************************************************************************************!*\
!*** /var/lib/jenkins/workspace/ent-rum_apm-agent-rum-mbp_master/src/github.com/elastic/apm-agent-rum-js/node_modules/opentracing/lib/constants.js ***!
\*****************************************************************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* The FORMAT_BINARY format represents SpanContexts in an opaque binary
* carrier.
*
* Tracer.inject() will set the buffer field to an Array-like (Array,
* ArrayBuffer, or TypedBuffer) object containing the injected binary data.
* Any valid Object can be used as long as the buffer field of the object
* can be set.
*
* Tracer.extract() will look for `carrier.buffer`, and that field is
* expected to be an Array-like object (Array, ArrayBuffer, or
* TypedBuffer).
*/
exports.FORMAT_BINARY = 'binary';
/**
* The FORMAT_TEXT_MAP format represents SpanContexts using a
* string->string map (backed by a Javascript Object) as a carrier.
*
* NOTE: Unlike FORMAT_HTTP_HEADERS, FORMAT_TEXT_MAP places no restrictions
* on the characters used in either the keys or the values of the map
* entries.
*
* The FORMAT_TEXT_MAP carrier map may contain unrelated data (e.g.,
* arbitrary gRPC metadata); as such, the Tracer implementation should use
* a prefix or other convention to distinguish Tracer-specific key:value
* pairs.
*/
exports.FORMAT_TEXT_MAP = 'text_map';
/**
* The FORMAT_HTTP_HEADERS format represents SpanContexts using a
* character-restricted string->string map (backed by a Javascript Object)
* as a carrier.
*
* Keys and values in the FORMAT_HTTP_HEADERS carrier must be suitable for
* use as HTTP headers (without modification or further escaping). That is,
* the keys have a greatly restricted character set, casing for the keys
* may not be preserved by various intermediaries, and the values should be
* URL-escaped.
*
* The FORMAT_HTTP_HEADERS carrier map may contain unrelated data (e.g.,
* arbitrary HTTP headers); as such, the Tracer implementation should use a
* prefix or other convention to distinguish Tracer-specific key:value
* pairs.
*/
exports.FORMAT_HTTP_HEADERS = 'http_headers';
/**
* A Span may be the "child of" a parent Span. In a “child of” reference,
* the parent Span depends on the child Span in some capacity.
*
* See more about reference types at https://github.com/opentracing/specification
*/
exports.REFERENCE_CHILD_OF = 'child_of';
/**
* Some parent Spans do not depend in any way on the result of their child
* Spans. In these cases, we say merely that the child Span “follows from”
* the parent Span in a causal sense.
*
* See more about reference types at https://github.com/opentracing/specification
*/
exports.REFERENCE_FOLLOWS_FROM = 'follows_from';
//# sourceMappingURL=constants.js.map
/***/ }),
/***/ "../../node_modules/opentracing/lib/functions.js":
/*!*****************************************************************************************************************************************************!*\
!*** /var/lib/jenkins/workspace/ent-rum_apm-agent-rum-mbp_master/src/github.com/elastic/apm-agent-rum-js/node_modules/opentracing/lib/functions.js ***!
\*****************************************************************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Constants = __webpack_require__(/*! ./constants */ "../../node_modules/opentracing/lib/constants.js");
var reference_1 = __webpack_require__(/*! ./reference */ "../../node_modules/opentracing/lib/reference.js");
var span_1 = __webpack_require__(/*! ./span */ "../../node_modules/opentracing/lib/span.js");
/**
* Return a new REFERENCE_CHILD_OF reference.
*
* @param {SpanContext} spanContext - the parent SpanContext instance to
* reference.
* @return a REFERENCE_CHILD_OF reference pointing to `spanContext`
*/
function childOf(spanContext) {
// Allow the user to pass a Span instead of a SpanContext
if (spanContext instanceof span_1.default) {
spanContext = spanContext.context();
}
return new reference_1.default(Constants.REFERENCE_CHILD_OF, spanContext);
}
exports.childOf = childOf;
/**
* Return a new REFERENCE_FOLLOWS_FROM reference.
*
* @param {SpanContext} spanContext - the parent SpanContext instance to
* reference.
* @return a REFERENCE_FOLLOWS_FROM reference pointing to `spanContext`
*/
function followsFrom(spanContext) {
// Allow the user to pass a Span instead of a SpanContext
if (spanContext instanceof span_1.default) {
spanContext = spanContext.context();
}
return new reference_1.default(Constants.REFERENCE_FOLLOWS_FROM, spanContext);
}
exports.followsFrom = followsFrom;
//# sourceMappingURL=functions.js.map
/***/ }),
/***/ "../../node_modules/opentracing/lib/noop.js":
/*!************************************************************************************************************************************************!*\
!*** /var/lib/jenkins/workspace/ent-rum_apm-agent-rum-mbp_master/src/github.com/elastic/apm-agent-rum-js/node_modules/opentracing/lib/noop.js ***!
\************************************************************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var span_1 = __webpack_require__(/*! ./span */ "../../node_modules/opentracing/lib/span.js");
var span_context_1 = __webpack_require__(/*! ./span_context */ "../../node_modules/opentracing/lib/span_context.js");
var tracer_1 = __webpack_require__(/*! ./tracer */ "../../node_modules/opentracing/lib/tracer.js");
exports.tracer = null;
exports.spanContext = null;
exports.span = null;
// Deferred initialization to avoid a dependency cycle where Tracer depends on
// Span which depends on the noop tracer.
function initialize() {
exports.tracer = new tracer_1.default();
exports.span = new span_1.default();
exports.spanContext = new span_context_1.default();
}
exports.initialize = initialize;
//# sourceMappingURL=noop.js.map
/***/ }),
/***/ "../../node_modules/opentracing/lib/reference.js":
/*!*****************************************************************************************************************************************************!*\
!*** /var/lib/jenkins/workspace/ent-rum_apm-agent-rum-mbp_master/src/github.com/elastic/apm-agent-rum-js/node_modules/opentracing/lib/reference.js ***!
\*****************************************************************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var span_1 = __webpack_require__(/*! ./span */ "../../node_modules/opentracing/lib/span.js");
/**
* Reference pairs a reference type constant (e.g., REFERENCE_CHILD_OF or
* REFERENCE_FOLLOWS_FROM) with the SpanContext it points to.
*
* See the exported childOf() and followsFrom() functions at the package level.
*/
var Reference = /** @class */ (function () {
/**
* Initialize a new Reference instance.
*
* @param {string} type - the Reference type constant (e.g.,
* REFERENCE_CHILD_OF or REFERENCE_FOLLOWS_FROM).
* @param {SpanContext} referencedContext - the SpanContext being referred
* to. As a convenience, a Span instance may be passed in instead
* (in which case its .context() is used here).
*/
function Reference(type, referencedContext) {
this._type = type;
this._referencedContext = (referencedContext instanceof span_1.default ?
referencedContext.context() :
referencedContext);
}
/**
* @return {string} The Reference type (e.g., REFERENCE_CHILD_OF or
* REFERENCE_FOLLOWS_FROM).
*/
Reference.prototype.type = function () {
return this._type;
};
/**
* @return {SpanContext} The SpanContext being referred to (e.g., the
* parent in a REFERENCE_CHILD_OF Reference).
*/
Reference.prototype.referencedContext = function () {
return this._referencedContext;
};
return Reference;
}());
exports.default = Reference;
//# sourceMappingURL=reference.js.map
/***/ }),
/***/ "../../node_modules/opentracing/lib/span.js":
/*!************************************************************************************************************************************************!*\
!*** /var/lib/jenkins/workspace/ent-rum_apm-agent-rum-mbp_master/src/github.com/elastic/apm-agent-rum-js/node_modules/opentracing/lib/span.js ***!
\************************************************************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var noop = __webpack_require__(/*! ./noop */ "../../node_modules/opentracing/lib/noop.js");
/**
* Span represents a logical unit of work as part of a broader Trace. Examples
* of span might include remote procedure calls or a in-process function calls
* to sub-components. A Trace has a single, top-level "root" Span that in turn
* may have zero or more child Spans, which in turn may have children.
*/
var Span = /** @class */ (function () {
function Span() {
}
// ---------------------------------------------------------------------- //
// OpenTracing API methods
// ---------------------------------------------------------------------- //
/**
* Returns the SpanContext object associated with this Span.
*
* @return {SpanContext}
*/
Span.prototype.context = function () {
return this._context();
};
/**
* Returns the Tracer object used to create this Span.
*
* @return {Tracer}
*/
Span.prototype.tracer = function () {
return this._tracer();
};
/**
* Sets the string name for the logical operation this span represents.
*
* @param {string} name
*/
Span.prototype.setOperationName = function (name) {
this._setOperationName(name);
return this;
};
/**
* Sets a key:value pair on this Span that also propagates to future
* children of the associated Span.
*
* setBaggageItem() enables powerful functionality given a full-stack
* opentracing integration (e.g., arbitrary application data from a web
* client can make it, transparently, all the way into the depths of a
* storage system), and with it some powerful costs: use this feature with
* care.
*
* IMPORTANT NOTE #1: setBaggageItem() will only propagate baggage items to
* *future* causal descendants of the associated Span.
*
* IMPORTANT NOTE #2: Use this thoughtfully and with care. Every key and
* value is copied into every local *and remote* child of the associated
* Span, and that can add up to a lot of network and cpu overhead.
*
* @param {string} key
* @param {string} value
*/
Span.prototype.setBaggageItem = function (key, value) {
this._setBaggageItem(key, value);
return this;
};
/**
* Returns the value for a baggage item given its key.
*
* @param {string} key
* The key for the given trace attribute.
* @return {string}
* String value for the given key, or undefined if the key does not
* correspond to a set trace attribute.
*/
Span.prototype.getBaggageItem = function (key) {
return this._getBaggageItem(key);
};
/**
* Adds a single tag to the span. See `addTags()` for details.
*
* @param {string} key
* @param {any} value
*/
Span.prototype.setTag = function (key, value) {
// NOTE: the call is normalized to a call to _addTags()
this._addTags((_a = {}, _a[key] = value, _a));
return this;
var _a;
};
/**
* Adds the given key value pairs to the set of span tags.
*
* Multiple calls to addTags() results in the tags being the superset of
* all calls.
*
* The behavior of setting the same key multiple times on the same span
* is undefined.
*
* The supported type of the values is implementation-dependent.
* Implementations are expected to safely handle all types of values but
* may choose to ignore unrecognized / unhandle-able values (e.g. objects
* with cyclic references, function objects).
*
* @return {[type]} [description]
*/
Span.prototype.addTags = function (keyValueMap) {
this._addTags(keyValueMap);
return this;
};
/**
* Add a log record to this Span, optionally at a user-provided timestamp.
*
* For example:
*
* span.log({
* size: rpc.size(), // numeric value
* URI: rpc.URI(), // string value
* payload: rpc.payload(), // Object value
* "keys can be arbitrary strings": rpc.foo(),
* });
*
* span.log({
* "error.description": someError.description(),
* }, someError.timestampMillis());
*
* @param {object} keyValuePairs
* An object mapping string keys to arbitrary value types. All
* Tracer implementations should support bool, string, and numeric
* value types, and some may also support Object values.
* @param {number} timestamp
* An optional parameter specifying the timestamp in milliseconds
* since the Unix epoch. Fractional values are allowed so that
* timestamps with sub-millisecond accuracy can be represented. If
* not specified, the implementation is expected to use its notion
* of the current time of the call.
*/
Span.prototype.log = function (keyValuePairs, timestamp) {
this._log(keyValuePairs, timestamp);
return this;
};
/**
* DEPRECATED
*/
Span.prototype.logEvent = function (eventName, payload) {
return this._log({ event: eventName, payload: payload });
};
/**
* Sets the end timestamp and finalizes Span state.
*
* With the exception of calls to Span.context() (which are always allowed),
* finish() must be the last call made to any span instance, and to do
* otherwise leads to undefined behavior.
*
* @param {number} finishTime
* Optional finish time in milliseconds as a Unix timestamp. Decimal
* values are supported for timestamps with sub-millisecond accuracy.
* If not specified, the current time (as defined by the
* implementation) will be used.
*/
Span.prototype.finish = function (finishTime) {
this._finish(finishTime);
// Do not return `this`. The Span generally should not be used after it
// is finished so chaining is not desired in this context.
};
// ---------------------------------------------------------------------- //
// Derived classes can choose to implement the below
// ---------------------------------------------------------------------- //
// By default returns a no-op SpanContext.
Span.prototype._context = function () {
return noop.spanContext;
};
// By default returns a no-op tracer.
//
// The base class could store the tracer that created it, but it does not
// in order to ensure the no-op span implementation has zero members,
// which allows V8 to aggressively optimize calls to such objects.
Span.prototype._tracer = function () {
return noop.tracer;
};
// By default does nothing
Span.prototype._setOperationName = function (name) {
};
// By default does nothing
Span.prototype._setBaggageItem = function (key, value) {
};
// By default does nothing
Span.prototype._getBaggageItem = function (key) {
return undefined;
};
// By default does nothing
//
// NOTE: both setTag() and addTags() map to this function. keyValuePairs
// will always be an associative array.
Span.prototype._addTags = function (keyValuePairs) {
};
// By default does nothing
Span.prototype._log = function (keyValuePairs, timestamp) {
};
// By default does nothing
//
// finishTime is expected to be either a number or undefined.
Span.prototype._finish = function (finishTime) {
};
return Span;
}());
exports.Span = Span;
exports.default = Span;
//# sourceMappingURL=span.js.map
/***/ }),
/***/ "../../node_modules/opentracing/lib/span_context.js":
/*!********************************************************************************************************************************************************!*\
!*** /var/lib/jenkins/workspace/ent-rum_apm-agent-rum-mbp_master/src/github.com/elastic/apm-agent-rum-js/node_modules/opentracing/lib/span_context.js ***!
\********************************************************************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* SpanContext represents Span state that must propagate to descendant Spans
* and across process boundaries.
*
* SpanContext is logically divided into two pieces: the user-level "Baggage"
* (see setBaggageItem and getBaggageItem) that propagates across Span
* boundaries and any Tracer-implementation-specific fields that are needed to
* identify or otherwise contextualize the associated Span instance (e.g., a
* <trace_id, span_id, sampled> tuple).
*/
var SpanContext = /** @class */ (function () {
function SpanContext() {
}
return SpanContext;
}());
exports.SpanContext = SpanContext;
exports.default = SpanContext;
//# sourceMappingURL=span_context.js.map
/***/ }),
/***/ "../../node_modules/opentracing/lib/tracer.js":
/*!**************************************************************************************************************************************************!*\
!*** /var/lib/jenkins/workspace/ent-rum_apm-agent-rum-mbp_master/src/github.com/elastic/apm-agent-rum-js/node_modules/opentracing/lib/tracer.js ***!
\**************************************************************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Functions = __webpack_require__(/*! ./functions */ "../../node_modules/opentracing/lib/functions.js");
var Noop = __webpack_require__(/*! ./noop */ "../../node_modules/opentracing/lib/noop.js");
var span_1 = __webpack_require__(/*! ./span */ "../../node_modules/opentracing/lib/span.js");
/**
* Tracer is the entry-point between the instrumentation API and the tracing
* implementation.
*
* The default object acts as a no-op implementation.
*
* Note to implementators: derived classes can choose to directly implement the
* methods in the "OpenTracing API methods" section, or optionally the subset of
* underscore-prefixed methods to pick up the argument checking and handling
* automatically from the base class.
*/
var Tracer = /** @class */ (function () {
function Tracer() {
}
// ---------------------------------------------------------------------- //
// OpenTracing API methods
// ---------------------------------------------------------------------- //
/**
* Starts and returns a new Span representing a logical unit of work.
*
* For example:
*
* // Start a new (parentless) root Span:
* var parent = Tracer.startSpan('DoWork');
*
* // Start a new (child) Span:
* var child = Tracer.startSpan('load-from-db', {
* childOf: parent.context(),
* });
*
* // Start a new async (FollowsFrom) Span:
* var child = Tracer.startSpan('async-cache-write', {
* references: [
* opentracing.followsFrom(parent.context())
* ],
* });
*
* @param {string} name - the name of the operation (REQUIRED).
* @param {SpanOptions} [options] - options for the newly created span.
* @return {Span} - a new Span object.
*/
Tracer.prototype.startSpan = function (name, options) {
if (options === void 0) { options = {}; }
// Convert options.childOf to fields.references as needed.
if (options.childOf) {
// Convert from a Span or a SpanContext into a Reference.
var childOf = Functions.childOf(options.childOf);
if (options.references) {
options.references.push(childOf);
}
else {
options.references = [childOf];
}
delete (options.childOf);
}
return this._startSpan(name, options);
};
/**
* Injects the given SpanContext instance for cross-process propagation
* within `carrier`. The expected type of `carrier` depends on the value of
* `format.
*
* OpenTracing defines a common set of `format` values (see
* FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has
* an expected carrier type.
*
* Consider this pseudocode example:
*
* var clientSpan = ...;
* ...
* // Inject clientSpan into a text carrier.
* var headersCarrier = {};
* Tracer.inject(clientSpan.context(), Tracer.FORMAT_HTTP_HEADERS, headersCarrier);
* // Incorporate the textCarrier into the outbound HTTP request header
* // map.
* Object.assign(outboundHTTPReq.headers, headersCarrier);
* // ... send the httpReq
*
* @param {SpanContext} spanContext - the SpanContext to inject into the
* carrier object. As a convenience, a Span instance may be passed
* in instead (in which case its .context() is used for the
* inject()).
* @param {string} format - the format of the carrier.
* @param {any} carrier - see the documentation for the chosen `format`
* for a description of the carrier object.
*/
Tracer.prototype.inject = function (spanContext, format, carrier) {
// Allow the user to pass a Span instead of a SpanContext
if (spanContext instanceof span_1.default) {
spanContext = spanContext.context();
}
return this._inject(spanContext, format, carrier);
};
/**
* Returns a SpanContext instance extracted from `carrier` in the given
* `format`.
*
* OpenTracing defines a common set of `format` values (see
* FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has
* an expected carrier type.
*
* Consider this pseudocode example:
*
* // Use the inbound HTTP request's headers as a text map carrier.
* var headersCarrier = inboundHTTPReq.headers;
* var wireCtx = Tracer.extract(Tracer.FORMAT_HTTP_HEADERS, headersCarrier);
* var serverSpan = Tracer.startSpan('...', { childOf : wireCtx });
*
* @param {string} format - the format of the carrier.
* @param {any} carrier - the type of the carrier object is determined by
* the format.
* @return {SpanContext}
* The extracted SpanContext, or null if no such SpanContext could
* be found in `carrier`
*/
Tracer.prototype.extract = function (format, carrier) {
return this._extract(format, carrier);
};
// ---------------------------------------------------------------------- //
// Derived classes can choose to implement the below
// ---------------------------------------------------------------------- //
// NOTE: the input to this method is *always* an associative array. The
// public-facing startSpan() method normalizes the arguments so that
// all N implementations do not need to worry about variations in the call
// signature.
//
// The default behavior returns a no-op span.
Tracer.prototype._startSpan = function (name, fields) {
return Noop.span;
};
// The default behavior is a no-op.
Tracer.prototype._inject = function (spanContext, format, carrier) {
};
// The default behavior is to return a no-op SpanContext.
Tracer.prototype._extract = function (format, carrier) {
return Noop.spanContext;
};
return Tracer;
}());
exports.Tracer = Tracer;
exports.default = Tracer;
//# sourceMappingURL=tracer.js.map
/***/ }),
/***/ "../../node_modules/promise-polyfill/src/finally.js":
/*!********************************************************************************************************************************************************!*\
!*** /var/lib/jenkins/workspace/ent-rum_apm-agent-rum-mbp_master/src/github.com/elastic/apm-agent-rum-js/node_modules/promise-polyfill/src/finally.js ***!
\********************************************************************************************************************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/**
* @this {Promise}
*/
function finallyConstructor(callback) {
var constructor = this.constructor;
return this.then(
function(value) {
// @ts-ignore
return constructor.resolve(callback()).then(function() {
return value;
});
},
function(reason) {
// @ts-ignore
return constructor.resolve(callback()).then(function() {
// @ts-ignore
return constructor.reject(reason);
});
}
);
}
/* harmony default export */ __webpack_exports__["default"] = (finallyConstructor);
/***/ }),
/***/ "../../node_modules/promise-polyfill/src/index.js":
/*!******************************************************************************************************************************************************!*\
!*** /var/lib/jenkins/workspace/ent-rum_apm-agent-rum-mbp_master/src/github.com/elastic/apm-agent-rum-js/node_modules/promise-polyfill/src/index.js ***!
\******************************************************************************************************************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _finally__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./finally */ "../../node_modules/promise-polyfill/src/finally.js");
// Store setTimeout reference so promise-polyfill will be unaffected by
// other code modifying setTimeout (like sinon.useFakeTimers())
var setTimeoutFunc = setTimeout;
function isArray(x) {
return Boolean(x && typeof x.length !== 'undefined');
}
function noop() {}
// Polyfill for Function.prototype.bind
function bind(fn, thisArg) {
return function() {
fn.apply(thisArg, arguments);
};
}
/**
* @constructor
* @param {Function} fn
*/
function Promise(fn) {
if (!(this instanceof Promise))
throw new TypeError('Promises must be constructed via new');
if (typeof fn !== 'function') throw new TypeError('not a function');
/** @type {!number} */
this._state = 0;
/** @type {!boolean} */
this._handled = false;
/** @type {Promise|undefined} */
this._value = undefined;
/** @type {!Array<!Function>} */
this._deferreds = [];
doResolve(fn, this);
}
function handle(self, deferred) {
while (self._state === 3) {
self = self._value;
}
if (self._state === 0) {
self._deferreds.push(deferred);
return;
}
self._handled = true;
Promise._immediateFn(function() {
var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;
if (cb === null) {
(self._state === 1 ? resolve : reject)(deferred.promise, self._value);
return;
}
var ret;
try {
ret = cb(self._value);
} catch (e) {
reject(deferred.promise, e);
return;
}
resolve(deferred.promise, ret);
});
}
function resolve(self, newValue) {
try {
// Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
if (newValue === self)
throw new TypeError('A promise cannot be resolved with itself.');
if (
newValue &&
(typeof newValue === 'object' || typeof newValue === 'function')
) {
var then = newValue.then;
if (newValue instanceof Promise) {
self._state = 3;
self._value = newValue;
finale(self);
return;
} else if (typeof then === 'function') {
doResolve(bind(then, newValue), self);
return;
}
}
self._state = 1;
self._value = newValue;
finale(self);
} catch (e) {
reject(self, e);
}
}
function reject(self, newValue) {
self._state = 2;
self._value = newValue;
finale(self);
}
function finale(self) {
if (self._state === 2 && self._deferreds.length === 0) {
Promise._immediateFn(function() {
if (!self._handled) {
Promise._unhandledRejectionFn(self._value);
}
});
}
for (var i = 0, len = self._deferreds.length; i < len; i++) {
handle(self, self._deferreds[i]);
}
self._deferreds = null;
}
/**
* @constructor
*/
function Handler(onFulfilled, onRejected, promise) {
this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;
this.onRejected = typeof onRejected === 'function' ? onRejected : null;
this.promise = promise;
}
/**
* Take a potentially misbehaving resolver function and make sure
* onFulfilled and onRejected are only called once.
*
* Makes no guarantees about asynchrony.
*/
function doResolve(fn, self) {
var done = false;
try {
fn(
function(value) {
if (done) return;
done = true;
resolve(self, value);
},
function(reason) {
if (done) return;
done = true;
reject(self, reason);
}
);
} catch (ex) {
if (done) return;
done = true;
reject(self, ex);
}
}
Promise.prototype['catch'] = function(onRejected) {
return this.then(null, onRejected);
};
Promise.prototype.then = function(onFulfilled, onRejected) {
// @ts-ignore
var prom = new this.constructor(noop);
handle(this, new Handler(onFulfilled, onRejected, prom));
return prom;
};
Promise.prototype['finally'] = _finally__WEBPACK_IMPORTED_MODULE_0__["default"];
Promise.all = function(arr) {
return new Promise(function(resolve, reject) {
if (!isArray(arr)) {
return reject(new TypeError('Promise.all accepts an array'));
}
var args = Array.prototype.slice.call(arr);
if (args.length === 0) return resolve([]);
var remaining = args.length;
function res(i, val) {
try {
if (val && (typeof val === 'object' || typeof val === 'function')) {
var then = val.then;
if (typeof then === 'function') {
then.call(
val,
function(val) {
res(i, val);
},
reject
);
return;
}
}
args[i] = val;
if (--remaining === 0) {
resolve(args);
}
} catch (ex) {
reject(ex);
}
}
for (var i = 0; i < args.length; i++) {
res(i, args[i]);
}
});
};
Promise.resolve = function(value) {
if (value && typeof value === 'object' && value.constructor === Promise) {
return value;
}
return new Promise(function(resolve) {
resolve(value);
});
};
Promise.reject = function(value) {
return new Promise(function(resolve, reject) {
reject(value);
});
};
Promise.race = function(arr) {
return new Promise(function(resolve, reject) {
if (!isArray(arr)) {
return reject(new TypeError('Promise.race accepts an array'));
}
for (var i = 0, len = arr.length; i < len; i++) {
Promise.resolve(arr[i]).then(resolve, reject);
}
});
};
// Use polyfill for setImmediate for performance gains
Promise._immediateFn =
// @ts-ignore
(typeof setImmediate === 'function' &&
function(fn) {
// @ts-ignore
setImmediate(fn);
}) ||
function(fn) {
setTimeoutFunc(fn, 0);
};
Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) {
if (typeof console !== 'undefined' && console) {
console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console
}
};
/* harmony default export */ __webpack_exports__["default"] = (Promise);
/***/ }),
/***/ "../../node_modules/stackframe/stackframe.js":
/*!*************************************************************************************************************************************************!*\
!*** /var/lib/jenkins/workspace/ent-rum_apm-agent-rum-mbp_master/src/github.com/elastic/apm-agent-rum-js/node_modules/stackframe/stackframe.js ***!
\*************************************************************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (root, factory) {
'use strict';
// Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, Rhino, and browsers.
/* istanbul ignore next */
if (true) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}(this, function () {
'use strict';
function _isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
function StackFrame(functionName, args, fileName, lineNumber, columnNumber, source) {
if (functionName !== undefined) {
this.setFunctionName(functionName);
}
if (args !== undefined) {
this.setArgs(args);
}
if (fileName !== undefined) {
this.setFileName(fileName);
}
if (lineNumber !== undefined) {
this.setLineNumber(lineNumber);
}
if (columnNumber !== undefined) {
this.setColumnNumber(columnNumber);
}
if (source !== undefined) {
this.setSource(source);
}
}
StackFrame.prototype = {
getFunctionName: function () {
return this.functionName;
},
setFunctionName: function (v) {
this.functionName = String(v);
},
getArgs: function () {
return this.args;
},
setArgs: function (v) {
if (Object.prototype.toString.call(v) !== '[object Array]') {
throw new TypeError('Args must be an Array');
}
this.args = v;
},
// NOTE: Prope