-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add OpenTracing support (#138)
* feat: add OpenTracing support add a separate bundle for opentracing minor fixes * add opentracing-entry bundle opentracing seperately but including the apm-base * update js-core to 2.4
- Loading branch information
1 parent
29ff168
commit 0cff389
Showing
12 changed files
with
124 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const indexExports = require('./index') | ||
const opentracing = require('./opentracing') | ||
const { extend } = require('elastic-apm-js-core/src/common/utils') | ||
module.exports = extend({}, indexExports, opentracing) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const { createTracer: createElasticTracer } = require('elastic-apm-js-core/src/opentracing') | ||
|
||
function createTracer (apmBase) { | ||
return createElasticTracer(apmBase.serviceFactory) | ||
} | ||
|
||
if (window && window.elasticApm) { | ||
window.elasticApm.createTracer = createTracer.bind(window.elasticApm, window.elasticApm) | ||
} | ||
|
||
module.exports = { | ||
__esModule: true, | ||
default: createTracer, | ||
createTracer | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>test</title> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" href="data:;base64,iVBORw0KGgo=" /> | ||
</head> | ||
|
||
<body> | ||
<div id="app"></div> | ||
<script src="/dist/bundles/elastic-apm-opentracing.umd.min.js"></script> | ||
<script> | ||
var serverUrl = 'http://localhost:8003', | ||
apmServerUrl = 'http://localhost:8001' | ||
|
||
elasticApm.init({ | ||
serviceName: 'standalone-html', | ||
serverUrl: apmServerUrl, | ||
distributedTracingOrigins: [serverUrl], | ||
pageLoadTransactionName: '/' | ||
}) | ||
|
||
function checkDtInfo(payload) { | ||
console.log('distributed tracing data', payload) | ||
if (typeof payload.traceId !== 'string') { | ||
throw new Error('Wrong distributed tracing payload: ') | ||
} | ||
} | ||
|
||
var tracer = elasticApm.createTracer() | ||
var span = tracer.startSpan('Opentracing span') | ||
span.finish(Date.now() + 100) | ||
|
||
req = new window.XMLHttpRequest() | ||
req.onerror = function(err) { | ||
console.log('[XHR Error]', err) | ||
} | ||
req.open('POST', serverUrl + '/data', false) | ||
req.addEventListener('load', function() { | ||
var payload = JSON.parse(req.responseText) | ||
checkDtInfo(payload) | ||
|
||
var appEl = document.getElementById('app') | ||
var testEl = document.createElement('h2') | ||
testEl.setAttribute('id', 'test-element') | ||
testEl.innerHTML = 'Passed' | ||
appEl.appendChild(testEl) | ||
}) | ||
|
||
req.send() | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters