diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..34c19f7
Binary files /dev/null and b/.DS_Store differ
diff --git a/examples/tracing-test/.gitignore b/examples/tracing-test/.gitignore
new file mode 100644
index 0000000..823f5f7
--- /dev/null
+++ b/examples/tracing-test/.gitignore
@@ -0,0 +1,48 @@
+# ------------------------------------------------------------------------------ #
+# Java defaults (https://github.com/github/gitignore/blob/master/Java.gitignore) #
+# ------------------------------------------------------------------------------ #
+*.class
+
+# Package Files #
+*.jar
+*.war
+*.ear
+
+# ------------------------------------------------------------------------------------------- #
+# Eclipse-specific (https://github.com/github/gitignore/blob/master/Global/Eclipse.gitignore) #
+# ------------------------------------------------------------------------------------------- #
+*.pydevproject
+.metadata
+bin/**
+tmp/**
+tmp/**/*
+*.tmp
+*.bak
+*.swp
+*~.nib
+local.properties
+.settings/
+.loadpath
+.project
+.classpath
+
+# External tool builders
+.externalToolBuilders/
+
+# Locally stored "Eclipse launch configurations"
+*.launch
+
+# CDT-specific
+.cproject
+
+# PDT-specific
+.buildpath
+
+# --------------- #
+# Studio-specific #
+# --------------- #
+target/
+.mule/**
+.mule/**/*
+.DS_Store
+velocity.log
\ No newline at end of file
diff --git a/examples/tracing-test/README.md b/examples/tracing-test/README.md
new file mode 100644
index 0000000..9e3dc30
--- /dev/null
+++ b/examples/tracing-test/README.md
@@ -0,0 +1,13 @@
+# Tracing test
+
+## Intro
+This Mule project runs as a Mule engine instrumented with the Mule APM agent and it serves a HTML page with Elastic RUM agent that both participate in a distributed trace. The RUM agent in the browser starts a transaction and sends a `traceparent` header containing the `trace.id` back to the Mule runtime that records its own transaction using the sent `trace.id` which results in a complete trace populated in Kibana APM UI:
+![kibana-apm](images/kibana.png)
+
+## How to run
+Start the Mule project with the following additional parameters to initialise the APM agent:
+```
+-M-Delastic.apm.server_urls=https://XXXXX.elastic-cloud.com -M-Delastic.apm.secret_token=YYYYYY -M-Delastic.apm.service_name=component1 -M-Delastic.apm.service_version=v1.0.0 -M-Delastic.apm.log_level=INFO
+```
+
+Open the browser at http://localhost:8081 and press the `Press me` button a couple of times.
diff --git a/examples/tracing-test/images/kibana.png b/examples/tracing-test/images/kibana.png
new file mode 100644
index 0000000..67337da
Binary files /dev/null and b/examples/tracing-test/images/kibana.png differ
diff --git a/examples/tracing-test/mule-artifact.json b/examples/tracing-test/mule-artifact.json
new file mode 100644
index 0000000..8a6b9da
--- /dev/null
+++ b/examples/tracing-test/mule-artifact.json
@@ -0,0 +1,3 @@
+{
+ "minMuleVersion": "4.3.0"
+}
\ No newline at end of file
diff --git a/examples/tracing-test/pom.xml b/examples/tracing-test/pom.xml
new file mode 100644
index 0000000..c2c609a
--- /dev/null
+++ b/examples/tracing-test/pom.xml
@@ -0,0 +1,92 @@
+
+
+ 4.0.0
+
+ com.mycompany
+ tracing-test
+ 1.0.0-SNAPSHOT
+ mule-application
+
+ tracing-test
+
+
+ UTF-8
+ UTF-8
+
+ 4.3.0-20201013
+ 3.3.5
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-clean-plugin
+ 3.0.0
+
+
+ org.mule.tools.maven
+ mule-maven-plugin
+ ${mule.maven.plugin.version}
+ true
+
+
+
+
+
+
+
+
+ org.mule.connectors
+ mule-http-connector
+ 1.5.22
+ mule-plugin
+
+
+ org.mule.connectors
+ mule-sockets-connector
+ 1.2.0
+ mule-plugin
+
+
+ org.mule.modules
+ mule-scripting-module
+ 1.1.7
+ mule-plugin
+
+
+ co.elastic.apm
+ mule4-agent
+ 0.4.0
+
+
+
+
+
+ anypoint-exchange-v2
+ Anypoint Exchange
+ https://maven.anypoint.mulesoft.com/api/v2/maven
+ default
+
+
+ mulesoft-releases
+ MuleSoft Releases Repository
+ https://repository.mulesoft.org/releases/
+ default
+
+
+
+
+ mulesoft-releases
+ mulesoft release repository
+ default
+ https://repository.mulesoft.org/releases/
+
+ false
+
+
+
+
+
diff --git a/examples/tracing-test/src/main/mule/tracing-test.xml b/examples/tracing-test/src/main/mule/tracing-test.xml
new file mode 100644
index 0000000..7bf286c
--- /dev/null
+++ b/examples/tracing-test/src/main/mule/tracing-test.xml
@@ -0,0 +1,93 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ A simple HTML document
+
+
+
+ Press me!
+
+
+
+
+
+
+'''
+]]>
+
+
+
+
+
+
+
+
+
diff --git a/examples/tracing-test/src/main/resources/elastic-apm-rum.umd.min.js b/examples/tracing-test/src/main/resources/elastic-apm-rum.umd.min.js
new file mode 100644
index 0000000..25fb89d
--- /dev/null
+++ b/examples/tracing-test/src/main/resources/elastic-apm-rum.umd.min.js
@@ -0,0 +1,2 @@
+!function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=4)}([function(t,e,n){var r,i,a;!function(o,s){"use strict";i=[n(3)],void 0===(a="function"==typeof(r=function(t){var e=/(^|@)\S+\:\d+/,n=/^\s*at .*(\S+\:\d+|\(native\))/m,r=/^(eval@)?(\[native code\])?$/;function i(t,e,n){if("function"==typeof Array.prototype.map)return t.map(e,n);for(var r=new Array(t.length),i=0;i-1&&(e=e.replace(/eval code/g,"eval").replace(/(\(eval at [^\()]*)|(\)\,.*$)/g,""));var n=e.replace(/^\s+/,"").replace(/\(eval code/g,"(").split(/\s+/).slice(1),r=this.extractLocation(n.pop()),i=n.join(" ")||void 0,a=function(t,e){if("function"==typeof Array.prototype.indexOf)return t.indexOf(e);for(var n=0;n"],r[0])>-1?void 0:r[0];return new t(i,void 0,a,r[1],r[2],e)}),this)},parseFFOrSafari:function(e){return i(a(e.stack.split("\n"),(function(t){return!t.match(r)}),this),(function(e){if(e.indexOf(" > eval")>-1&&(e=e.replace(/ line (\d+)(?: > eval line \d+)* > eval\:\d+\:\d+/g,":$1")),-1===e.indexOf("@")&&-1===e.indexOf(":"))return new t(e);var n=e.split("@"),r=this.extractLocation(n.pop()),i=n.join("@")||void 0;return new t(i,void 0,r[0],r[1],r[2],e)}),this)},parseOpera:function(t){return!t.stacktrace||t.message.indexOf("\n")>-1&&t.message.split("\n").length>t.stacktrace.split("\n").length?this.parseOpera9(t):t.stack?this.parseOpera11(t):this.parseOpera10(t)},parseOpera9:function(e){for(var n=/Line (\d+).*script (?:in )?(\S+)/i,r=e.message.split("\n"),i=[],a=2,o=r.length;a/,"$2").replace(/\([^\)]*\)/g,"")||void 0;a.match(/\(([^\)]*)\)/)&&(n=a.replace(/^[^\(]+\(([^\)]*)\)$/,"$1"));var s=void 0===n||"[arguments not available]"===n?void 0:n.split(",");return new t(o,s,i[0],i[1],i[2],e)}),this)}}})?r.apply(e,i):r)||(t.exports=a)}()},,,function(t,e,n){var r,i,a;!function(n,o){"use strict";i=[],void 0===(a="function"==typeof(r=function(){function t(t){return!isNaN(parseFloat(t))&&isFinite(t)}function e(t,e,n,r,i,a){void 0!==t&&this.setFunctionName(t),void 0!==e&&this.setArgs(e),void 0!==n&&this.setFileName(n),void 0!==r&&this.setLineNumber(r),void 0!==i&&this.setColumnNumber(i),void 0!==a&&this.setSource(a)}return e.prototype={getFunctionName:function(){return this.functionName},setFunctionName:function(t){this.functionName=String(t)},getArgs:function(){return this.args},setArgs:function(t){if("[object Array]"!==Object.prototype.toString.call(t))throw new TypeError("Args must be an Array");this.args=t},getFileName:function(){return this.fileName},setFileName:function(t){this.fileName=String(t)},getLineNumber:function(){return this.lineNumber},setLineNumber:function(e){if(!t(e))throw new TypeError("Line Number must be a Number");this.lineNumber=Number(e)},getColumnNumber:function(){return this.columnNumber},setColumnNumber:function(e){if(!t(e))throw new TypeError("Column Number must be a Number");this.columnNumber=Number(e)},getSource:function(){return this.source},setSource:function(t){this.source=String(t)},toString:function(){return(this.getFunctionName()||"{anonymous}")+("("+(this.getArgs()||[]).join(",")+")")+(this.getFileName()?"@"+this.getFileName():"")+(t(this.getLineNumber())?":"+this.getLineNumber():"")+(t(this.getColumnNumber())?":"+this.getColumnNumber():"")}},e})?r.apply(e,i):r)||(t.exports=a)}()},function(t,e,n){"use strict";n.r(e),n.d(e,"init",(function(){return Ve})),n.d(e,"apmBase",(function(){return $e})),n.d(e,"ApmBase",(function(){return Ue})),n.d(e,"apm",(function(){return $e}));var r=function(t){var e=this.constructor;return this.then((function(n){return e.resolve(t()).then((function(){return n}))}),(function(n){return e.resolve(t()).then((function(){return e.reject(n)}))}))},i=setTimeout;function a(t){return Boolean(t&&void 0!==t.length)}function o(){}function s(t){if(!(this instanceof s))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],l(t,this)}function c(t,e){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,s._immediateFn((function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null!==n){var r;try{r=n(t._value)}catch(t){return void f(e.promise,t)}u(e.promise,r)}else(1===t._state?u:f)(e.promise,t._value)}))):t._deferreds.push(e)}function u(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof s)return t._state=3,t._value=e,void d(t);if("function"==typeof n)return void l((r=n,i=e,function(){r.apply(i,arguments)}),t)}t._state=1,t._value=e,d(t)}catch(e){f(t,e)}var r,i}function f(t,e){t._state=2,t._value=e,d(t)}function d(t){2===t._state&&0===t._deferreds.length&&s._immediateFn((function(){t._handled||s._unhandledRejectionFn(t._value)}));for(var e=0,n=t._deferreds.length;e0)return r}}()}}function N(t){return I(t,m.call(arguments,1),!1)}function j(t){return I(t,m.call(arguments,1),!0)}function F(t){return void 0===t}function R(){}function A(t){return t.replace(/[.*"]/g,"_")}function P(){return _.now()}function M(t){return"number"==typeof t&&t>=0?t:P()}function q(t,e){return F(e)||F(t)?null:parseInt(e-t)}function H(t){g.resolve().then(t)}function D(){return"function"==typeof _.getEntriesByType}var z={fetchInProgress:!1};function B(t){return"__apm_symbol__"+t}function U(t,e,n){for(var r=t;r&&!r.hasOwnProperty(e);)r=Object.getPrototypeOf(r);!r&&t[e]&&(r=t);var i,a,o,s,c=B(e);if(r&&!(i=r[c])){i=r[c]=r[e];var u=r&&Object.getOwnPropertyDescriptor(r,e);if(!(s=u)||!1!==s.writable&&("function"!=typeof s.get||void 0!==s.set)){var f=n(i,c,e);r[e]=function(){return f(this,arguments)},a=r[e],o=i,a[B("OriginalDelegate")]=o}}return i}var $=B("xhrIgnore"),V=B("xhrSync"),X=B("xhrURL"),J=B("xhrMethod"),Z="schedule",G="invoke",K="clear",Q="addEventListener",W="removeEventListener",Y=["link","css","script","img","xmlhttprequest","fetch","beacon","iframe"],tt=3e5,et="page-load",nt="custom",rt="Unknown",it=[et,"route-change","user-interaction","http-request",nt,"temporary"],at=60,ot="xmlhttprequest",st="fetch",ct="history",ut="eventtarget",ft="error",dt="longtask",pt="measure",lt="navigation",vt="resource",ht="first-contentful-paint",gt="largest-contentful-paint",mt="first-input",yt="ConfigService",_t="LoggingService",bt="ApmServer",St=".truncated",wt=1024,Tt=B("xhrTask"),Et=B("xhrListener"),xt=B("xhrScheduled");function kt(t){var e=XMLHttpRequest.prototype,n=e[Q],r=e[W];if(!n){var i=window.XMLHttpRequestEventTarget;if(i){var a=i.prototype;n=a[Q],r=a[W]}}var o="readystatechange",s="load";function c(e){e.state=G,t(G,e)}function u(e){XMLHttpRequest[xt]=!1,e.state=Z,t(Z,e);var i=e.data,a=i.aborted,u=i.target;n||(n=u[Q],r=u[W]);var f,d=u[Et];d&&(r.call(u,o,d),r.call(u,s,d));var p=u[Et]=function(t){var n=t.type;f?f!=n&&function(t){setTimeout(t,0)}((function(){e.state!==G&&c(e)})):u.readyState===u.DONE&&!a&&XMLHttpRequest[xt]&&e.state===Z&&(f=n)};n.call(u,o,p),n.call(u,s,p),u[Tt]||(u[Tt]=e)}var f=U(e,"open",(function(){return function(t,e){return t[$]||(t[J]=e[0],t[X]=e[1],t[V]=!1===e[2]),f.apply(t,e)}})),d=U(e,"send",(function(){return function(t,e){if(t[$])return d.apply(t,e);var n={source:ot,state:"",type:"macroTask",data:{target:t,method:t[J],sync:t[V],url:t[X],aborted:!1}};u(n);var r=d.apply(t,e);return XMLHttpRequest[xt]=!0,t[V]&&c(n),r}})),p=U(e,"abort",(function(){return function(e,n){if(!e[$]){var r=e[Tt];if(r&&"string"==typeof r.type){if(r.data&&r.data.aborted)return;!function(e){e.state=K,t(K,e),e.data.aborted=!0}(r)}}return p.apply(e,n)}}))}for(var Lt=["click"],Ot={},It=0;It=0&&"function"==typeof n}var jt=function(){function t(){this.observers={}}var e=t.prototype;return e.observe=function(t,e){var n=this;if("function"==typeof e)return this.observers[t]||(this.observers[t]=[]),this.observers[t].push(e),function(){var r=n.observers[t].indexOf(e);r>-1&&n.observers[t].splice(r,1)}},e.sendOnly=function(t,e){var n=this.observers[t];n&&n.forEach((function(t){try{t.apply(void 0,e)}catch(t){console.log(t,t.stack)}}))},e.send=function(t,e){this.sendOnly(t+":before",e),this.sendOnly(t,e),this.sendOnly(t+":after",e)},t}(),Ft=new jt,Rt=!1;function At(){return Rt||(Rt=!0,kt((function(t,e){Ft.send(ot,[t,e])})),function(t){if(window.fetch&&window.Request){var e=window.fetch;window.fetch=function(t,i){var a,o,s=this,c=arguments;if("string"==typeof t)a=new Request(t,i),o=t;else{if(!t)return e.apply(s,c);o=(a=t).url}var u={source:st,state:"",type:"macroTask",data:{target:a,method:a.method,url:o,aborted:!1}};return new g((function(t,i){var o;z.fetchInProgress=!0,n(u);try{o=e.apply(s,[a])}catch(t){return i(t),u.data.error=t,r(u),void(z.fetchInProgress=!1)}o.then((function(e){t(e),H((function(){u.data.response=e,r(u)}))}),(function(t){i(t),H((function(){u.data.error=t,r(u)}))})),z.fetchInProgress=!1}))}}function n(e){e.state=Z,t(Z,e)}function r(e){e.state=G,t(G,e)}}((function(t,e){Ft.send(st,[t,e])})),function(t){if(window.history){var e=history.pushState;"function"==typeof e&&(history.pushState=function(n,r,i){var a={source:ct,data:{state:n,title:r,url:i}};t(G,a),e.apply(this,arguments)})}}((function(t,e){Ft.send(ct,[t,e])})),function(t){if(window.EventTarget){var e=window.EventTarget.prototype,n=e[Q],r=e[W];e[Q]=function(t,e,r){var i=this;if(!Nt(i,t,e))return n.apply(i,arguments);var a=o(i,t,e,r),s=Array.prototype.slice.call(arguments);return s[1]=a,n.apply(i,s)},e[W]=function(t,e,n){var i=this;if(!Nt(i,t,e))return r.apply(i,arguments);var a=s(i,t,e,n),o=Array.prototype.slice.call(arguments);return o[1]=a,r.apply(i,o)}}function i(t,e,n,r){for(var i=0;i=0||(i[n]=t[n]);return i}(n,["tags"])),i=Xt(),a={};if(t.type===et&&D()){var o=_.getEntriesByType(lt);o&&o.length>0&&(a={response:$t(o[0])})}t.addContext(i,a,r)}var Gt=function(t){var e,n;function r(e,n,r){var i;if((i=t.call(this,e,n,r)||this).parentId=i.options.parentId,i.subtype=void 0,i.action=void 0,-1!==i.type.indexOf(".")){var a=i.type.split(".",3);i.type=a[0],i.subtype=a[1],i.action=a[2]}return i.sync=i.options.sync,i}return n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n,r.prototype.end=function(e,n){t.prototype.end.call(this,e),Jt(this,n)},r}(Pt),Kt={fcp:0,tbt:{start:1/0,duration:0}},Qt=50;function Wt(t,e){var n=e.capturePaint,r=t.getEntriesByType(dt),i={spans:function(t){for(var e=[],n=0;n0){var f=s[0],d=f.name,p=f.containerType,l=f.containerName,v=f.containerId,h={attribution:d,type:p};l&&(h.name=l),v&&(h.id=v),u.addContext({custom:h})}u.end(c),e.push(u)}return e}(r),marks:{}};if(!n)return i;var a=t.getEntriesByType(gt),o=a[a.length-1];if(o){var s=parseInt(o.startTime);Kt.lcp=s,i.marks.largestContentfulPaint=s}var c=_.timing,u=c.fetchStart-c.navigationStart,f=t.getEntriesByName(ht)[0];if(f){var d=parseInt(u>=0?f.startTime-u:f.startTime);Kt.fcp=d,i.marks.firstContentfulPaint=d}var p=function(t){var e=t[0];if(e&&!Kt.wasHidden){var n=e.startTime,r=e.processingStart,i=new Gt("First Input Delay",mt,{startTime:n});return i.end(r),i}}(t.getEntriesByType(mt));return p&&i.spans.push(p),function(t){t.forEach((function(t){var e=t.name,n=t.startTime,r=t.duration;if(!(n0&&(Kt.tbt.duration+=i)}}))}(r),i}var Yt=function(){function t(t){this.po={observe:R,disconnect:R},window.PerformanceObserver&&(this.po=new PerformanceObserver(t))}var e=t.prototype;return e.start=function(t){try{var e=!0;t===dt&&(e=!1),this.po.observe({type:t,buffered:e})}catch(t){}},e.stop=function(){this.po.disconnect()},t}();var te=!1;function ee(){return x()?(At(),Kt.wasHidden="hidden"===document.visibilityState,window.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&(Kt.wasHidden=!0)}),{capture:!0,once:!0}),te=!0):y&&console.log("[Elastic APM] platform is not supported!"),te}var ne=n(0),re=n.n(ne);function ie(t){var e=t.error,n=t.filename,r=t.lineno,i=t.colno,a=[];if(e)try{a=re.a.parse(e)}catch(t){}return 0===a.length&&(a=[{fileName:n,lineNumber:r,columnNumber:i}]),a.map((function(t){return t.functionName&&(t.functionName=(e=t.functionName,n=e.split("/"),e=(e=(e=n.length>1?["Object",n[n.length-1]].join("."):n[0]).replace(/.<$/gi,".")).replace(/^Anonymous function$/,""),e=(n=e.split(".")).length>1?n[n.length-1]:n[0])),t;var e,n})).map((function(t){var e=t.fileName,n=t.lineNumber,r=t.columnNumber,i=t.functionName,a=void 0===i?"":i;if(!e&&!n)return{};if(!r&&!n)return{};var o,s,c=function(t){return void 0===t&&(t=""),""===t&&(t=""),t}(e),u=(o=c,s=window.location.origin||window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:""),o.indexOf(s)>-1&&(o=o.replace(s+"/","")),o);return function(t){return!!t&&0===window.location.href.indexOf(t)}(c)&&(u="(inline script)"),{abs_path:e,filename:u,function:a,lineno:n,colno:r}}))}var ae={service:{name:[wt,!0],version:!0,agent:{version:[wt,!0]},environment:!0},labels:{"*":!0}},oe={"*":!0,headers:{"*":!0}},se={user:{id:!0,email:!0,username:!0},tags:{"*":!0},http:{response:oe},destination:{address:[wt],service:{"*":[wt,!0]}},response:oe},ce={name:[wt,!0],type:[wt,!0],id:[wt,!0],trace_id:[wt,!0],parent_id:[wt,!0],transaction_id:[wt,!0],subtype:!0,action:!0,context:se},ue={name:!0,parent_id:!0,type:[wt,!0],id:[wt,!0],trace_id:[wt,!0],span_count:{started:[wt,!0]},context:se},fe={id:[wt,!0],trace_id:!0,transaction_id:!0,parent_id:!0,culprit:!0,exception:{type:!0},transaction:{type:!0},context:se};function de(t){return null==t||""===t||void 0===t}function pe(t,e,n){var r=function(t,e,n,r){return void 0===e&&(e=wt),void 0===n&&(n=!1),void 0===r&&(r="N/A"),n&&de(t)&&(t=r),"string"==typeof t?t.substring(0,e):t}(t[e],n[0],n[1]);de(r)?delete t[e]:t[e]=r}function le(t,e,n){void 0===t&&(t={}),void 0===n&&(n=e);for(var r=Object.keys(t),i=[],a=function(a){var o=r[a],s=!0===t[o]?i:t[o];Array.isArray(s)?"*"===o?Object.keys(n).forEach((function(t){return pe(n,t,s)})):pe(n,o,s):le(s,e,n[o])},o=0;o=0)){var i=t[r];if(null!=i&&"function"!=typeof i){if("object"==typeof i){if("function"!=typeof i.toISOString)return;i=i.toISOString()}n[r]=i,e=!0}}})),e)return n}(a);u&&(c.custom=u)}s||o&&o.indexOf(":")>-1&&(s=o.split(":")[0]);var f=this._transactionService.getCurrentTransaction(),d=f?f.context:{},p=this._configService.get("context"),l=(p.tags,function(t,e){if(null==t)return{};var n,r,i={},a=Object.keys(t);for(r=0;r=0||(i[n]=t[n]);return i}(p,["tags"])),v=j({},Xt(),d,l,c),h={id:T(),culprit:n,exception:{message:o,stacktrace:e,type:s},context:v};return f&&(h=N(h,{trace_id:f.traceId,parent_id:f.id,transaction_id:f.id,transaction:{type:f.type,sampled:f.sampled}})),le(fe,h)},e.logErrorEvent=function(t){if(void 0!==t){var e=this.createErrorDataModel(t);void 0!==e.exception.message&&this._apmServer.addError(e)}},e.registerListeners=function(){var t=this;window.addEventListener("error",(function(e){return t.logErrorEvent(e)})),window.addEventListener("unhandledrejection",(function(e){return t.logPromiseEvent(e)}))},e.logPromiseEvent=function(t){var e="Unhandled promise rejection: ",n=t.reason;null==n?this.logError(e+""):"string"==typeof n.message?this.logError({message:e+n.message,stack:n.stack?n.stack:null}):"object"!=typeof n&&this.logError(e+n)},e.logError=function(t){var e={};return"string"==typeof t?e.message=t:e.error=t,this.logErrorEvent(e)},t}(),ge=function(){function t(t,e){void 0===e&&(e={}),this.onFlush=t,this.items=[],this.queueLimit=e.queueLimit||-1,this.flushInterval=e.flushInterval||0,this.timeoutId=void 0}var e=t.prototype;return e._setTimer=function(){var t=this;this.timeoutId=setTimeout((function(){return t.flush()}),this.flushInterval)},e._clear=function(){void 0!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=void 0),this.items=[]},e.flush=function(){this.onFlush(this.items),this._clear()},e.add=function(t){this.items.push(t),-1!==this.queueLimit&&this.items.length>=this.queueLimit?this.flush():void 0===this.timeoutId&&this._setTimer()},t}();var me=function(){function t(){}return t.stringify=function(t){return JSON.stringify(t)+"\n"},t}(),ye=[["domainLookupStart","domainLookupEnd","Domain lookup"],["connectStart","connectEnd","Making a connection to the server"],["requestStart","responseEnd","Requesting and receiving the document"],["domLoading","domInteractive","Parsing the document, executing sync. scripts"],["domContentLoadedEventStart","domContentLoadedEventEnd",'Fire "DOMContentLoaded" event'],["loadEventStart","loadEventEnd",'Fire "load" event']];function _e(t,e,n,r,i){return void 0===i&&(i=0),"number"==typeof t&&"number"==typeof e&&t>=i&&e>t&&t-i>=n&&e-i<=r&&e-t=e&&(r[n]=parseInt(i-e))})),r}(t);return null==e?null:{navigationTiming:e,agent:{timeToFirstByte:e.responseStart,domInteractive:e.domInteractive,domComplete:e.domComplete}}}function Ee(t){if(t.captureTimings){var e=t._end;if(t.type===et){if(t.marks&&t.marks.custom){var n=t.marks.custom;Object.keys(n).forEach((function(e){n[e]+=t._start}))}t._start=0;var r=_.timing;(function(t,e,n,r){for(var i=[],a=0;a-1&&l===c.length-e[p].length){d=!0;break}}!d&&_e(u,f,n,r)&&i.push(be(t[a]))}}return i})(_.getEntriesByType(vt),function(t){for(var e=t.spans,n=[],r=0;ra&&"function"==typeof e?e.apply(i,arguments):t.apply(i,arguments)}}(this.queue.add.bind(this.queue),(function(){return t._loggingService.warn("Dropped events due to throttling!")}),{limit:r,interval:6e4})},e._postJson=function(t,e){return this._makeHttpRequest("POST",t,{payload:e,headers:{"Content-Type":"application/x-ndjson"}}).then((function(t){return t.responseText}))},e._constructError=function(t){var e=t.url,n=t.status;t.responseText;if(void 0===n)return t;var r=e+" HTTP status: "+n;return new Error(r)},e._makeHttpRequest=function(t,e,n){var r=void 0===n?{timeout:1e4}:n,i=r.timeout,a=r.payload,o=r.headers;return new g((function(n,r){var s=new window.XMLHttpRequest;if(s[$]=!0,s.open(t,e,!0),s.timeout=i,o)for(var c in o)o.hasOwnProperty(c)&&s.setRequestHeader(c,o[c]);s.onreadystatechange=function(){if(4===s.readyState){var t=s.status,i=s.responseText;0===t||t>399&&t<600?r({url:e,status:t,responseText:i}):n(s)}},s.onerror=function(){var t=s.status,n=s.responseText;r({url:e,status:t,responseText:n})},s.send(a)}))},e.fetchConfig=function(t,e){var n=this,r=this._configService.get("serverUrl")+"/config/v1/rum/agents";if(!t)return g.reject("serviceName is required for fetching central config.");r+="?service.name="+t,e&&(r+="&service.environment="+e);var i=this._configService.getLocalConfig();return i&&(r+="&ifnonematch="+i.etag),this._makeHttpRequest("GET",r,{timeout:5e3}).then((function(t){var e=t.status,r=t.responseText;if(304===e)return i;var a=JSON.parse(r),o=t.getResponseHeader("etag");return o&&(a.etag=o.replace(/["]/g,""),n._configService.setLocalConfig(a)),a})).catch((function(t){var e=n._constructError(t);return g.reject(e)}))},e.createMetaData=function(){var t=this._configService,e={service:{name:t.get("serviceName"),version:t.get("serviceVersion"),agent:{name:"rum-js",version:t.version},language:{name:"javascript"},environment:t.get("environment")},labels:t.get("context.tags")};return le(ae,e)},e.addError=function(t){var e;this.throttleEvents(((e={}).errors=t,e))},e.addTransaction=function(t){var e;this.throttleEvents(((e={}).transactions=t,e))},e.ndjsonErrors=function(t,e){var n=e?"e":"error";return t.map((function(t){var r;return me.stringify(((r={})[n]=e?function(t){var e,n=t.exception,r={id:t.id,cl:t.culprit,ex:{mg:n.message,st:(e=n.stacktrace,e.map((function(t){return{ap:t.abs_path,f:t.filename,fn:t.function,li:t.lineno,co:t.colno}}))),t:t.type},c:ke(t.context)},i=t.transaction;return i&&(r.tid=t.trace_id,r.pid=t.parent_id,r.xid=t.transaction_id,r.x={t:i.type,sm:i.sampled}),r}(t):t,r))}))},e.ndjsonMetricsets=function(t){return t.map((function(t){return me.stringify({metricset:t})})).join("")},e.ndjsonTransactions=function(t,e){var n=this,r=e?"x":"transaction";return t.map((function(t){var i,a="",o="";return e||(t.spans&&(a=t.spans.map((function(t){return me.stringify({span:t})})).join(""),delete t.spans),t.breakdown&&(o=n.ndjsonMetricsets(t.breakdown),delete t.breakdown)),me.stringify(((i={})[r]=e?function(t){var e,n=t.spans.map((function(e){var n={id:e.id,n:e.name,t:e.type,s:e.start,d:e.duration,c:ke(e.context)};return e.parent_id!==t.id&&(n.pid=e.parent_id),!0===e.sync&&(n.sy=!0),e.subtype&&(n.su=e.subtype),e.action&&(n.ac=e.action),n}));return{id:t.id,tid:t.trace_id,n:t.name,t:t.type,d:t.duration,c:ke(t.context),m:Le(t.marks),me:(e=t.breakdown,e.map((function(t){var e=t.span,n=t.samples,r=null!=e;return r?{y:{t:e.type},sa:{ysc:{v:n["span.self_time.count"].value},yss:{v:n["span.self_time.sum.us"].value}}}:{sa:{xdc:{v:n["transaction.duration.count"].value},xds:{v:n["transaction.duration.sum.us"].value},xbc:{v:n["transaction.breakdown.count"].value}}}}))),y:n,yc:{sd:n.length},sm:t.sampled}}(t):t,i))+a+o}))},e.sendEvents=function(t){var e,n;if(0!==t.length){for(var r=[],i=[],a=0;a2,p=[],l=this.createMetaData(),v=d?"m":"metadata";p.push(me.stringify(((n={})[v]=d?function(t){var e=t.service,n=t.labels,r=e.agent,i=e.language;return{se:{n:e.name,ve:e.version,a:{n:r.name,ve:r.version},la:{n:i.name},en:e.environment},l:n}}(l):l,n)));var h=(p=p.concat(this.ndjsonErrors(u.errors,d),this.ndjsonTransactions(u.transactions,d))).join(""),g=s.get("serverUrl")+"/intake/v"+f+"/rum/events";return this._postJson(g,h)}this._loggingService.warn("Dropped payload due to filtering!")}}},t}();var Ie,Ce=function(){function t(){this.config={serviceName:"",serviceVersion:"",environment:"",serverUrl:"http://localhost:8200",active:!0,instrument:!0,disableInstrumentations:[],logLevel:"warn",breakdownMetrics:!1,ignoreTransactions:[],eventsLimit:80,queueLimit:-1,flushInterval:500,distributedTracing:!0,distributedTracingOrigins:[],distributedTracingHeaderName:"traceparent",pageLoadTraceId:"",pageLoadSpanId:"",pageLoadSampled:!1,pageLoadTransactionName:"",transactionSampleRate:1,centralConfig:!1,monitorLongtasks:!0,apiVersion:2,context:{}},this.events=new jt,this.filters=[],this.version=""}var e=t.prototype;return e.init=function(){var t=function(t){if(!t)return{};for(var e={},n=/^data-([\w-]+)$/,r=t.attributes,i=0;i0?t.charAt(0).toUpperCase()+t.substring(1):t})).join("");e[o]=a.value||a.nodeValue}}return e}(C());this.setConfig(t)},e.isActive=function(){return this.get("active")},e.setVersion=function(t){this.version=t},e.addFilter=function(t){if("function"!=typeof t)throw new Error("Argument to must be function");this.filters.push(t)},e.applyFilters=function(t){for(var e=0;e"});var r=t.transactionSampleRate;return void 0!==r&&("number"!=typeof r||isNaN(r)||r<0||r>1)&&n.invalid.push({key:"transactionSampleRate",value:r,allowed:"Number between 0 and 1"}),n},e.getLocalConfig=function(){var t=sessionStorage.getItem("elastic_apm_config");if(t)return JSON.parse(t)},e.setLocalConfig=function(t){t&&sessionStorage.setItem("elastic_apm_config",JSON.stringify(t))},t}(),Ne=function(){function t(t){void 0===t&&(t={}),this.levels=["trace","debug","info","warn","error"],this.level=t.level||"info",this.prefix=t.prefix||"",this.resetLogMethods()}var e=t.prototype;return e.shouldLog=function(t){return this.levels.indexOf(t)>=this.levels.indexOf(this.level)},e.setLevel=function(t){this.level=t,this.resetLogMethods()},e.resetLogMethods=function(){var t=this;this.levels.forEach((function(e){t[e]=t.shouldLog(e)?function(){var n,r=t.prefix;switch(e){case"trace":case"debug":n="info";break;default:n=e}var i=arguments;r&&(i[0]=r+i[0]);if(console){var a=console[n]||console.log;"function"==typeof a&&a.apply(console,i)}}:R}))},t}(),je=((Ie={})[yt]=function(){return new Ce},Ie[_t]=function(){return new Ne({prefix:"[Elastic APM] "})},Ie[bt]=function(t){var e=t.getService([yt,_t]),n=e[0],r=e[1];return new Oe(n,r)},Ie),Fe=function(){function t(){this.instances={},this.initialized=!1}var e=t.prototype;return e.init=function(){if(!this.initialized){this.initialized=!0;var t=this.getService(yt);t.init();var e=this.getService(_t);n(e,t),t.events.observe("config:change",(function(){n(e,t)})),this.getService(bt).init()}function n(t,e){var n=e.get("logLevel");t.setLevel(n)}},e.getService=function(t){var e=this;return"string"==typeof t?(this.instances[t]||"function"==typeof je[t]&&(this.instances[t]=je[t](this)),this.instances[t]):Array.isArray(t)?t.map((function(t){return e.getService(t)})):void 0},t}();var Re=.05;var Ae=function(){function t(t,e,n,r){this._apmServer=t,this._configService=e,this._logginService=n,this._transactionService=r}var e=t.prototype;return e.init=function(t){var e=this;void 0===t&&(t={}),this._configService.events.observe("transaction:end:after",(function(t){var n=e.createTransactionPayload(t);n&&e._apmServer.addTransaction(n)})),t[ct]&&Ft.observe(ct,this.getHistorySub()),t[ot]&&Ft.observe(ot,this.getXHRSub()),t[st]&&Ft.observe(st,this.getFetchSub()),t[ut]&&Ft.observe(ut,this.getEventTargetSub())},e.getEventTargetSub=function(){var t=this._transactionService;return function(e,n){if(e===Z&&n.source===ut&&"click"===n.eventType){var r=n.target,i=r.getAttribute("name"),a="";i&&(a='["'+i+'"]');var o=r.tagName.toLowerCase(),s=t.startTransaction("Click - "+o+a,"user-interaction",{managed:!0,canReuse:!0,reuseThreshold:100});if(s){var c=r.getAttribute("class");c&&s.addContext({custom:{classes:c}})}}}},e.getHistorySub=function(){var t=this._transactionService;return function(e,n){n.source===ct&&e===G&&t.startTransaction(n.data.title,"route-change",{managed:!0,canReuse:!0})}},e.getXHRSub=function(){var t=this;return function(e,n){n.source!==ot||z.fetchInProgress||t.processAPICalls(e,n)}},e.getFetchSub=function(){var t=this;return function(e,n){n.source===st&&t.processAPICalls(e,n)}},e.processAPICalls=function(t,e){var n=this._configService,r=this._transactionService;if(t===Z&&e.data){var i=e.data,a=new Ht(i.url),o=i.method+" "+(a.relative?a.path:L(a.href));r.getCurrentTransaction()||r.startTransaction(o,"http-request",{managed:!0});var s=r.startSpan(o,"external.http"),c=r.addTask();if(!s)return;var u=n.get("distributedTracing"),f=n.get("distributedTracingOrigins"),d=new Ht(window.location.href),p=E(a.origin,d.origin)||E(a.origin,f),l=i.target;u&&p&&l&&this.injectDtHeader(s,l),i.sync&&(s.sync=i.sync),i.span=s,e.id=c}else t===G&&(e.data&&e.data.span&&e.data.span.end(null,e.data),e.id&&r.removeTask(e.id))},e.injectDtHeader=function(t,e){var n,r=this._configService.get("distributedTracingHeaderName"),i=function(t){if(t&&t.traceId&&t.id&&t.parentId){var e=t.sampled?"01":"00",n=t.sampled?t.id:t.parentId;return"00-"+t.traceId+"-"+n+"-"+e}}(t),a=/^[\da-f]{2}-[\da-f]{32}-[\da-f]{16}-[\da-f]{2}$/.test(n=i)&&"00000000000000000000000000000000"!==n.slice(3,35)&&"0000000000000000"!==n.slice(36,52);r&&i&&a&&("function"==typeof e.setRequestHeader?e.setRequestHeader(r,i):e.headers&&"function"==typeof e.headers.append?e.headers.append(r,i):e[r]=i)},e.extractDtHeader=function(t){var e=this._configService.get("distributedTracingHeaderName");if(t)return function(t){var e=/^([\da-f]{2})-([\da-f]{32})-([\da-f]{16})-([\da-f]{2})$/.exec(t);if(e){var n="00"!==e[4];return{traceId:e[2],id:e[3],sampled:n}}}(t[e])},e.filterTransaction=function(t){var e=t.duration();if(!e)return!1;if(t.isManaged()){if(e>6e4)return!1;if(t.sampled&&0===t.spans.length)return!1;if(t.type!==et)if(!function(t,e,n){var r=t.browserResponsivenessCounter,i=t.duration();return r+n>=Math.floor(i/e)}(t,500,3))return!1}return!0},e.createTransactionDataModel=function(t){var e=t._start,n=t.spans.map((function(n){var r={id:n.id,transaction_id:t.id,parent_id:n.parentId||t.id,trace_id:t.traceId,name:n.name,type:n.type,subtype:n.subtype,action:n.action,sync:n.sync,start:parseInt(n._start-e),duration:n.duration(),context:n.context};return le(ce,r)})),r={id:t.id,trace_id:t.traceId,name:t.name,type:t.type,duration:t.duration(),spans:n,context:t.context,marks:t.marks,breakdown:t.breakdownTimings,span_count:{started:n.length},sampled:t.sampled};return le(ue,r)},e.createTransactionPayload=function(t){var e=function(t){if(t.sampled){var e=t.spans.filter((function(e){return e.duration()>0&&e._start>=t._start&&e._end<=t._end}));if(t.isManaged()){var n=function(t,e,n){t.sort((function(t,e){return t._start-e._start}));var r=[],i=1;return t.forEach((function(a,o){if(0===r.length)r.push(a);else{var s=r[r.length-1],c=s.type===a.type&&s.subtype===a.subtype&&s.action===a.action&&s.name===a.name&&a.duration()/e1&&(!c||u)&&(s.name=i+"x "+s.name,i=1),c||r.push(a)}})),r}(e,t.duration(),Re);t.spans=n}else t.spans=e}else t.resetSpans();return t}(t);if(this.filterTransaction(e))return this.createTransactionDataModel(t)},t}(),Pe=[["domainLookupStart","domainLookupEnd","DNS"],["connectStart","connectEnd","TCP"],["requestStart","responseStart","Request"],["responseStart","responseEnd","Response"],["domLoading","domComplete","Processing"],["loadEventStart","loadEventEnd","Load"]];function Me(t){return{value:t}}function qe(t,e){var n=e.details,r=e.count,i=void 0===r?1:r,a=e.duration;return{transaction:t,span:n,samples:{"span.self_time.count":Me(i),"span.self_time.sum.us":Me(a)}}}function He(t,e){void 0===e&&(e=_.timing);var n=[],r=t.duration(),i=t.name,a=t.type,o=t.sampled,s={name:i,type:a};if(n.push({transaction:s,samples:{"transaction.duration.count":Me(1),"transaction.duration.sum.us":Me(r),"transaction.breakdown.count":Me(o?1:0)}}),!o)return n;if(a===et&&e)for(var c=0;cs?(c+=o-s,s=a):a>s&&(s=a);return s-1&&this._scheduledTasks.splice(e,1),this.detectFinish()},i.resetSpans=function(){this.spans=[]},i._onSpanEnd=function(t){this.spans.push(t),delete this._activeSpans[t.id]},i.isManaged=function(){return!!this.options.managed},r}(Pt),ze=function(){function t(t,e){var n=this;this._config=e,this._logger=t,this.currentTransaction=void 0,this.respIntervalId=void 0,this.recorder=new Yt((function(t){var e=n.getCurrentTransaction();if(e&&e.captureTimings){var r,i=!1;e.type===et&&(i=!0);var a=Wt(t,{capturePaint:i}),o=a.spans,s=a.marks;(r=e.spans).push.apply(r,o),e.addMarks({agent:s})}}))}var e=t.prototype;return e.ensureCurrentTransaction=function(t,e,n){var r=this.getCurrentTransaction();return r||(r=new De(t,e,n),this.setCurrentTransaction(r),r)},e.getCurrentTransaction=function(){if(this.currentTransaction&&!this.currentTransaction.ended)return this.currentTransaction},e.setCurrentTransaction=function(t){this.currentTransaction=t},e.ensureRespInterval=function(t){var e=this,n=function(){clearInterval(e.respIntervalId),e.respIntervalId=void 0};t?void 0===this.respIntervalId&&(this.respIntervalId=setInterval((function(){var t=e.getCurrentTransaction();t?t.browserResponsivenessCounter++:n()}),500)):void 0!==this.respIntervalId&&n()},e.createOptions=function(t){var e=this._config.config,n=N({transactionSampleRate:e.transactionSampleRate},t);return n.managed&&(n=N({pageLoadTraceId:e.pageLoadTraceId,pageLoadSampled:e.pageLoadSampled,pageLoadSpanId:e.pageLoadSpanId,pageLoadTransactionName:e.pageLoadTransactionName},n)),n},e.startManagedTransaction=function(t,e,n){var r=this.getCurrentTransaction(),i=!1;if(r)if(r.canReuse()&&n.canReuse){var a=r.type,o=it.indexOf(r.type),s=it.indexOf(e);o>=0&&s0&&t.spans.push((a=Kt.tbt,o=a.start,s=a.duration,(c=new Gt("Total Blocking Time",dt,{startTime:o})).end(o+s),c))}var a,o,s,c;Ee(t),e.adjustTransactionTime(t),e._config.get("breakdownMetrics")&&t.captureBreakdown();var u=e._config.get("context");Zt(t,u),e._config.events.send("transaction:end",[t])}}),(function(t){0}))},e.adjustTransactionTime=function(t){var e=t.spans,n=function(t){for(var e=t[0],n=1;nr._start&&(e=r)}return e}(e);n&&n._startt._end&&(t._end=r._end);for(var i=t._end,a=0;ai&&(o._end=i,o.type+=St),o._start>i&&(o._start=i)}},e.shouldIgnoreTransaction=function(t){var e=this._config.get("ignoreTransactions");if(e&&e.length)for(var n=0;n0&&(o+=r.join(", ")+" is missing",i.length>0&&(o+=", ")),i.forEach((function(t,e){var n=t.key,r=t.value,a=t.allowed;o+=n+' "'+r+'" contains invalid characters! (allowed: '+a+")"+(e!==i.length-1?", ":"")})),a.error(o),e.setConfig({active:!1})}},e.setUserContext=function(t){this.serviceFactory.getService(yt).setUserContext(t)},e.setCustomContext=function(t){this.serviceFactory.getService(yt).setCustomContext(t)},e.addLabels=function(t){this.serviceFactory.getService(yt).addLabels(t)},e.setInitialPageLoadName=function(t){this.isEnabled()&&this.serviceFactory.getService(yt).setConfig({pageLoadTransactionName:t})},e.startTransaction=function(t,e,n){if(this.isEnabled())return this.serviceFactory.getService("TransactionService").startTransaction(t,e,n)},e.startSpan=function(t,e){if(this.isEnabled())return this.serviceFactory.getService("TransactionService").startSpan(t,e)},e.getCurrentTransaction=function(){if(this.isEnabled())return this.serviceFactory.getService("TransactionService").getCurrentTransaction()},e.captureError=function(t){if(this.isEnabled())return this.serviceFactory.getService("ErrorLogging").logError(t)},e.addFilter=function(t){this.serviceFactory.getService(yt).addFilter(t)},t}();var $e=function(){if(y&&window.elasticApm)return window.elasticApm;var t=ee(),e=Be(),n=new Ue(e,!t);return y&&(window.elasticApm=n),n}(),Ve=$e.init.bind($e);e.default=Ve}]);
+//# sourceMappingURL=elastic-apm-rum.umd.min.js.map
diff --git a/examples/tracing-test/src/main/resources/log4j2.xml b/examples/tracing-test/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..89a3541
--- /dev/null
+++ b/examples/tracing-test/src/main/resources/log4j2.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/tracing-test/src/test/resources/log4j2-test.xml b/examples/tracing-test/src/test/resources/log4j2-test.xml
new file mode 100644
index 0000000..bffdaa4
--- /dev/null
+++ b/examples/tracing-test/src/test/resources/log4j2-test.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mule4-agent/pom.xml b/mule4-agent/pom.xml
index 2b4e3a8..fca2053 100644
--- a/mule4-agent/pom.xml
+++ b/mule4-agent/pom.xml
@@ -4,7 +4,7 @@
4.0.0
co.elastic.apm
mule4-agent
- 0.3.0
+ 0.4.0
Elastic Mule 4 APM agent
Elastic Mule 4 APM agent
jar
diff --git a/mule4-agent/src/main/java/co/elastic/apm/mule4/agent/tracing/HttpTracingUtils.java b/mule4-agent/src/main/java/co/elastic/apm/mule4/agent/tracing/HttpTracingUtils.java
index 4e93759..fcaf308 100644
--- a/mule4-agent/src/main/java/co/elastic/apm/mule4/agent/tracing/HttpTracingUtils.java
+++ b/mule4-agent/src/main/java/co/elastic/apm/mule4/agent/tracing/HttpTracingUtils.java
@@ -13,7 +13,8 @@ public class HttpTracingUtils {
private static final String HTTP_REQUEST_NAMESPACE = "http://www.mulesoft.org/schema/mule/http";
private static final String HTTP_REQUEST_NAME = "request";
- public static final String ELASTIC_APM_TRACEPARENT = "elastic-apm-traceparent";
+ public static final String ELASTIC_APM_TRACEPARENT_HEADER = "elastic-apm-traceparent";
+ public static final String TRACEPARENT_HEADER = "traceparent";
public static boolean isHttpEvent(PipelineMessageNotification notification) {
return extractAttributes(notification).getDataType().getType() == HttpRequestAttributes.class;
@@ -24,17 +25,22 @@ public static boolean hasRemoteParent(PipelineMessageNotification notification)
if (!isHttpEvent(notification))
return false;
- return getHttpAttributes(notification).containsKey(ELASTIC_APM_TRACEPARENT);
+ return getHttpAttributes(notification).containsKey(ELASTIC_APM_TRACEPARENT_HEADER)
+ || getHttpAttributes(notification).containsKey(TRACEPARENT_HEADER);
}
public static String getTracingHeaderValue(String x, PipelineMessageNotification notification) {
- return getHttpAttributes(notification).get(ELASTIC_APM_TRACEPARENT);
+
+ if (getHttpAttributes(notification).containsKey(ELASTIC_APM_TRACEPARENT_HEADER))
+ return getHttpAttributes(notification).get(ELASTIC_APM_TRACEPARENT_HEADER);
+ else
+ return getHttpAttributes(notification).get(TRACEPARENT_HEADER);
}
private static MultiMap getHttpAttributes(PipelineMessageNotification notification) {
-
+
HttpRequestAttributes attributes = (HttpRequestAttributes) extractAttributes(notification).getValue();
-
+
return attributes.getHeaders();
}
@@ -43,17 +49,17 @@ private static TypedValue