!function(){var t={311:function(t,e,r){t.exports=r(507)},507:function(t,e,r){var n,o;function i(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}t=r.nmd(t),n=window,o=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e||4&e&&"object"==(void 0===t?"undefined":i(t))&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,(function(e){return t[e]}).bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=19)}([function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){if(t)for(var r in t)hasOwnProperty.call(t,r)&&e(t[r],r)},t.exports=e.default},function(t,e,r){"use strict";t.exports={Platform:r(29),ThriftTransport:r(34),thrift:r(35),crouton_thrift:r(36)}},function(t,e,r){"use strict";function n(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}Object.defineProperty(e,"__esModule",{value:!0});var o=r(22);e.BinaryCarrier=o.default;var i=r(23);e.Tags=i;var a=r(8),s=r(13);e.Reference=s.default;var u=r(4);e.Span=u.default;var c=r(10);e.SpanContext=c.default;var l=r(9);e.Tracer=l.Tracer;var p=r(24);e.MockTracer=p.MockTracer,n(r(27)),n(r(12)),n(r(11)),a.initialize()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.toString=function(t){return""+t},e.toNumber=function(t){return Number(t)},e.toBoolean=function(t){return!!t}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(8),o=function(){function t(){}return t.prototype.context=function(){return this._context()},t.prototype.tracer=function(){return this._tracer()},t.prototype.setOperationName=function(t){return this._setOperationName(t),this},t.prototype.setBaggageItem=function(t,e){return this._setBaggageItem(t,e),this},t.prototype.getBaggageItem=function(t){return this._getBaggageItem(t)},t.prototype.setTag=function(t,e){var r;return this._addTags(((r={})[t]=e,r)),this},t.prototype.addTags=function(t){return this._addTags(t),this},t.prototype.log=function(t,e){return this._log(t,e),this},t.prototype.logEvent=function(t,e){return this._log({event:t,payload:e})},t.prototype.finish=function(t){this._finish(t)},t.prototype._context=function(){return n.spanContext},t.prototype._tracer=function(){return n.tracer},t.prototype._setOperationName=function(t){},t.prototype._setBaggageItem=function(t,e){},t.prototype._getBaggageItem=function(t){},t.prototype._addTags=function(t){},t.prototype._log=function(t,e){},t.prototype._finish=function(t){},t}();e.Span=o,e.default=o},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n,o=function(){function t(t,e){for(var r=0;r1){var a=t+"="+encodeURIComponent(e)+(r?"; expires="+new Date(+new Date+1e3*r).toUTCString():"")+(n?"; path="+n:"")+(o?"; domain="+o:"")+(i?"; secure":"");return document.cookie=a,a}return decodeURIComponent((("; "+document.cookie).split("; "+t+"=")[1]||"").split(";")[0])}:function(){return null},isBrowser:n}},function(t,e,r){"use strict";var n,o;n={},(o={}).KeyValue=function(t){if(this.Key=null,this.Value=null,t){if(void 0===t.Key)throw new n.TProtocolException(n.TProtocolExceptionType.UNKNOWN,"Required field Key is unset!");if(this.Key=t.Key,void 0===t.Value)throw new n.TProtocolException(n.TProtocolExceptionType.UNKNOWN,"Required field Value is unset!");this.Value=t.Value}},o.KeyValue.prototype={},o.KeyValue.prototype.read=!1,o.KeyValue.prototype.write=!1,o.NamedCounter=function(t){if(this.Name=null,this.Value=null,t){if(void 0===t.Name)throw new n.TProtocolException(n.TProtocolExceptionType.UNKNOWN,"Required field Name is unset!");if(this.Name=t.Name,void 0===t.Value)throw new n.TProtocolException(n.TProtocolExceptionType.UNKNOWN,"Required field Value is unset!");this.Value=t.Value}},o.NamedCounter.prototype={},o.NamedCounter.prototype.read=!1,o.NamedCounter.prototype.write=!1,o.Runtime=function(t){this.guid=null,this.start_micros=null,this.group_name=null,this.attrs=null,t&&(void 0!==t.guid&&(this.guid=t.guid),void 0!==t.start_micros&&(this.start_micros=t.start_micros),void 0!==t.group_name&&(this.group_name=t.group_name),void 0!==t.attrs&&(this.attrs=t.attrs))},o.Runtime.prototype={},o.Runtime.prototype.read=!1,o.Runtime.prototype.write=!1,o.LogRecord=function(t){this.timestamp_micros=null,this.fields=null,this.runtime_guid=null,this.span_guid=null,this.stable_name=null,this.message=null,this.level=null,this.thread_id=null,this.filename=null,this.line_number=null,this.stack_frames=null,this.payload_json=null,this.error_flag=null,t&&(void 0!==t.timestamp_micros&&(this.timestamp_micros=t.timestamp_micros),void 0!==t.fields&&(this.fields=t.fields),void 0!==t.runtime_guid&&(this.runtime_guid=t.runtime_guid),void 0!==t.span_guid&&(this.span_guid=t.span_guid),void 0!==t.stable_name&&(this.stable_name=t.stable_name),void 0!==t.message&&(this.message=t.message),void 0!==t.level&&(this.level=t.level),void 0!==t.thread_id&&(this.thread_id=t.thread_id),void 0!==t.filename&&(this.filename=t.filename),void 0!==t.line_number&&(this.line_number=t.line_number),void 0!==t.stack_frames&&(this.stack_frames=t.stack_frames),void 0!==t.payload_json&&(this.payload_json=t.payload_json),void 0!==t.error_flag&&(this.error_flag=t.error_flag))},o.LogRecord.prototype={},o.LogRecord.prototype.read=!1,o.LogRecord.prototype.write=!1,o.TraceJoinId=function(t){if(this.TraceKey=null,this.Value=null,t){if(void 0===t.TraceKey)throw new n.TProtocolException(n.TProtocolExceptionType.UNKNOWN,"Required field TraceKey is unset!");if(this.TraceKey=t.TraceKey,void 0===t.Value)throw new n.TProtocolException(n.TProtocolExceptionType.UNKNOWN,"Required field Value is unset!");this.Value=t.Value}},o.TraceJoinId.prototype={},o.TraceJoinId.prototype.read=!1,o.TraceJoinId.prototype.write=!1,o.SpanRecord=function(t){this.span_guid=null,this.trace_guid=null,this.runtime_guid=null,this.span_name=null,this.join_ids=null,this.oldest_micros=null,this.youngest_micros=null,this.attributes=null,this.error_flag=null,this.log_records=null,t&&(void 0!==t.span_guid&&(this.span_guid=t.span_guid),void 0!==t.trace_guid&&(this.trace_guid=t.trace_guid),void 0!==t.runtime_guid&&(this.runtime_guid=t.runtime_guid),void 0!==t.span_name&&(this.span_name=t.span_name),void 0!==t.join_ids&&(this.join_ids=t.join_ids),void 0!==t.oldest_micros&&(this.oldest_micros=t.oldest_micros),void 0!==t.youngest_micros&&(this.youngest_micros=t.youngest_micros),void 0!==t.attributes&&(this.attributes=t.attributes),void 0!==t.error_flag&&(this.error_flag=t.error_flag),void 0!==t.log_records&&(this.log_records=t.log_records))},o.SpanRecord.prototype={},o.SpanRecord.prototype.read=!1,o.SpanRecord.prototype.write=!1,o.Auth=function(t){this.access_token=null,t&&void 0!==t.access_token&&(this.access_token=t.access_token)},o.Auth.prototype={},o.Auth.prototype.read=!1,o.Auth.prototype.write=!1,o.Timing=function(t){this.receive_micros=null,this.transmit_micros=null,t&&(void 0!==t.receive_micros&&(this.receive_micros=t.receive_micros),void 0!==t.transmit_micros&&(this.transmit_micros=t.transmit_micros))},o.Timing.prototype={},o.Timing.prototype.read=!1,o.Timing.prototype.write=!1,o.SampleCount=function(t){this.oldest_micros=null,this.youngest_micros=null,this.count=null,t&&(void 0!==t.oldest_micros&&(this.oldest_micros=t.oldest_micros),void 0!==t.youngest_micros&&(this.youngest_micros=t.youngest_micros),void 0!==t.count&&(this.count=t.count))},o.SampleCount.prototype={},o.SampleCount.prototype.read=!1,o.SampleCount.prototype.write=!1,o.MetricsSample=function(t){if(this.name=null,this.int64_value=null,this.double_value=null,t){if(void 0===t.name)throw new n.TProtocolException(n.TProtocolExceptionType.UNKNOWN,"Required field name is unset!");this.name=t.name,void 0!==t.int64_value&&(this.int64_value=t.int64_value),void 0!==t.double_value&&(this.double_value=t.double_value)}},o.MetricsSample.prototype={},o.MetricsSample.prototype.read=!1,o.MetricsSample.prototype.write=!1,o.Metrics=function(t){this.counts=null,this.gauges=null,t&&(void 0!==t.counts&&(this.counts=t.counts),void 0!==t.gauges&&(this.gauges=t.gauges))},o.Metrics.prototype={},o.Metrics.prototype.read=!1,o.Metrics.prototype.write=!1,o.ReportRequest=function(t){this.runtime=null,this.span_records=null,this.log_records=null,this.timestamp_offset_micros=null,this.oldest_micros=null,this.youngest_micros=null,this.counters=null,this.internal_logs=null,this.internal_metrics=null,t&&(void 0!==t.runtime&&(this.runtime=t.runtime),void 0!==t.span_records&&(this.span_records=t.span_records),void 0!==t.log_records&&(this.log_records=t.log_records),void 0!==t.timestamp_offset_micros&&(this.timestamp_offset_micros=t.timestamp_offset_micros),void 0!==t.oldest_micros&&(this.oldest_micros=t.oldest_micros),void 0!==t.youngest_micros&&(this.youngest_micros=t.youngest_micros),void 0!==t.counters&&(this.counters=t.counters),void 0!==t.internal_logs&&(this.internal_logs=t.internal_logs),void 0!==t.internal_metrics&&(this.internal_metrics=t.internal_metrics))},o.ReportRequest.prototype={},o.ReportRequest.prototype.read=!1,o.ReportRequest.prototype.write=!1,o.Command=function(t){this.disable=null,t&&void 0!==t.disable&&(this.disable=t.disable)},o.Command.prototype={},o.Command.prototype.read=!1,o.Command.prototype.write=!1,o.ReportResponse=function(t){this.commands=null,this.timing=null,t&&(void 0!==t.commands&&(this.commands=t.commands),void 0!==t.timing&&(this.timing=t.timing))},o.ReportResponse.prototype={},o.ReportResponse.prototype.read=!1,o.ReportResponse.prototype.write=!1,t.exports.crouton_thrift=o,t.exports.Thrift={}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){for(var r=0;r=3){var o="",a=0;(0,l.default)(r,function(t,e){o+=" "+JSON.stringify(e)+": "+JSON.stringify(t.newValue)+"\n",a++}),a>0&&this._debug("Options modified:\n"+o)}this.emit("options",r,this._options,this)}},{key:"_setOptionInternal",value:function(t,e,r,n){var o=n.name,a=r[o],s=void 0===a?"undefined":i(a);if(void 0!==a){switch(n.type){case"any":break;case"bool":if(!0!==a&&!1!==a)return void this._error("Invalid boolean option '"+o+"' '"+a+"'");break;case"function":if("function"!=typeof a)return void this._error("Invalid function option '"+o+"' '"+a+"'");break;case"int":if("number"!==s||Math.floor(a)!==a)return void this._error("Invalid int option '"+o+"' '"+a+"'");if(void 0!==n.min&&void 0!==n.max&&!(a>=n.min&&a<=n.max))return void this._error("Option '"+o+"' out of range '"+a+"' is not between "+n.min+" and "+n.max);break;case"string":switch(s){case"string":break;case"number":a=T.toString(a);break;default:return void this._error("Invalid string option "+o+" "+a)}break;case"array":if("[object Array]"!==Object.prototype.toString.call(a))return void this._error("Invalid type for array option "+o+": found '"+s+"'");break;default:return void this._error("Unknown option type '"+n.type+"'")}var u=this._options[o];if(void 0===u)throw Error("Attempt to set unknown option "+o);"object"===s||u!==a?(t[o]={oldValue:u,newValue:a},this._options[o]=a):e[o]=!0}}},{key:"_initReportingDataIfNeeded",value:function(t){var e=this;if(null===this._auth){this._runtimeGUID=this._platform.runtimeGUID(this._options.component_name),this._auth=new f.default(this._options.access_token);var r={};(0,l.default)(this._options.tags,function(t,n){"string"==typeof t?r[n]=t:e._error("Tracer tag value is not a string: key="+n)}),r["lightstep.tracer_version"]=E.version;var n=this._platform.tracerTags();(0,l.default)(n,function(t,e){r[e]=t}),this._runtime=new _.default(this._runtimeGUID,this._startMicros,this._options.component_name,r),this._info("Initializing reporting data",{component_name:this._options.component_name,access_token:this._auth.getAccessToken()}),this.emit("reporting_initialized")}else{if(!this._runtime)return this._error("Inconsistent state: auth initialized without runtime.");if(t.access_token)throw Error("Cannot change access_token after it has been set.");if(t.component_name)throw Error("Cannot change component_name after it has been set.");if(t.collector_host)throw Error("Cannot change collector_host after the connection is established");if(t.collector_port)throw Error("Cannot change collector_port after the connection is established");if(t.collector_path)throw Error("Cannot change collector_path after the connection is established");if(t.collector_encryption)throw Error("Cannot change collector_encryption after the connection is established")}}},{key:"getLogFieldKeyHardLimit",value:function(){return this._options.log_field_key_hard_limit}},{key:"getLogFieldValueHardLimit",value:function(){return this._options.log_field_value_hard_limit}},{key:"addPlatformPlugins",value:function(t){var e=this,r=this._platform.plugins(t);(0,l.default)(r,function(t){e.addPlugin(t)})}},{key:"addPlugin",value:function(t){var e=t.name();this._plugins[e]||(this._plugins[e]=t,t.addOptions(this))}},{key:"startPlugins",value:function(){var t=this;(0,l.default)(this._plugins,function(e,r){t._plugins[r].start(t)})}},{key:"addActiveRootSpan",value:function(t){this._activeRootSpanSet[t._guid]=t,this._setActiveRootSpanToYoungest()}},{key:"removeActiveRootSpan",value:function(t){delete this._activeRootSpanSet[t._guid],this._setActiveRootSpanToYoungest()}},{key:"_setActiveRootSpanToYoungest",value:function(){var t=this;this._activeRootSpan=null,(0,l.default)(this._activeRootSpanSet,function(e){(!t._activeRootSpan||e._beginMicros>t._activeRootSpan._beginMicros)&&(t._activeRootSpan=e)})}},{key:"_objectToUint8Array",value:function(t){var e=void 0;try{e=encodeURIComponent(JSON.stringify(t))}catch(t){return this._error("Could not binary encode carrier data."),null}for(var r=new ArrayBuffer(e.length),n=new Uint8Array(r),o=0;o=0&&i<=255))return this._error("Unexpected character code"),null;n[o]=i}return n}},{key:"_uint8ArrayToObject",value:function(t){if(!t)return this._error("Array is null"),null;for(var e="",r=0;r0||this._internalLogs.length>0)return!1;var t=!0;return(0,l.default)(this._counters,function(e){e>0&&(t=!1)}),t}},{key:"_addSpanRecord",value:function(t){this._internalAddSpanRecord(t),this.emit("span_added",t)}},{key:"_internalAddSpanRecord",value:function(t){if(t){if(this._spanRecords.length>=this._options.max_span_records){var e=Math.floor(this._spanRecords.length*Math.random());this._spanRecords[e]=t,this._counters["spans.dropped"]++}else this._spanRecords.push(t)}else this._error("Attempt to add null record to buffer")}},{key:"_restoreRecords",value:function(t,e,r){var n=this;(0,l.default)(t,function(t){n._internalAddSpanRecord(t)});var o=this._internalLogs;this._internalLogs=[];var i=e.concat(o);(0,l.default)(i,function(t){n._pushInternalLog(t)}),(0,l.default)(r,function(t,e){e in n._counters?n._counters[e]+=t:n._error("Bad counter name: "+e)})}},{key:"_clearSpanRecordsIfMaxErrors",value:function(){var t=this.options().clear_span_buffer_consecutive_errors;if(!(null===t||this._reportErrorStreak0||(t._info("Final flush before exit."),t._flushReport(!1,!0,function(e){e&&t._warn("Final report before exit failed",{error:e,unflushed_spans:t._spanRecords.length,buffer_youngest_micros:t._reportYoungestMicros})}))})}}},{key:"_startReportingLoop",value:function(){var t=this;if(this._options.disabled)this._info("Not starting reporting loop: instrumentation is disabled.");else if(this._options.disable_reporting_loop)this._info("Not starting reporting loop: reporting loop is disabled.");else if(null!==this._auth){if(this._reportingLoopActive)this._info("Reporting loop already started!");else{this._info("Starting reporting loop:",this._runtime),this._reportingLoopActive=!0;var e=0;this._platform.onBeforeExit(function(){e++>0||t._stopReportingLoop()});var r=function(){t._enqueueNextReport(function(e){t._reportingLoopActive&&r()})},n=Math.floor(Math.random()*this._options.delay_initial_report_millis);R.detachedTimeout(function(){r()},n)}}}},{key:"_stopReportingLoop",value:function(){this._debug("Stopping reporting loop"),this._reportingLoopActive=!1,clearTimeout(this._reportTimer),this._reportTimer=null}},{key:"_enqueueNextReport",value:function(t){var e=this;if(!this._reportTimer){var r=this._options.max_reporting_interval_millis;0===this._reportErrorStreak&&this._useClockState&&!this._clockState.isReady()&&(r=Math.min(O.CLOCK_STATE_REFRESH_INTERVAL_MS,r));var n=Math.floor(Math.max(0,(.5*Math.random()-.25+1)*((1+Math.min(7,Math.max(0,this._reportErrorStreak)))*r)));this._debug("Delaying next flush for "+n+"ms"),this._reportTimer=R.detachedTimeout(function(){e._reportTimer=null,e._flushReport(!1,!1,t)},n)}}},{key:"_flushReport",value:function(t,e,r){var n=this;r=r||function(t){};var o=this._clockState.isReady(),i=this._clockState.offsetMicros();this._debug("time correction state",{offset_micros:i,active_samples:this._clockState.activeSampleCount(),ready:o});var a=this._spanRecords,s=this._counters,u=this._internalLogs;if(!this._useClockState||t||o||e){if(this._buffersAreEmpty())return this._debug("Skipping empty report"),r(null);this._clearBuffers(),this._debug("Flushing report ("+a.length+" spans)")}else this._debug("Flushing empty report to prime clock state"),a=[],s={},u=[];this._transport.ensureConnection(this._options),console.assert(null!==this._runtimeGUID,"No runtime GUID for Tracer");var c=this._useClockState?i:0,l=this._platform.nowMicros(),p=new d.default(this._runtime,this._reportYoungestMicros,l,a,u,s,c);this.emit("prereport",p);var f,_=this._platform.nowMicros();this._options.meta_event_reporting&&!this._first_report_has_run&&(this._first_report_has_run=!0,this.startSpan(O.LS_META_TRACER_CREATE,{tags:(y(f={},O.LS_META_EVENT_KEY,!0),y(f,O.LS_META_TRACER_GUID_KEY,this._runtimeGUID),f)}).finish()),this._transport.report(e,this._auth,p,function(t,o){var i=n._platform.nowMicros(),a=(l-p.oldest_micros)/1e6;if(t){n._reportErrorStreak++;var s=void 0;s=t.message?""+t.message:""+t,n._warn("Error in report: "+s,{last_report_seconds_ago:a}),n._restoreRecords(p.getSpanRecords(),p.getInternalLogs(),p.getCounters()),n._counters["reports.errors.send"]++,n._clearSpanRecordsIfMaxErrors(),n.emit("report_error",t,{error:t,streak:n._reportErrorStreak,detached:e})}else n.verbosity()>=4&&n._debug("Report flushed for last "+a+" seconds",{spans_reported:p.getSpanRecords().length}),n._reportErrorStreak=0,n._reportYoungestMicros=l,o?(o.timing&&o.timing.receive_micros&&o.timing.transmit_micros?n._clockState.addSample(_,o.timing.receive_micros,o.timing.transmit_micros,i):o.receiveTimestamp&&o.transmitTimestamp?n._clockState.addSample(_,1e6*o.receiveTimestamp.seconds+o.receiveTimestamp.nanos/1e3,1e6*o.transmitTimestamp.seconds+o.transmitTimestamp.nanos/1e3,i):n._useClockState=!1,o.errors&&o.errors.length>0?n._warn("Errors in report",o.errors):o.errorsList&&o.errorsList.length>0&&n._warn("Errors in report",o.errorsList),o.commandsList&&o.commandsList.length>0&&o.commandsList[0].devMode&&!0!==n.options().disable_meta_event_reporting&&(n.options().meta_event_reporting=!0)):n._useClockState=!1,n.emit("report",p,o);return r(t)})}},{key:"stats",value:function(){return{counters:this._counters}}},{key:"_debug",value:function(t,e){4>this.verbosity()||this._options.logger("debug",t,e)}},{key:"_info",value:function(t,e){3>this.verbosity()||this._options.logger("info",t,e)}},{key:"_warn",value:function(t,e){this._counters["internal.warnings"]++,3>this.verbosity()||this._options.logger("warn",t,e)}},{key:"_error",value:function(t,e){this._counters["internal.errors"]++;var r=this.log().level(O.LOG_ERROR).message(t).payload(e).record();this._pushInternalLog(r);var n=this.verbosity();if(0!==n){var o=Date.now();if(1===n){if(o0){var i=this._skippedVisibleErrors+" errors masked since last logged error. Increase 'verbosity' option to see all errors.";this._options.logger("error",i,e)}}this._options.logger("error",t,e),this._lastVisibleErrorMillis=o,this._skippedVisibleErrors=0}}},{key:"_printToConsole",value:function(t,e,r){var n="log",o="[LightStep:INFO] "+e;"debug"===t?(n="log",o="[LightStep:DEBUG] "+e):"info"===t?(n="log",o="[LightStep:INFO] "+e):"warn"===t?(n="warn",o="[LightStep:WARN] "+e):"error"===t&&(n="error",o="[LightStep:ERROR] "+e),this._options.silent||(void 0!==r?console[n](o,r):console[n](o))}},{key:"_pushInternalLog",value:function(t){t&&(this._internalLogs.length>=20?(t.message="MAX_INTERNAL_LOGS limit hit. Last error: "+t.message,this._internalLogs[this._internalLogs.length-1]=t):this._internalLogs.push(t))}}]),e}();e.default=M,t.exports=e.default},function(t,e,r){"use strict";var n="function"!=typeof Object.create&&"~";function o(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function i(){}i.prototype._events=void 0,i.prototype.listeners=function(t,e){var r=this._events&&this._events[n?n+t:t];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=Array(i);o0&&this._endMicros>0?Math.floor((this._beginMicros+this._endMicros)/2):this._tracerImp._platform.nowMicros(),s.LIGHTSTEP_APP_URL_PREFIX+"/"+encodeURIComponent(this._tracerImp.options().access_token)+"/trace?span_guid="+encodeURIComponent(this.guid())+"&at_micros="+t}},{key:"getTags",value:function(){return this._tags}},{key:"end",value:function(t){if(!this._ended){var e;this._ended=!0,void 0!==t&&this.setEndMicros(Math.floor(1e3*t)),0===this._endMicros&&this.setEndMicros(this._tracerImp._platform.nowMicros()),p.default.shouldSendMetaSpan(this._tracer().options(),this.getTags())&&this._tracerImp.startSpan(s.LS_META_SP_FINISH,{tags:(d(e={},s.LS_META_EVENT_KEY,!0),d(e,s.LS_META_TRACE_KEY,this.traceGUID()),d(e,s.LS_META_SPAN_KEY,this.guid()),e)}).finish(),this._tracerImp._addSpanRecord(this)}}},{key:"_toThrift",value:function(){var t=this,e=[];(0,u.default)(this._tags,function(t,r){e.push(new c.crouton_thrift.KeyValue({Key:a.toString(r),Value:a.toString(t)}))});var r=[];return(0,u.default)(this._log_records,function(e){var n=e.toThrift();t._tracerImp._counters["logs.keys.over_limit"]+=e.getNumKeysOverLimit(),t._tracerImp._counters["logs.values.over_limit"]+=e.getNumValuesOverLimit(),r.push(n)}),new c.crouton_thrift.SpanRecord({span_guid:this.guid(),trace_guid:this.traceGUID(),runtime_guid:this._tracerImp.guid(),span_name:this._operationName,oldest_micros:this._beginMicros,youngest_micros:this._endMicros,attributes:e,error_flag:this._errorFlag,log_records:r})}}]),e}();e.default=h,t.exports=e.default},function(t,e,r){"use strict";var n=function(){function t(t,e){for(var r=0;r0?t[t.length-1]:null}();t.exports={parseScriptElementOptions:n.isBrowser()?function(t,e){if(o){var r=o.dataset,n=r.access_token;"string"==typeof n&&n.length>0&&(t.access_token=n);var i=r.component_name;"string"==typeof i&&i.length>0&&(t.component_name=i);var a=r.collector_host;"string"==typeof a&&a.length>0&&(t.collector_host=a);var s=r.collector_port;s&&(t.collector_port=parseInt(s,10));var u=r.collector_path;"string"==typeof u&&u.length>0&&(t.collector_path=u);var c=r.collector_encryption;c&&(t.collector_encryption=c);var l=r.enable;"string"==typeof l&&("true"===l?t.enable=!0:"false"===l&&(t.enable=!1));var p=r.verbosity;"string"==typeof p&&(t.verbosity=parseInt(p,10));var f=r.init_global_tracer;"string"==typeof f&&("true"===f?e.init_global_tracer=!0:"false"===f&&(e.init_global_tracer=!1)),"string"==typeof r.xhr_instrumentation&&"true"===r.xhr_instrumentation&&(t.xhr_instrumentation=!0),"string"==typeof r.instrument_page_load&&"true"===r.instrument_page_load&&(t.instrument_page_load=!0)}}:function(t,e){},parseURLQueryOptions:n.isBrowser()?function(t){var e=function(t){var e={},r=window.location.href.indexOf("?");if(r<0)return e;var n=window.location.href.slice(r+1);n.indexOf("#")>=0&&(n=n.slice(0,n.indexOf("#")));for(var o=n.replace(/\+/,"%20").split("&"),i=0;i0?e:null}());var d=void 0===i||i;d&&this.addEventListener("readystatechange",function(){if(0===this.readyState)p.log({readyState:0,event:"unsent"});else if(1===this.readyState)p.log({readyState:1,event:"sending"});else if(2===this.readyState)p.log({readyState:2,event:"headers received",method:r,url:o,openPayload:_,headers:u(this)}),p.addTags(f);else if(3===this.readyState)p.log({readyState:3,event:"loading"});else if(4===this.readyState){var t=this.responseType;p.log({readyState:4,url:o,method:r,headers:u(this),status:this.status,statusText:this.statusText,responseType:t}),e.removeActiveRootSpan(p),p.finish()}else p.log({readyState:this.readyState})});var h=s.open.apply(this,arguments);return d||(e.removeActiveRootSpan(p),p.finish()),h}}},{key:"_instrumentSend",value:function(){var t=this,e=this._tracer;return function(){var r=this;if(!t._shouldTrace(e,this,this.__tracer_url))return s.send.apply(this,arguments);var n=this.__tracer_span;if(!n)return s.send.apply(this,arguments);var o=Array.prototype.slice.call(arguments),i=void 0;if(1===o.length){o[0]&&o[0].length&&(i=o[0].length);try{o=JSON.parse(o[0])}catch(t){}}var u=void 0===i?"":", data length="+i;if(n.log({event:"send",data_length:u}),t._shouldAddHeadersToRequest(e,this.__tracer_url)){var c={};e.inject(n.context(),a.FORMAT_HTTP_HEADERS,c),Object.keys(c).forEach(function(t){s.setRequestHeader.call(r,t,c[t])})}return s.send.apply(this,arguments)}}},{key:"_shouldTrace",value:function(t,e,r){if(!t||!r)return!1;var n=t.options();return!n.disabled&&!this._internalExclusions.some(function(t){return t.test(r)})&&!n.xhr_url_exclusion_patterns.some(function(t){return t.test(r)})&&!!n.xhr_url_inclusion_patterns.some(function(t){return t.test(r)})}},{key:"_shouldAddHeadersToRequest",value:function(t,e){if(!t||!e)return!1;var r=t.options();return!r.disabled&&!r.xhr_url_header_exclusion_patterns.some(function(t){return t.test(e)})&&!!r.xhr_url_header_inclusion_patterns.some(function(t){return t.test(e)})}}]),t}();t.exports=new c},function(t,e,r){"use strict";var n=function(){function t(t,e){for(var r=0;r0?e:null}()),t._shouldAddHeadersToRequest(e,i.url)){var f={};e.inject(c.context(),a.FORMAT_HTTP_HEADERS,f),Object.keys(f).forEach(function(t){i.headers.get(t)||i.headers.set(t,f[t])})}return c.log({event:"sending",method:i.method,url:i.url,openPayload:p}),c.addTags(p),s(i).then(function(t){return t.ok||c.addTags({error:!0}),c.log({method:i.method,headers:function(t){for(var e={},r=t.headers.entries(),n=0;nthis._logFieldKeyHardLimit&&(this._keysOverLimit+=1,e=e.substr(0,this._logFieldKeyHardLimit)+"..."),e}},{key:"getFieldValue",value:function(t){var e=null;if(t instanceof Error)try{e=JSON.stringify(t,Object.getOwnPropertyNames(t))}catch(t){e="Could not encode value. Exception: "+t}else if(t instanceof Object)try{e=JSON.stringify(t,null," ")}catch(t){e="Could not encode value. Exception: "+t}else e=s.toString(t);return e.length>this._logFieldValueHardLimit&&(this._valuesOverLimit+=1,e=e.substr(0,this._logFieldValueHardLimit)+"..."),e}}]),t}();e.default=u,t.exports=e.default},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){for(var r=0;rthis._nowMicros()-36e8&&(this._samples=r.samples.slice(-8)),this.update()}return o(t,[{key:"addSample",value:function(t,e,r,n){var o=Number.MAX_VALUE,i=0;t>0&&e>0&&r>0&&n>0&&(o=n-t-(r-e),i=(e-t+(r-n))/2),8===this._samples.length&&this._samples.shift(),this._samples.push({delayMicros:o,offsetMicros:i}),this._currentOffsetAge++,this._localStoreSet({timestamp_micros:this._nowMicros(),samples:this._samples}),this.update()}},{key:"update",value:function(){var t=Number.MAX_VALUE,e=0;if((0,i.default)(this._samples,function(r){r.delayMicros7||Math.abs(this._currentOffsetMicros-e)<3*r)&&(this._currentOffsetMicros=e,this._currentOffsetAge=0)}}},{key:"offsetMicros",value:function(){return Math.floor(this._currentOffsetMicros)}},{key:"isReady",value:function(){return this._samples.length>3}},{key:"activeSampleCount",value:function(){return this._samples.length}}]),t}();t.exports=a},function(t,e,r){"use strict";var n=function(){function t(t,e){for(var r=0;r=i.LOG_ERROR&&this.error(!0),this}},{key:"span",value:function(t){return void 0!==t&&(this._record.span_guid=a.toString(t)),this}},{key:"name",value:function(t){return this._record.stable_name=a.toString(t),this}},{key:"error",value:function(t){return this._record.error_flag=a.toBoolean(t),this}},{key:"payload",value:function(t){return void 0!==t&&(this._record.payload_json=this._encodePayload(t)),this}},{key:"_encodePayload",value:function(t){var e=null;try{e=JSON.stringify(t)}catch(t){return}return e}}]),t}();t.exports=s},function(t,e,r){"use strict";var n,o=function(){function t(t,e){for(var r=0;r=8.0.0"},scripts:{test:"rm -f test/results/*.json && node node_modules/mocha/bin/mocha -c test/unittest_node.js",version:"make build && git add -A dist"},license:"MIT",repository:{type:"git",url:"http://github.com/lightstep/lightstep-tracer-javascript.git"},dependencies:{async:"1.5.0",eventemitter3:"1.1.1",hex2dec:"1.0.1",opentracing:"^0.14.4","source-map-support":"0.3.3",thrift:"0.13.0"},devDependencies:{"babel-cli":"6.14.0","babel-core":"^6.26.3","babel-loader":"7","babel-plugin-add-module-exports":"^1.0.0","babel-plugin-check-es2015-constants":"6.7.2","babel-plugin-syntax-object-rest-spread":"^6.13.0","babel-plugin-transform-es2015-arrow-functions":"6.5.2","babel-plugin-transform-es2015-block-scoped-functions":"6.6.5","babel-plugin-transform-es2015-block-scoping":"^6.26.0","babel-plugin-transform-es2015-classes":"6.6.5","babel-plugin-transform-es2015-computed-properties":"6.6.5","babel-plugin-transform-es2015-destructuring":"6.6.5","babel-plugin-transform-es2015-duplicate-keys":"6.6.4","babel-plugin-transform-es2015-literals":"6.5.0","babel-plugin-transform-es2015-modules-commonjs":"6.7.4","babel-plugin-transform-es2015-object-super":"6.6.5","babel-plugin-transform-es2015-parameters":"6.7.0","babel-plugin-transform-es2015-spread":"^6.6.5","babel-plugin-transform-es2015-sticky-regex":"6.5.0","babel-plugin-transform-es2015-template-literals":"6.6.5","babel-plugin-transform-es2015-unicode-regex":"6.5.0","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-polyfill":"6.3.14","babel-preset-es2015":"6.3.13",chai:"3.4.1",clone:"1.0.2",colors:"1.1.2",eslint:"^6.8.0","eslint-config-airbnb":"^18.0.1","eslint-plugin-import":"^2.20.0","eslint-plugin-jsx-a11y":"^6.2.3","eslint-plugin-react":"^7.18.0",express:"^4.16.3","fetch-mock":"^9.2.1",istanbul:"^0.4.5",mocha:"^5.2.0",shelljs:"0.5.3",sinon:"^9.0.1","sprintf-js":"1.0.3",underscore:"1.8.3","watch-trigger":"0.0.5",webpack:"^4.25.1","webpack-cli":"^3.1.2"}}},function(t,e,r){"use strict";var n=function(){function t(t,e){for(var r=0;rt.length)&&(e=t.length);for(var r=0,n=Array(e);r2&&void 0!==arguments[2]?arguments[2]:window;if("string"==typeof t)r[t]=e;else{var n=function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return o(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);if("Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(t,e)}}(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),i=n.pop(),a=r,s=!0,u=!1,c=void 0;try{for(var l,p=n[Symbol.iterator]();!(s=(l=p.next()).done);s=!0){var f,_,d=l.value;null!==(_=(f=a)[d])&&void 0!==_||(f[d]={}),a=a[d]}}catch(t){u=!0,c=t}finally{try{s||null==p.return||p.return()}finally{if(u)throw c}}a[i]=e}},a={environments:{dev:"Development",prod:"Production"},metaData:function(){var t,e,r=document.querySelector('meta[name="roblox-tracer-meta-data"]');if(null==r)return{accessToken:null,serviceName:"Web",tracerEnabled:!1,apiSitesRequestAllowList:"",sampleRate:0,isInstrumentPagePerformanceEnabled:!1};var n=null!=r.dataset.sampleRate?parseInt(r.dataset.sampleRate,10):0;return{accessToken:r.dataset.accessToken,serviceName:null!==(t=r.dataset.serviceName)&&void 0!==t?t:"Web",tracerEnabled:"true"===r.dataset.tracerEnabled,apiSitesRequestAllowList:null!==(e=r.dataset.apiSitesRequestAllowList)&&void 0!==e?e:"",sampleRate:Number.isNaN(n)?0:n,isInstrumentPagePerformanceEnabled:"true"===r.dataset.isInstrumentPagePerformanceEnabled}}(),pageName:null!==(e=null===(t=document.querySelector('meta[name="page-meta"]'))||void 0===t?void 0:t.dataset.internalPageName)&&void 0!==e?e:null,hostnames:{prod:"roblox.com",dev:"robloxlabs.com"}},s=window.Roblox["core-scripts"].meta.environment,u=r(801),c=r.n(u),l=r(311),p=r.n(l),f=(0,s.isTestSite)()?a.environments.dev:a.environments.prod,_={initTracer:function(t,e){if(!a.metaData.accessToken)return null;var r,n,o,i=new l.Tracer({access_token:a.metaData.accessToken,component_name:t,tags:{"service.version":f},instrument_page_load:e,propagators:(r={},n=c().FORMAT_HTTP_HEADERS,o=new(p()).B3Propagator,n in r?Object.defineProperty(r,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[n]=o,r)});return c().initGlobalTracer(i),i},createAndGetSpan:function(t,e){return c().globalTracer().startSpan(t,e)},finalizeSpan:function(t){t&&t.finish()}},d=a.metaData,h=d.sampleRate,g=d.serviceName,v=d.tracerEnabled,y=d.isInstrumentPagePerformanceEnabled,m=Math.floor(100*Math.random()+1),b=v&&m<=h,T={isTracerEnabled:b,rootTracer:function(){return b?_.initTracer(g,y):null}},O=function(t,e){t.log({message:e})},S={setXHRRequestLogs:function(t){O(t,"request_sent")},setXHRResponseSuccessLogs:function(t){O(t,"request_ok")},setXHRResponseErrorLogs:function(t){t.log({message:"request_failed"})}},E=function(t){t.setTag("error","true")},R=function(t,e){var r=e.component,n=e.method,o=e.url;t.setTag("span.kind","client"),t.setTag("component",r),t.setTag("http.method",n),t.setTag("http.url",o),t.setTag("page.name",a.pageName),t.setTag("page.url",window.location.href),t.setTag("user.agent",navigator.userAgent)},k={setErrorTag:E,setXHRRequestTags:function(t,e){R(t,e)},setXHRResponseTags:function(t,e){t.setTag("http.status_code",e.status)},setXHRResponseErrorTags:function(t,e){E(t),t.setTag("http.status_code",e.status)},setPlaceIdTag:function(t,e){t.setTag("guid:place_id",e)},setDefaultTags:function(t){t.setTag("span.kind","client")}},M={httpRequestCarrier:function(t){var e={};return c().globalTracer().inject(t,c().FORMAT_HTTP_HEADERS,e),e},textMapCarrier:function(t){var e={};return c().globalTracer().inject(t,c().FORMAT_TEXT_MAP,e),e}},w={httpRequestCarrier:function(t){return c().globalTracer().extract(c().FORMAT_HTTP_HEADERS,t)},textMapCarrier:function(t){return c().globalTracer().extract(c().FORMAT_TEXT_MAP,t)}},x=function(t){var e=a.hostnames,r=null!=t?t:window.location.hostname;return r.includes(e.prod)||r.includes(e.dev)},P=a.metaData.apiSitesRequestAllowList.split(","),A={isApiSiteAvailableForTracing:function(t){return!!(x()&&x(t))&&!!P.length&&P.some(function(e){return t.includes(e)})}},I={operationNames:{httpRequest:"Web::HTTPRequest"}},L=T.isTracerEnabled;i(["Roblox","core-scripts","tracing"],n),i("RobloxTracer",{isTracerEnabled:L,instrumentation:_,logs:S,tags:k,inject:M,extract:w,apiSiteRequestValidator:A,tracerConstants:I}),T.rootTracer()}()}(); //# sourceMappingURL=https://sourcemaps.rbxcdn.com/robloxTracer-a2536b353e9a18eb.js.map window.Roblox && window.Roblox.BundleDetector && window.Roblox.BundleDetector.bundleDetected("RobloxTracer");