-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(sdk): automatically log http calls to API #3081
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few small comments
return res; | ||
} | ||
|
||
const valuesToFilter: string[] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small thought for the future: Could we compute our filter array once up front before any runner work and have the logger lean on it across all logging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed. The valuesToFilter should not changed within a single execution
request: { | ||
method: method, | ||
url: redactURL({ url: res.config.url, valuesToFilter }), | ||
headers: redactHeaders({ headers: res.config.headers }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be more future-proof if we went ahead and included valuesToFilter
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small comments. The most important is about precomputing valuesToFilter
onFulfilled: this.logAPICall.bind(this) | ||
} | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do I read correctly that it doesn't override the interceptors defined a few lines above that is used for snapshoting in dry-mode?
logger[logLevelToLogger[level] ?? 'info'].apply(null, [args[0], { status: args[1]?.response?.code || 'xxx' }] as any); | ||
} else { | ||
logger[logLevelToLogger[level] ?? 'info'].apply(null, args as any); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would something like this be easier to read
const status = args[1]?.type == 'http' ? args[1].response?.code: undefined
const logArgs = status ? [args[0], { status }] : args
logger[logLevelToLogger[level] ?? 'info'].apply(null, logArgs as any);
return res; | ||
} | ||
|
||
const valuesToFilter: string[] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed. The valuesToFilter should not changed within a single execution
Changes
While doing fix(sdk): expose getIntegration() #3080 I noticed we don't log calls to our own API which can lead to confusion when you expect something to happen but don't manually log the result. Thanks to recent change, we now have a way to plug into axios and just listen to requests.
It will log everything (i.e: triggerAction, getConnection, getIntegration, etc.), except proxy which doesn't go through node-client.
NB: This will for sure increase the log amount but just slightly since we do cache a lot.