Skip to content

Instantly share code, notes, and snippets.

@endeepak
Created January 12, 2020 16:25
Show Gist options
  • Save endeepak/0e2328fd8dd8af5c4a8388a51ebdb5ca to your computer and use it in GitHub Desktop.
Save endeepak/0e2328fd8dd8af5c4a8388a51ebdb5ca to your computer and use it in GitHub Desktop.
NodeJS Request Log Tracing : HTTP Request Wrapper
const request = require('request-promise');
const requestTracing = require('request-tracing'); // Wrapper library to read the tracing information from CLS context
const requestPromiseWrapper = async (body) => {
const requestBody = Object.assign({}, body);
requestBody.headers['X-Tracing-Id'] = requestTracing.getTracingId(); // Same as requestTracingNamespace.get('tracingId');
return request(requestBody);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment