Loading
Commits on Source 5
-
Sami Hiltunen authored
NewHandlerFactory is unfortunately registering its metrics in the global registry of Prometheus client library. This also leads to its tests leaking state between different test cases as they all access the same registry. This has been worked around by applying a namespace on the metric names of each test. Isolate the tests correctly by overriding the global registry with a test specific one, and recovering the original registry at the end of the test. This way each of the tests can access have their own isolated registry no longer need namespaces to avoid conflicts. As we're no longer implicitly testing the namespace option through using it for test isolation, we add an explicit test to assert the functionality works.
-
Sami Hiltunen authored
NewHandlerFactory registers its metrics directly into the global registry for the Prometheus client library. This forces global state on applications that use the shared functionality from LabKit. Global state is discouraged as it makes testing difficult, the application code inflexible and more complex as it couples unrelated aspects of an application together. This commit adds an option to provide a custom registerer where the factory will register metrics. This way the application has an option to avoid the global state of the default registry. It would be better to leave the metric registration up to the application entirely but I've opted to stick with the existing pattern here and provide an option that fits in the existing API.
-
Andrew Newdigate authored
Add an option for providing a custom prometheus.Registerer See merge request !243 Merged-by:
Andrew Newdigate <andrew@gitlab.com>
Approved-by: Elliot Forbes <eforbes@gitlab.com> Approved-by:
Andrew Newdigate <andrew@gitlab.com>
Reviewed-by:
Sami Hiltunen <shiltunen@gitlab.com>
Co-authored-by:
Sami Hiltunen <shiltunen@gitlab.com> -
Andrew Newdigate authored
Adds WithRegisterer option to `http_round_tripper.NewFactory` to allow applications to avoid global registry state, matching the pattern introduced in c448e786 for the handler factory. This follows the style of the original commit that made similar changes to the handler, keeping it concise while explaining what was added and why.
-
João Pereira authored
feat: http-roundtripper metrics: add option for providing a custom prometheus.Registerer See merge request !248 Merged-by:
João Pereira <jpereira@gitlab.com> Approved-by:
Elliot Forbes <eforbes@gitlab.com> Approved-by:
João Pereira <jpereira@gitlab.com> Reviewed-by:
GitLab Duo <gitlab-duo@gitlab.com> Co-authored-by:
Andrew Newdigate <andrew@gitlab.com>