Skip to content

Commit

Permalink
chore: variable names cleanup
Browse files Browse the repository at this point in the history
Variable names in the trace example were not fully clear. This meant that the relationships between different operations also was unclear. Have amended.
  • Loading branch information
DarkPurple141 committed Sep 16, 2020
1 parent 3309ea4 commit 5350fb7
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions examples/tracer-web/examples/fetch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
}
Expand Down

0 comments on commit 5350fb7

Please sign in to comment.