crc-org / crc

CRC is a tool to help you run containers. It manages a local OpenShift 4.x cluster, Microshift or a Podman VM optimized for testing and development purposes
https://crc.dev
Apache License 2.0
1.27k stars 242 forks source link

Add NoopClient to segment.go to allow running without telemetry in case of errors #4085

Closed redbeam closed 6 months ago

redbeam commented 8 months ago

Discussed in #4023

Currently, any error in the initialization of segment client prevents the program to run. Since it only deals with telemetry collection, it should not block other, more important parts of the program.

I propose implementing a "mock" segment client (NoopClient) that will be returned if the initialization of the real segment client fails. This way, the execution of the command is not interrupted by any error in telemetry. If this happens, the mock client will return a warning stating that telemetry will not be available in current session and its methods will do nothing.

gbraad commented 8 months ago

its methods will do nothing

logging?

redbeam commented 8 months ago

Yes, the methods can log their "inactivity". But I'm not sure if every call needs to do that. Maybe only the first would be enough.

gbraad commented 8 months ago

It depends on the state:

We might want to understand the NoopClient received the call and continues to execute the regular method. Just to be sure, we have full traceability when an error occurs. Logs are rotated anyway.