-
Notifications
You must be signed in to change notification settings - Fork 62
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
AspNet Core Integration Tests Fail "OneTimeSetUp: System.InvalidOperationException : Configuration for DogStatsdService already performed" #69
Comments
What is the reason in general for not allowing the configuration to be changed? I have a use case which I would believe is quite common, where constant tags need to be updated and since DogStatsd is a static class and Configure cannot be called twice, the only elegant way is to write a wrapper to send tags and not use ConstantTags at all. |
This was actually a breaking change introduced in 3.3.0 - here 2a2d5fd When upgrading from 3.0.0 to 3.3.0 our code no longer works. Changes like this should not be introduced in minor version increments. |
Apologies for the delay @cjablonski76,
@jfloodnet: Indeed, breaking changes should be introduced only in major version increments. |
Maybe a method |
@avidalcarrasco : Can you provide more context on how you are using DogStatsD C# client and why you have to know if |
Hello, While doing unit test I create a fake client using the When I tried to configure it with the non-static class I have the same problem when I try to create singleton class for my instance, as I want it to be available in all the application. So having a method to check if it's already configured can avoid an exception for this cases. I made an example here Let me know if I'm doing something wrong. |
In AspNet Core when writing integration tests to call my Api, we get the exception
when our
Startup
class callsDogStatsd.Configure(statsDConfiguration);
The reason is because for aspnet core integration tests we are going to create the web server for each test, i.e.
Startup.cs
will run multiple times.I found this article describing the scenario and how they solved it for a different third party dependency: https://blog.markvincze.com/tear-down-your-asp-net-core-api-between-integration-tests/
I think we might need a way to unregister/dispose from the static instance of
DogStatsd
so that_config
kept inDogStatsdService
can be reset to null.As a workaround, I just keep a static flag in my
Startup
logic to stop from callingDogStatsd.Configure(...)
more than once. But this is a less than ideal solution in my opinion.The text was updated successfully, but these errors were encountered: