add b3 header for trace propagation on initial webhook

This commit is contained in:
Dave Horton
2022-03-30 15:12:44 -04:00
parent ff8d7f3648
commit dbe925af05
4 changed files with 29 additions and 5 deletions

View File

@@ -49,7 +49,7 @@ class HttpRequestor extends BaseRequestor {
* @param {string} [hook.password] - if basic auth is protecting the endpoint
* @param {object} [params] - request parameters
*/
async request(type, hook, params) {
async request(type, hook, params, httpHeaders = {}) {
assert(HookMsgTypes.includes(type));
const payload = params ? snakeCaseKeys(params, ['customerData', 'sip']) : null;
const url = hook.url || hook;
@@ -64,8 +64,8 @@ class HttpRequestor extends BaseRequestor {
let buf;
try {
const sigHeader = this._generateSigHeader(payload, this.secret);
const headers = {...sigHeader, ...this.authHeader};
//this.logger.info({url, headers}, 'send webhook');
const headers = {...sigHeader, ...this.authHeader, ...httpHeaders};
this.logger.debug({url, headers}, 'send webhook');
buf = this._isRelativeUrl(url) ?
await this.post(url, payload, headers) :
await bent(method, 'buffer', 200, 201, 202)(url, payload, headers);