<commit_before>package eventmaster

import (
	"time"

	"github.com/pkg/errors"
	"github.com/prometheus/client_golang/prometheus"
)

var (
	httpReqLatencies = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Namespace: "eventmaster",
		Subsystem: "http_server",
		Name:      "request_latency_ms",
		Help:      "Latency in ms of http requests grouped by req path",
		Buckets:   prometheus.ExponentialBuckets(1, 10, 10),
	}, []string{"path"})

	reqLatency = prometheus.NewSummaryVec(prometheus.SummaryOpts{
		Name: "http_request_latency_ms",
		Help: "http request duration (ms).",
	}, []string{"path"})

	httpReqCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "eventmaster",
		Subsystem: "http_server",
		Name:      "request_total",
		Help:      "The count of http requests received grouped by req path",
	}, []string{"path"})

	httpRespCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "eventmaster",
		Subsystem: "http_server",
		Name:      "response_total",
		Help:      "The count of http responses issued classified by code and api endpoint",
	}, []string{"path", "code"})

	grpcReqLatencies = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Namespace: "eventmaster",
		Subsystem: "grpc_server",
		Name:      "request_latency",
		Help:      "Latency of grpc requests grouped by method name",
	}, []string{"method"})

	grpcReqCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "eventmaster",
		Subsystem: "grpc_server",
		Name:      "request_total",
		Help:      "The count of grpc requests received grouped by method name",
	}, []string{"method"})

	grpcRespCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "eventmaster",
		Subsystem: "grpc_server",
		Name:      "response_total",
		Help:      "The count of grpc responses issued classified by method name and success",
	}, []string{"method", "success"})

	rsyslogReqLatencies = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Namespace: "eventmaster",
		Subsystem: "rsyslog_server",
		Name:      "request_latency",
		Help:      "Latency of rsyslog requests",
	}, []string{})

	rsyslogReqCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "eventmaster",
		Subsystem: "rsyslog_server",
		Name:      "request_total",
		Help:      "The count of rsyslog requests received",
	}, []string{})

	eventStoreTimer = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Namespace: "eventmaster",
		Subsystem: "event_store",
		Name:      "method_time",
		Help:      "Time of event store methods by method name",
	}, []string{"method"})

	eventStoreDbErrCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "eventmaster",
		Subsystem: "event_store",
		Name:      "db_error",
		Help:      "The count of db errors by db name and type of operation",
	}, []string{"db_name", "operation"})
)

// RegisterPromMetrics registers all the metrics that eventmanger uses.
func RegisterPromMetrics() error {
	regErr := prometheus.Register(httpReqLatencies)
	if regErr != nil {
		if c, ok := regErr.(prometheus.AlreadyRegisteredError); ok {
			httpReqLatencies = c.ExistingCollector.(*prometheus.HistogramVec)
		} else {
			return regErr
		}
	}

	if err := prometheus.Register(reqLatency); err != nil {
		return errors.Wrap(err, "registering request latency")
	}

	regErr = prometheus.Register(httpReqCounter)
	if regErr != nil {
		if c, ok := regErr.(prometheus.AlreadyRegisteredError); ok {
			httpReqCounter = c.ExistingCollector.(*prometheus.CounterVec)
		} else {
			return regErr
		}
	}

	regErr = prometheus.Register(httpRespCounter)
	if regErr != nil {
		if c, ok := regErr.(prometheus.AlreadyRegisteredError); ok {
			httpRespCounter = c.ExistingCollector.(*prometheus.CounterVec)
		} else {
			return regErr
		}
	}

	regErr = prometheus.Register(grpcReqLatencies)
	if regErr != nil {
		if c, ok := regErr.(prometheus.AlreadyRegisteredError); ok {
			grpcReqLatencies = c.ExistingCollector.(*prometheus.HistogramVec)
		} else {
			return regErr
		}
	}

	regErr = prometheus.Register(grpcReqCounter)
	if regErr != nil {
		if c, ok := regErr.(prometheus.AlreadyRegisteredError); ok {
			grpcReqCounter = c.ExistingCollector.(*prometheus.CounterVec)
		} else {
			return regErr
		}
	}
<commit_msg>Remove http request counter<commit_after>package eventmaster

import (
	"time"

	"github.com/pkg/errors"
	"github.com/prometheus/client_golang/prometheus"
)

var (
	httpReqLatencies = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Namespace: "eventmaster",
		Subsystem: "http_server",
		Name:      "request_latency_ms",
		Help:      "Latency in ms of http requests grouped by req path",
		Buckets:   prometheus.ExponentialBuckets(1, 10, 10),
	}, []string{"path"})

	reqLatency = prometheus.NewSummaryVec(prometheus.SummaryOpts{
		Name: "http_request_latency_ms",
		Help: "http request duration (ms).",
	}, []string{"path"})

	httpRespCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "eventmaster",
		Subsystem: "http_server",
		Name:      "response_total",
		Help:      "The count of http responses issued classified by code and api endpoint",
	}, []string{"path", "code"})

	grpcReqLatencies = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Namespace: "eventmaster",
		Subsystem: "grpc_server",
		Name:      "request_latency",
		Help:      "Latency of grpc requests grouped by method name",
	}, []string{"method"})

	grpcReqCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "eventmaster",
		Subsystem: "grpc_server",
		Name:      "request_total",
		Help:      "The count of grpc requests received grouped by method name",
	}, []string{"method"})

	grpcRespCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "eventmaster",
		Subsystem: "grpc_server",
		Name:      "response_total",
		Help:      "The count of grpc responses issued classified by method name and success",
	}, []string{"method", "success"})

	rsyslogReqLatencies = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Namespace: "eventmaster",
		Subsystem: "rsyslog_server",
		Name:      "request_latency",
		Help:      "Latency of rsyslog requests",
	}, []string{})

	rsyslogReqCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "eventmaster",
		Subsystem: "rsyslog_server",
		Name:      "request_total",
		Help:      "The count of rsyslog requests received",
	}, []string{})

	eventStoreTimer = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Namespace: "eventmaster",
		Subsystem: "event_store",
		Name:      "method_time",
		Help:      "Time of event store methods by method name",
	}, []string{"method"})

	eventStoreDbErrCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "eventmaster",
		Subsystem: "event_store",
		Name:      "db_error",
		Help:      "The count of db errors by db name and type of operation",
	}, []string{"db_name", "operation"})
)

// RegisterPromMetrics registers all the metrics that eventmanger uses.
func RegisterPromMetrics() error {
	regErr := prometheus.Register(httpReqLatencies)
	if regErr != nil {
		if c, ok := regErr.(prometheus.AlreadyRegisteredError); ok {
			httpReqLatencies = c.ExistingCollector.(*prometheus.HistogramVec)
		} else {
			return regErr
		}
	}

	if err := prometheus.Register(reqLatency); err != nil {
		return errors.Wrap(err, "registering request latency")
	}

	regErr = prometheus.Register(httpRespCounter)
	if regErr != nil {
		if c, ok := regErr.(prometheus.AlreadyRegisteredError); ok {
			httpRespCounter = c.ExistingCollector.(*prometheus.CounterVec)
		} else {
			return regErr
		}
	}

	regErr = prometheus.Register(grpcReqLatencies)
	if regErr != nil {
		if c, ok := regErr.(prometheus.AlreadyRegisteredError); ok {
			grpcReqLatencies = c.ExistingCollector.(*prometheus.HistogramVec)
		} else {
			return regErr
		}
	}

	regErr = prometheus.Register(grpcReqCounter)
	if regErr != nil {
		if c, ok := regErr.(prometheus.AlreadyRegisteredError); ok {
			grpcReqCounter = c.ExistingCollector.(*prometheus.CounterVec)
		} else {
			return regErr
		}
	}

{'fraction_non_alphanumeric': 0.12018280632411067, 'fraction_numerical': 0.0012351778656126482, 'mean_word_length': 4.568775790921595, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5851948', 'n_tokens_mistral': 2849, 'n_tokens_neox': 2576, 'n_words': 592}