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

ApolloServerPluginUsageReporting does not allow to pass http agent #7811

Closed
vany0114 opened this issue Dec 20, 2023 · 11 comments
Closed

ApolloServerPluginUsageReporting does not allow to pass http agent #7811

vany0114 opened this issue Dec 20, 2023 · 11 comments

Comments

@vany0114
Copy link
Contributor

Issue Description

Hello,

I'm using Apollo Federation in an Azure environment, specifically deployed as an Azure Function. I've noticed that the ApolloServerPluginUsageReporting is causing a lot of connect ETIMEDOUT as it seems it is exhausting the available Websockets/TCP connections when making this request to: HTTP: POST usage-reporting.api.apollographql.com/api/ingress/traces, I guess most likely because it is not reusing the HTTP contention, so I had to disable the reporting as I could not find a way to pass an HTTP agent to the plunging to keep alive the connection to avoid the issue mentioned above.

Is there a workaround or you guys can please point me to the right direction?

Link to Reproduction

N/A

Reproduction Steps

No response

@vany0114
Copy link
Contributor Author

Hi @glasser is this repo active/being maintained?

@glasser
Copy link
Member

glasser commented Jan 3, 2024

Yes, but not by me personally, and most of Apollo was on vacation starting right around when you filed the issue :)
Also, this is more specifically a part of Apollo Server rather than federation-specific, so I will move this issue to that repository. That said, I will then close it for now because there's not enough information to reproduce — at the very least we will need the version of Apollo Server you're using.

@glasser glasser transferred this issue from apollographql/federation Jan 3, 2024
@glasser glasser closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2024
@vany0114
Copy link
Contributor Author

vany0114 commented Jan 3, 2024

Yes, but not by me personally, and most of Apollo was on vacation starting right around when you filed the issue :) Also, this is more specifically a part of Apollo Server rather than federation-specific, so I will move this issue to that repository. That said, I will then close it for now because there's not enough information to reproduce — at the very least we will need the version of Apollo Server you're using.

@glasser Thanks for the response, these are the versions we're using:

"@apollo/gateway": "^2.5.1",
"@apollo/server": "^4.9.0",
"@apollo/server-plugin-landing-page-graphql-playground": "^4.0.1",
"@apollo/server-plugin-response-cache": "^4.1.3",
"@apollo/subgraph": "^2.5.1",

Can you please leave the link here when you open the issue in the other repo, or at least point me where I should open it, I can do so as well.

@glasser
Copy link
Member

glasser commented Jan 4, 2024

Hi, this was transferred in place to this repo.

I assume you are also using @as-integrations/azure-functions? It might make more sense to start this discussion at https://github.com/apollo-server-integrations/apollo-server-integration-azure-functions as this might be an Azure-specific concern.

@glasser
Copy link
Member

glasser commented Jan 4, 2024

That said, the usage reporting plugin uses the standard fetch API to do HTTP and you can customize this with the fetcher option. By default it uses node-fetch, so you could use that yourself adding an agent of your choice to the call.

@vany0114
Copy link
Contributor Author

vany0114 commented Jan 4, 2024

That said, the usage reporting plugin uses the standard fetch API to do HTTP and you can customize this with the fetcher option. By default it uses node-fetch, so you could use that yourself adding an agent of your choice to the call.

Yes I'm aware of that, I know I can pass the fetcher, but how can I pass the options to which the fetcher will use when it's called? maybe I'm missing something here, would you mind sharing an example of how it can be achieved?

@vany0114
Copy link
Contributor Author

vany0114 commented Jan 4, 2024

Hi, this was transferred in place to this repo.

I assume you are also using @as-integrations/azure-functions? It might make more sense to start this discussion at https://github.com/apollo-server-integrations/apollo-server-integration-azure-functions as this might be an Azure-specific concern.

Yes I'm using the @as-integrations/azure-functions, is there a specific implementation of the ApolloServerPluginUsageReporting for Azure then?

@glasser
Copy link
Member

glasser commented Jan 4, 2024

Something like

import fetch from 'node-fetch';

new ApolloServerPluginUsageReporting({
  fetcher(url, options) {
    return fetch(url, {...options, agent: myAgent});
  }
})

?

@glasser
Copy link
Member

glasser commented Jan 4, 2024

And no, you're correct that the plugin is generic, but it's possible that there are other aspects of running in Azure Functions that the AF integration maintainers may be more knowledgeable about (eg, how "background" operations like publishing usage reports might work best in that context).

@vany0114
Copy link
Contributor Author

vany0114 commented Jan 4, 2024

@glasser That makes sense, I'll give it a try, thanks 🙏

Copy link
Contributor

github-actions bot commented Feb 4, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
For general questions, we recommend using StackOverflow or our discord server.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants