nelmio / NelmioCorsBundle

Adds CORS (Cross-Origin Resource Sharing) headers support in your Symfony application
https://symfony.com/bundles/NelmioCorsBundle/
MIT License
1.89k stars 108 forks source link

Avoid preflight responses spamming New Relic #108

Closed trompette closed 6 years ago

trompette commented 6 years ago

At https://laruchequiditoui.fr/, we have an API monitored with New Relic.

For some time we have a strange /unknown route with high throughput:

image

Looking at the documentation we thought it was a configuration problem on our side.

But we calculated the route is about 30% of our traffic and when we looked at our HTTP logs, only responses of OPTIONS requests were generated in less than 10 ms.

These so-called preflight responses are generated by NelmioCorsBundle.

We are wondering if it would be a good idea to offer a configuration option to ignore the transactions.

Thoughts?

Seldaek commented 6 years ago

Why not I guess, but I'd say you could also do this in a request listener to ignore all OPTIONS requests if you are not interested in tracking these. That said if 30% of traffic is OPTIONS requests maybe you should check why that is.. Maybe it can be reduced?

trompette commented 6 years ago

You could also do this in a request listener to ignore all OPTIONS requests.

That is exactly what we did, but we thought it would be nice to be part of NelmioCorsBundle.

An alternative to the configuration option could be a README addition. I can help by openning a PR.

If 30% of traffic is OPTIONS requests maybe you should check why that is.

Our API is mostly authenticated routes, that is why.

Actually we were surprised that it was only 30%.

Seldaek commented 6 years ago

I'd rather a README PR because adding newrelic specific stuff in the code isn't so great IMO..