-
Notifications
You must be signed in to change notification settings - Fork 404
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: Ensure API errors are tracked #1880
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1880 +/- ##
==========================================
+ Coverage 96.87% 96.88% +0.01%
==========================================
Files 209 210 +1
Lines 39635 39698 +63
==========================================
+ Hits 38397 38463 +66
+ Misses 1238 1235 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
I may have more comments after another round but I think I called out everything that needs to be addressed
lib/llm-events/openai/llm-error.js
Outdated
* Represents an error object, to be tracked via `agent.errors`, that is the | ||
* result of some error returned from the OpenAI API. | ||
*/ | ||
class OpenAiLlmError extends Error { |
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.
This should just be a class, not inheriting from Error. When you call agent.errors.add
the signature is transaction, err, customAttrs
. This class should be providing all the custom attrs. Since the NR exceptions do not handle error.code and error.param those will be properties on this class.
This PR is to resolve newrelic#1845.
200ad00
to
7dab013
Compare
7dab013
to
9c155c7
Compare
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.
nice work 👏🏻
@@ -35,6 +36,7 @@ function shouldSkipInstrumentation(config, shim) { | |||
return semver.lt(pkgVersion, MIN_VERSION) | |||
} | |||
|
|||
// eslint-disable-next-line sonarjs/cognitive-complexity |
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.
i noticed this too. I think it's because we're defining all the functions within the module.exports. We try not to add to the cognitive complexity but we can address later
*/ | ||
function recordChatCompletionMessages({ segment, request, response }) { | ||
function recordChatCompletionMessages({ segment, request, response, hasError = false }) { |
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.
nit: hasError and withError
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.
What is your suggestion?
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 calling out the arg coming in is diff than it going into the event creation
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.
In my mind there's a difference between the two, but I'm totally open to changing it one way or the other. Which would you prefer?
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.
Ah I guess so. Just keep it.
This PR is to resolve #1845.