コード例 #1
0
        /// <summary>
        /// Configure the bus to capture metrics for publication using Prometheus.
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="configureOptions"></param>
        /// <param name="serviceName">
        /// The service name for metrics reporting, defaults to the current process main module filename
        /// </param>
        public static void UsePrometheusMetrics(this IBusFactoryConfigurator configurator,
                                                Action <PrometheusMetricsOptions> configureOptions = null,
                                                string serviceName = default)
        {
            var options = PrometheusMetricsOptions.CreateDefault();

            configureOptions?.Invoke(options);

            PrometheusMetrics.TryConfigure(GetServiceName(serviceName), options);

            configurator.ConnectConsumerConfigurationObserver(new PrometheusConsumerConfigurationObserver());
            configurator.ConnectHandlerConfigurationObserver(new PrometheusHandlerConfigurationObserver());
            configurator.ConnectSagaConfigurationObserver(new PrometheusSagaConfigurationObserver());
            configurator.ConnectActivityConfigurationObserver(new PrometheusActivityConfigurationObserver());
            configurator.ConnectEndpointConfigurationObserver(new PrometheusReceiveEndpointConfiguratorObserver());
            configurator.ConnectBusObserver(new PrometheusBusObserver());
        }
コード例 #2
0
        /// <summary>
        /// A Kill Switch monitors a receive endpoint and automatically stops and restarts the endpoint in the presence of consumer faults. The options
        /// can be configured to adjust the trip threshold, restart timeout, and exceptions that are observed by the kill switch. When configured on the bus,
        /// a kill switch is installed on every receive endpoint.
        /// </summary>
        /// <param name="configurator">The bus factory configurator</param>
        /// <param name="configure">Configure the kill switch options</param>
        public static void UseKillSwitch(this IBusFactoryConfigurator configurator, Action <KillSwitchOptions> configure = default)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            var options = new KillSwitchOptions();

            configure?.Invoke(options);

            var observer = new KillSwitchReceiveEndpointConfiguratorObserver(options);

            configurator.ConnectEndpointConfigurationObserver(observer);

            configurator.AddPipeSpecification(new ValidateOptions(options));
        }
コード例 #3
0
 public void UseHealthCheck(IBusFactoryConfigurator configurator)
 {
     configurator.ConnectBusObserver(_busHealth);
     configurator.ConnectEndpointConfigurationObserver(_busHealth);
 }