Prometheus.NetStandard
Base class for labeled instances of metrics (with all label names and label values defined).
Marks the metric as one to be published, even if it might otherwise be suppressed.
This is useful for publishing zero-valued metrics once you have loaded data on startup and determined
that there is no need to increment the value of the metric.
Subclasses must call this when their value is first set, to mark the metric as published.
Marks the metric as one to not be published.
The metric will be published when Publish() is called or the value is updated.
Removes this labeled instance from metrics.
It will no longer be published and any existing measurements/buckets will be discarded.
Labels specific to this metric instance, without any inherited static labels.
Internal for testing purposes only.
All labels that materialize on this metric instance, including inherited static labels.
Internal for testing purposes only.
Collects all the metric data rows from this collector and serializes it using the given serializer.
Subclass must check _publish and suppress output if it is false.
Creates a metric identifier, with an optional name postfix and optional extra labels.
familyname_postfix{labelkey1="labelvalue1",labelkey2="labelvalue2"}
Base class for metrics, defining the basic informative API and the internal API.
The metric name, e.g. http_requests_total.
The help text describing the metric for a human audience.
Names of the instance-specific labels (name-value pairs) that apply to this metric.
When the values are added to the names, you get a instance.
Base class for metrics collectors, providing common labeled child management functionality.
Gets the child instance that has no labels.
Gets the instance-specific label values of all labelled instances of the collector.
Values of any inherited static labels are not returned in the result.
Note that during concurrent operation, the set of values returned here
may diverge from the latest set of values used by the collector.
Set of static labels obtained from any hierarchy level (either defined in metric configuration or in registry).
For tests that want to see what label values were used when metrics were created.
Creates a new instance of the child collector type.
Maintains references to a set of collectors, from which data for metrics is collected at data export time.
Use methods on the class to add metrics to a collector registry.
To encourage good concurrency practices, registries are append-only. You can add things to them but not remove.
If you wish to remove things from the registry, create a new registry with only the things you wish to keep.
Registers an action to be called before metrics are collected.
This enables you to do last-minute updates to metric values very near the time of collection.
Callbacks will delay the metric collection, so do not make them too long or it may time out.
The callback will be executed synchronously and should not take more than a few milliseconds.
To execute longer-duration callbacks, register an asynchronous callback (Func<Task>).
If the callback throws then the entire metric collection will fail.
This will result in an appropriate HTTP error code or a skipped push, depending on type of exporter.
If multiple concurrent collections occur, the callback may be called multiple times concurrently.
Registers an action to be called before metrics are collected.
This enables you to do last-minute updates to metric values very near the time of collection.
Callbacks will delay the metric collection, so do not make them too long or it may time out.
Asynchronous callbacks will be executed concurrently and may last longer than a few milliseconds.
If the callback throws then the entire metric collection will fail.
This will result in an appropriate HTTP error code or a skipped push, depending on type of exporter.
If multiple concurrent collections occur, the callback may be called multiple times concurrently.
The set of static labels that are applied to all metrics in this registry.
Enumeration of the returned collection is thread-safe.
Defines the set of static labels to apply to all metrics in this registry.
The static labels can only be set once on startup, before adding or publishing any metrics.
Executes an action while holding a read lock on the set of static labels (provided as parameter).
Collects all metrics and exports them in text document format to the provided stream.
This method is designed to be used with custom output mechanisms that do not use an IMetricServer.
Adds a collector to the registry, returning an existing instance if one with a matching name was already registered.
Allows us to initialize (or not) the registry with the default metrics before the first collection.
Collects metrics from all the registered collectors and sends them to the specified serializer.
Executes the provided operation and increments the counter if an exception occurs. The exception is re-thrown.
If an exception filter is specified, only counts exceptions for which the filter returns true.
Executes the provided operation and increments the counter if an exception occurs. The exception is re-thrown.
If an exception filter is specified, only counts exceptions for which the filter returns true.
Executes the provided async operation and increments the counter if an exception occurs. The exception is re-thrown.
If an exception filter is specified, only counts exceptions for which the filter returns true.
Executes the provided async operation and increments the counter if an exception occurs. The exception is re-thrown.
If an exception filter is specified, only counts exceptions for which the filter returns true.
Collects basic .NET metrics about the current process. This is not meant to be an especially serious collector,
more of a producer of sample data so users of the library see something when they install it.
Registers the .NET metrics in the specified registry.
Sets the value of the gauge to the current UTC time as a Unix timestamp in seconds.
Value does not include any elapsed leap seconds because Unix timestamps do not include leap seconds.
Sets the value of the gauge to a specific moment as the UTC timezone Unix timestamp in seconds.
Value does not include any elapsed leap seconds because Unix timestamps do not include leap seconds.
Increments the value of the gauge to the current UTC time as a Unix timestamp in seconds.
Value does not include any elapsed leap seconds because Unix timestamps do not include leap seconds.
Operation is ignored if the current value is already greater.
Increments the value of the gauge to a specific moment as the UTC Unix timestamp in seconds.
Value does not include any elapsed leap seconds because Unix timestamps do not include leap seconds.
Operation is ignored if the current value is already greater.
Tracks the number of in-progress operations taking place.
Calling this increments the gauge. Disposing of the returned instance decrements it again.
It is safe to track the sum of multiple concurrent in-progress operations with the same gauge.
The histogram is thread-safe but not atomic - the sum of values and total count of events
may not add up perfectly with bucket contents if new observations are made during a collection.
Creates '' buckets, where the lowest bucket has an
upper bound of '' and each following bucket's upper bound is ''
times the previous bucket's upper bound.
The function throws if '' is 0 or negative, if '' is 0 or negative,
or if '' is less than or equal 1.
The upper bound of the lowest bucket. Must be positive.
The factor to increase the upper bound of subsequent buckets. Must be greater than 1.
The number of buckets to create. Must be positive.
Creates '' buckets, where the lowest bucket has an
upper bound of '' and each following bucket's upper bound is the upper bound of the
previous bucket, incremented by ''
The function throws if '' is 0 or negative.
The upper bound of the lowest bucket.
The width of each bucket (distance between lower and upper bound).
The number of buckets to create. Must be positive.
Custom histogram buckets to use. If null, will use Histogram.DefaultBuckets.
Child-type-specific interface implemented by all collectors, used to enable substitution in test code.
Interface implemented by all collectors, used to enable substitution in test code.
Interface shared by all labelled collector children.
Allows for substitution of CollectorRegistry in tests.
Not used by prometheus-net itself - you cannot provide your own implementation to prometheus-net code, only to your own code.
Observe multiple events with a given value.
Intended to support high frequency or batch processing use cases utilizing pre-aggregation.
Measured value.
Number of observations with this value.
Gets the sum of all observed events.
Gets the count of all observed events.
Allows for substitution of MetricFactory in tests.
Not used by prometheus-net itself - you cannot provide your own implementation to prometheus-net code, only to your own code.
A metric server exposes a Prometheus metric exporter endpoint in the background,
operating independently and serving metrics until it is instructed to stop.
Starts serving metrics.
Returns the same instance that was called (for fluent-API-style chaining).
Instructs the metric server to stop and returns a task you can await for it to stop.
Instructs the metric server to stop and waits for it to stop.
The only purpose this serves is to warn the developer when he might be accidentally introducing
new serialization-time relationships. The serialization code is very tied to the text format and
not intended to be a generic serialization mechanism.
Writes the lines that declare the metric family.
Writes a single metric in a metric family.
Flushes any pending buffers. Always call this after all your write calls.
Implemented by metric types that observe individual events with specific values.
Observes a single event with the given value.
A timer that can be used to observe a duration of elapsed time.
The observation is made either when ObserveDuration is called or when the instance is disposed of.
Observes the duration (in seconds) and returns the observed value.
The set of labels and label values associated with a metric. Used both for export and as keys.
Only the values are considered for equality purposes - the caller must ensure that
LabelValues objects with different sets of names are never compared to each other.
Always use the explicit constructor when creating an instance. This is a struct in order
to reduce heap allocations when dealing with labelled metrics, which has the consequence of
adding a default parameterless constructor. It should not be used.
Serializes to the labelkey1="labelvalue1",labelkey2="labelvalue2" label string.
This class packages the options for creating metrics into a single class (with subclasses per metric type)
for easy extensibility of the API without adding numerous method overloads whenever new options are added.
Names of all the label fields that are defined for each instance of the metric.
If null, the metric will be created without any instance-specific labels.
Before using a metric that uses instance-specific labels, .WithLabels() must be called to provide values for the labels.
The static labels to apply to all instances of this metric. These labels cannot be later overwritten.
If true, the metric will not be published until its value is first modified (regardless of the specific value).
This is useful to delay publishing gauges that get their initial values delay-loaded.
By default, metrics are published as soon as possible - if they do not use labels then they are published on
creation and if they use labels then as soon as the label values are assigned.
Adds metrics to a registry.
Counters only increase in value and reset to zero when the process restarts.
Gauges can have any numeric value and change arbitrarily.
Summaries track the trends in events over time (10 minutes by default).
Histograms track the size and number of events in buckets.
Counters only increase in value and reset to zero when the process restarts.
Gauges can have any numeric value and change arbitrarily.
Summaries track the trends in events over time (10 minutes by default).
Histograms track the size and number of events in buckets.
Base class for various metric server implementations that start an independent exporter in the background.
The expoters may either be pull-based (exposing the Prometheus API) or push-based (actively pushing to PushGateway).
A metric server that regularly pushes metrics to a Prometheus PushGateway.
Callback for when a metric push fails.
If null, a singleton HttpClient will be used.
Static class for easy creation of metrics. Acts as the entry point to the prometheus-net metrics recording API.
Some built-in metrics are registered by default in the default collector registry. This is mainly to ensure that
the library exports some metrics when installed. If these default metrics are not desired, call
to remove them before registering your own.
The default registry where all metrics are registered by default.
Creates a new registry. You may want to use multiple registries if you want to
export different sets of metrics via different exporters (e.g. on different URLs).
Returns an instance of that you can use to register metrics in a custom registry.
Counters only increase in value and reset to zero when the process restarts.
Gauges can have any numeric value and change arbitrarily.
Summaries track the trends in events over time (10 minutes by default).
Histograms track the size and number of events in buckets.
Counters only increase in value and reset to zero when the process restarts.
Gauges can have any numeric value and change arbitrarily.
Summaries track the trends in events over time (10 minutes by default).
Histograms track the size and number of events in buckets.
Suppresses the registration of the default sample metrics from the default registry.
Has no effect if not called on startup (it will not remove metrics from a registry already in use).
Implementation of a Prometheus exporter that serves metrics using HttpListener.
This is a stand-alone exporter for apps that do not already have an HTTP server included.
Only requests that match this predicate will be served by the metric server. This allows you to add authorization checks.
By default (if null), all requests are served.
Signals to the metrics server that metrics are currently unavailable. Thrown from "before collect" callbacks.
This causes the entire export operation to fail - even if some metrics are available, they will not be exported.
The exception message will be delivered as the HTTP response body by the exporter.
Client library guidelines say that the summary should default to not measuring quantiles.
https://prometheus.io/docs/instrumenting/writing_clientlibs/#summary
For unit tests only
Pairs of quantiles and allowed error values (epsilon).
For example, a quantile of 0.95 with an epsilon of 0.01 means the calculated value
will be between the 94th and 96th quantile.
If null, no quantiles will be calculated!
Time span over which to calculate the summary.
Number of buckets used to control measurement expiration.
Buffer size limit. Use multiples of 500 to avoid waste, as internal buffers use that size.
Does NOT take ownership of the stream - caller remains the boss.
Sets the value to this, unless the existing value is already greater.
Sets the value to this, unless the existing value is already smaller.
Enables you to easily report elapsed seconds in the value of an observer.
Dispose of the returned instance to report the elapsed duration.
Enables you to easily report elapsed seconds in the value of a gauge.
Dispose of the returned instance to report the elapsed duration.
Enables you to easily report elapsed seconds in the value of a counter.
The duration (in seconds) will be added to the value of the counter.
Dispose of the returned instance to report the elapsed duration.
Provides an implementation that exposes an output
which can be written to directly. The ability to push data to the output stream differs from the
where data is pulled and not pushed.
Initializes a new instance of the class with the given .
When this method is called, it calls the action provided in the constructor with the output
stream to write to. Once the action has completed its work it closes the stream which will
close this content instance and complete the HTTP request or response.
The to which to write.
The associated .
A instance that is asynchronously serializing the object's content.
Computes the length of the stream if possible.
The computed length of the stream.
true if the length has been computed; otherwise false.