Closed ryanb93 closed 5 years ago
Talked this over with a teammate, and we're going to look into adding this functionality to the EmbeddedHttpServer
.
Are there any plans to generalize this behavior for maybe user defined modules? I ran into a few cases where I am running into the same issue with the modules I have created when I try to use them across multiple test files & src
@sinanspd I'm not sure what issues you are running into as the StatsReceiver is the only instance that was bound unchangeably by the testing framework. Have you looked at the documentation around testing? Specifically the OverrideModules? https://twitter.github.io/finatra/user-guide/testing/override_modules.html
If using a custom
StatsReceiver
in production, is it not possible to use it in tests due toEmbeddedHttpServer
overriding it with anInMemoryStatsReceiver
.Given a custom StatsReceiver has been defined, such as using the finagle-metrics library. When the application is started using
EmbeddedHttpServer
the following code is executed:This overrides the
injector.instance[StatsReceiver]
in the application with anInMemoryStatsReceiver
.If you try and override it yourself
The following error is thrown:
Our production code is written to use the codahale
MetricsRegistry
directly, which is then shared with theMetricsStatsReceiver
wrapper. When we hit our custom/metrics
endpoint in tests, which prints theMetricsRegistry
out to JSON, we can see our application metrics however we are missing the Finatra specific metrics, for exampleroute.endpoint.status.200
and all thejvm.
metrics.This only happens in testing but makes it hard to verify production behaviour without starting the application manually and hitting the endpoint (then everything shows as expected).
There should be a way to disable the
InMemoryStatsReceiverModule
being loaded and to use the one defined in the application.