Click or drag to resize

MetricsOptions Class

Specifies options for a NeonService. This is initialized to reasonable defaults.
Inheritance Hierarchy

Namespace:  Neon.Service
Assembly:  Neon.Service (in Neon.Service.dll) Version: 2.14.0
public class MetricsOptions

The MetricsOptions type exposes the following members.

Public methodMetricsOptions
Initializes a new instance of the MetricsOptions class
Public propertyGetCollector
Optionally configures a callback that can return an additional metrics collector for the service.
Public propertyMode
Enables Prometheus and controls how metrics are published.
Public propertyPath
Specifies the URL path for the local HTTP listener that exposes metrics for scraping by Prometheus.
Public propertyPort
Specifies the TCP port for the local HTTP listener that exposes metrics for scraping by Prometheus.
Public propertyPushInterval
Specifies how often metrics will be pushed to the target Prometheus Pushgateway for Push mode. This defaults to 5 seconds.
Public propertyPushLabels
Optionally specifies additional labels to be identify the source for Push mode.
Public propertyPushUrl
Specifies the target Prometheus Pushgateway for Push mode.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodValidate
Validates the options.

These options allow developers to customize some service behaviors. This is is exposed as the MetricsOptions property and is initialized to reasonable default values. Developers may modify these options as desired before calling RunAsync(Boolean) to start their service.

Prometheus metrics capturing is disabled by default. You can change this by setting Mode to Scrape, ScrapeIgnoreErrors, or Push. The two scrape modes expect that Prometheus will be perodically reading metrics from the service via the HTTP endpoint specified by Port and Path.

Note Note
The ScrapeIgnoreErrors mode is somewhat specialized and is intended for testing environments and is not recommended for production.
Note Note

Built-in Prometheus scraping support is limited to HTTP and not HTTPS and no authentication is enforced. Pushgateway support can use HTTPS as well as HTTP, but we don't support authentication.

For more complex scenarios, just leave Mode==Disabled and configure prometheus-net yourself before calling RunAsync(Boolean). We're trying to address 80% scenarios to reduce a bit of service related boilerplate code but prometheus-net is quite easy to configure.

Note Note
For ASPNET applications, we recommend that you leave metrics collection disabled here and configure middleware to handle the metrics; this will automatically much more detailed web related metrics. You can use the standard prometheus-net middleware builder extension.
See Also