examples/mongodb/server.js
/** A function which handles requests and send response. */
A function which handles requests and send response.
A function which handles requests and send response .
function handleRequest(request, response) {
  const currentSpan = api.trace.getSpan(api.context.active());
  const { traceId } = currentSpan.spanContext();
  console.log(`traceid: ${traceId}`);
  console.log(`Jaeger URL: http://localhost:16686/trace/${traceId}`);
  console.log(`Zipkin URL: http://localhost:9411/zipkin/traces/${traceId}`);
  try {
    const body = [];
    request.on('error', (err) => console.log(err));
    request.on('data', (chunk) => body.push(chunk));
    request.on('end', async () => {
      if (request.url === '/collection/') {
        handleCreateCollection(response);
      } else if (request.url === '/insert/') {
        handleInsertQuery(response);
      } else if (request.url === '/get/') {
        handleGetQuery(response);
      } else {
        handleNotFound(response);
      }
    });
  } catch (err) {
    console.log(err);
  }
}
function handleRequest ( request , response ) { const currentSpan = api . trace . getSpan ( api . context . active ( ) ) ; const { traceId } = currentSpan . spanContext ( ) ; console . log ( ` ${ traceId } ` ) ; console . log ( ` ${ traceId } ` ) ; console . log ( ` ${ traceId } ` ) ; try { const body = [ ] ; request . on ( 'error' , ( err ) => console . log ( err ) ) ; request . on ( 'data' , ( chunk ) => body . push ( chunk ) ) ; request . on ( 'end' , async ( ) => { if ( request . url === '/collection/' ) { handleCreateCollection ( response ) ; } else if ( request . url === '/insert/' ) { handleInsertQuery ( response ) ; } else if ( request . url === '/get/' ) { handleGetQuery ( response ) ; } else { handleNotFound ( response ) ; } } ) ; } catch ( err ) { console . log ( err ) ; } }
A function which handles requests and send response.
A function which handles requests and send response .
// display traceid in the terminal