Skip to content

Prometheus-net is an unnecessary dependency #1525

Closed
@rwkarg

Description

@rwkarg

Describe the bug
This package references prometheus-net for metrics but that is not a core function of this package.
This can lead to problems where a user has an older version of Prometheus server running on a version that can't accept metrics from the version of prometheus-net reference by this package. This has happened with an older (but not too old) version of Promethus and prometheus-net referenced in KubernetesClient 8.x. The new prometheus-net version includes exemplars which leads to the Prometheus server not accepting the published metrics. Users can't force using an older version of prometheus-net explicitly because it is binary incompatible with the version KubernetesClient was built with and will lead to runtime exceptions and crashing.

Ideally, there would have been a separate package for KubernetesClient.Prometheus that could optionally pulled in to get metrics.

Now however, there are .NET Metrics available without needing to pull in any additional dependency (other than the System package System.Diagnostics.DiagnosticSource) and then users of KubernetesClient are free to use anything that integrates with that common interface (dotnet-counters, OpenTelemetry w/ Prometheus exporter, OpenTelemetry w/ OTLP exporter, directly with a MeterListener). This allows for a no-dependency way to collect metrics and a common interface to achieve the existing behavior (Prometheus exposition) or a variety of other exports that the users' applications are already using. This also means that the user is in control of the version of any additional, non-core dependencies like exporting metric data. Additionally, users that do not have a framework to store metrics would not need to pull in any unnecessary packages when all they want to do is work with a Kubernetes cluster.

Example impact:
Kubernetes C# SDK Client Version
e.g. 8.x

To Reproduce
Run a Prometheus 2.42.0 server
https://github.com/prometheus/prometheus/releases/tag/v2.42.0
Run a test app using KubernetesClient 8.x+ with any exposed metrics
Scrape metrics from the test app

Expected behavior
Prometheus metrics should be stored by the Prometheus server

Actual behavior
No metrics are stored by the Prometheus server because that version of Prometheus server does not accept metrics that includes exemplars, but the version of prometheus-net that is required to be used by KubernetesClient 8.x+ includes exemplars in the data it exposes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions