From 5350fb73a4db3fe56a9dca21d6f3e488bf65566b Mon Sep 17 00:00:00 2001 From: Alex Hinds Date: Wed, 16 Sep 2020 12:46:47 +1000 Subject: [PATCH] chore: variable names cleanup Variable names in the trace example were not fully clear. This meant that the relationships between different operations also was unclear. Have amended. --- examples/tracer-web/examples/fetch/index.js | 22 ++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/tracer-web/examples/fetch/index.js b/examples/tracer-web/examples/fetch/index.js index 1d29b65475..2ed363453a 100644 --- a/examples/tracer-web/examples/fetch/index.js +++ b/examples/tracer-web/examples/fetch/index.js @@ -39,28 +39,28 @@ const getData = (url) => fetch(url, { // example of keeping track of context between async operations const prepareClickEvent = () => { - const url1 = 'https://httpbin.org/get'; + const url = 'https://httpbin.org/get'; const element = document.getElementById('button1'); const onClick = () => { - const span1 = webTracerWithZone.startSpan(`files-series-info`, { + const singleSpan = webTracerWithZone.startSpan(`files-series-info`, { parent: webTracerWithZone.getCurrentSpan(), }); - webTracerWithZone.withSpan(span1, () => { - getData(url1).then((_data) => { - webTracerWithZone.getCurrentSpan().addEvent('fetching-span1-completed'); - span1.end(); + webTracerWithZone.withSpan(singleSpan, () => { + getData(url).then((_data) => { + webTracerWithZone.getCurrentSpan().addEvent('fetching-single-span-completed'); + singleSpan.end(); }); }); for (let i = 0, j = 5; i < j; i += 1) { - const span1 = webTracerWithZone.startSpan(`files-series-info-${i}`, { + const span = webTracerWithZone.startSpan(`files-series-info-${i}`, { parent: webTracerWithZone.getCurrentSpan(), }); - webTracerWithZone.withSpan(span1, () => { - getData(url1).then((_data) => { - webTracerWithZone.getCurrentSpan().addEvent('fetching-span1-completed'); - span1.end(); + webTracerWithZone.withSpan(span, () => { + getData(url).then((_data) => { + webTracerWithZone.getCurrentSpan().addEvent(`fetching-span-${i}-completed`); + span.end(); }); }); }