Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

bodinsamuel
Copy link
Collaborator

Changes

  • Automatically log http calls to API
    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.

Screenshot 2024-11-28 at 16 11 02

@bodinsamuel bodinsamuel self-assigned this Nov 28, 2024
@bodinsamuel bodinsamuel requested a review from a team November 28, 2024 15:38
Copy link
Contributor

@nalanj nalanj left a 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 :shipit:

return res;
}

const valuesToFilter: string[] = [
Copy link
Contributor

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?

Copy link
Collaborator

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 })
Copy link
Contributor

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?

Copy link
Collaborator

@TBonnin TBonnin left a 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)
}
};
}
Copy link
Collaborator

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);
}
Copy link
Collaborator

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[] = [
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants