-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Allow overriding RESTDataSource.trace #2009
Comments
So for your information, I started a branch, which is pretty much "ready" (there were no tests for the trace method): https://github.com/apollographql/apollo-server/compare/master...christianrondeau:gh-2009?expand=1 Quick notes:
I'd like to head feedback from a maintainer before further modifying the code. |
Any estimations when it will be merged? |
Is there any news on this? :) |
For your information, I stopped using apollo's rest data source completely since, the amount of things I had to workaround was larger than the gain for me. |
@christianrondeau thanks for the feedback, are there any other viable alternatives to I want to gather metrics on how my data sources are performing when they actually send requests. @abernix Are there any plans on making trace method |
Is there any news on this? |
There even was a PR trying to convert In our case, we just want to get rid of the logs like these:
We have our own logging and it's unpleasant that apollo-server/packages/apollo-datasource-rest/src/RESTDataSource.ts Lines 285 to 293 in bbae424
|
I know this issue has been opened for awhile, but I would also like to point out that the implementation for trace is using console.log instead of |
In the absence of a proper fix (which I agree would be highly desirable) you can "subclass" RESTDataSource and provide your own override of the |
Major +1 on this issue. It may not seem like a big deal, but having an unnecessary Simply making this method |
I've just overriden the method with @ts-ignore. But what would be the best way to also trace the REST calls response status? Wouldn't it be better to trace in "didReceiveResponse" or something? |
I think you can put some tracing in didReceiveResponse and didEncounterError |
I'm currently adding Application Insights' dependency tracking into an Apollo server, and I'd like to track the time it takes to call dependencies from within Apollo. Good news, there's a
trace
method that does exactly what I need! Bad news, it's private and only logs toconsole
...I'd like to simply be able to receive the trace context (url, duration, method) and log that information myself.
I'm happy to provide a PR if that makes sense.
RESTDataSource.traceEnabled
(by default,process && process.env && process.env.NODE_ENV === 'development'
)RESTDataSource.trace
to receive individual propertiesoptions.method || 'GET'
andurl
RESTDataSource.log
, which by default logs to the console like it does now, but that can be overriden.The text was updated successfully, but these errors were encountered: