Open viralpraxis opened 4 months ago
not sure about this, I guess if it simplifies some of the test suite then fine
The following client stub
# frozen_string_literal: true
require "prometheus_exporter/client"
module PrometheusExporter
class ClientStub < PrometheusExporter::Client
def send(_json); end
def process_queue; end
def stop(wait_timeout_seconds: 0); end
end
end
seems to work fine -- in our case, in dev/test environments prometheus_exporter
is loaded and PrometheusExprorter::Client.default
is set to PrometheusExporter::ClientStub.new
. We also don't see any significant test suite slow down. In fact, it's OK for us to have this stub in our codebase (not in the gem itself). Should I open PR with these changes? If not, feel free to close this issue. I hope if someone tries to solve the same problem this snippet will be helpful.
you can send a PR I guess.
Could someone take a look, please?
Hey!
I believe it would be beneficial to have a no-op implementation of PrometheusExporter::Client for use in test environments. This would allow us to avoid sending metrics during tests while maintaining the same interface.
I believe we could implement a stub client like the following:
If this idea is deemed appropriate, I'd be happy to create a pull request with the implementation.