Skip to content

Commit

Permalink
Fix delete subription and msg responses
Browse files Browse the repository at this point in the history
Signed-off-by: Aneesh Puttur <aneeshputtur@gmail.com>
  • Loading branch information
aneeshkp committed Feb 28, 2023
1 parent 881cc84 commit 42df6b7
Show file tree
Hide file tree
Showing 10 changed files with 396 additions and 131 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,11 @@ test:
gha:
go test ./... --tags=unittests -coverprofile=cover.out

fmt: ## Go fmt your code
hack/gofmt.sh

fmt-code: ## Run go fmt against code.
go fmt ./...

vet: ## Run go vet against code.
go vet ./...
92 changes: 46 additions & 46 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,75 +28,75 @@ These metrics describe the status of the cloud native events, publisher and subs

All these metrics are prefixed with `cne_`

| Name | Description | Type |
|-------------------------------------------------------|----------------------------------------------------------|---------|
| cne_amqp_events_received | Metric to get number of events received by the transport. | Gauge |
| cne_amqp_events_published | Metric to get number of events published by the transport. | Gauge |
| cne_amqp_connection_reset | Metric to get number of connection resets. | Gauge |
| cne_amqp_sender | Metric to get number of sender created. | Gauge |
| cne_amqp_receiver | Metric to get number of receiver created. | Gauge |
| cne_amqp_status_check_published | Metric to get number of status check published by the transport | Gauge |
| Name | Description | Type |
|-----------------------------|----------------------------------------------------------|---------|
| cne_transport_events_received | Metric to get number of events received by the transport. | Gauge |
| cne_transport_events_published | Metric to get number of events published by the transport. | Gauge |
| cne_transport_connection_reset | Metric to get number of connection resets. | Gauge |
| cne_transport_sender | Metric to get number of sender created. | Gauge |
| cne_transport_receiver | Metric to get number of receiver created. | Gauge |
| cne_transport_status_check_published | Metric to get number of status check published by the transport | Gauge |

`cne_amqp_events_received` - The number of events received by the amqp protocol, and their status by address.
`cne_transport_events_received` - The number of events received by the transport protocol, and their status by address.

Example
```json
# HELP cne_amqp_events_received Metric to get number of events received by the transport
# TYPE cne_amqp_events_received gauge
cne_amqp_events_received{address="/news-service/finance",status="success"} 8
cne_amqp_events_received{address="/news-service/sports",status="success"} 8
```
# HELP cne_transport_events_received Metric to get number of events received by the transport
# TYPE cne_transport_events_received gauge
cne_transport_events_received{address="/news-service/finance",status="success"} 8
cne_transport_events_received{address="/news-service/sports",status="success"} 8
```

`cne_amqp_events_published` - This metrics indicates number of events that were published via amqp , grouped by address and status.
`cne_transport_events_published` - This metrics indicates number of events that were published via transport , grouped by address and status.

Example
```json
# HELP cne_amqp_events_published Metric to get number of events published by the transport
# TYPE cne_amqp_events_published gauge
cne_amqp_events_published{address="/news-service/finance",status="connection reset"} 1
cne_amqp_events_published{address="/news-service/finance",status="success"} 8
cne_amqp_events_published{address="/news-service/sports",status="connection reset"} 1
cne_amqp_events_published{address="/news-service/sports",status="success"} 8
```
# HELP cne_transport_events_published Metric to get number of events published by the transport
# TYPE cne_transport_events_published gauge
cne_transport_events_published{address="/news-service/finance",status="connection reset"} 1
cne_transport_events_published{address="/news-service/finance",status="success"} 8
cne_transport_events_published{address="/news-service/sports",status="connection reset"} 1
cne_transport_events_published{address="/news-service/sports",status="success"} 8
```

`cne_amqp_connection_reset` - This metrics indicates number of types amqp connection was reset
`cne_transport_connection_reset` - This metrics indicates number of types transport connection was reset

Example
```json
# HELP cne_amqp_connection_reset Metric to get number of connection resets
# TYPE cne_amqp_connection_reset gauge
cne_amqp_connection_reset 1
```
# HELP cne_transport_connection_reset Metric to get number of connection resets
# TYPE cne_transport_connection_reset gauge
cne_transport_connection_reset 1
```

`cne_amqp_sender` - This metrics indicates number of amqp sender objects were created , grouped by address and status.
`cne_transport_sender` - This metrics indicates number of transport sender objects were created , grouped by address and status.

Example
```json
# HELP cne_amqp_sender Metric to get number of sender active
# TYPE cne_amqp_sender gauge
cne_amqp_sender{address="/news-service/finance",status="active"} 1
cne_amqp_sender{address="/news-service/sports",status="active"} 1
```
# HELP cne_transport_sender Metric to get number of sender active
# TYPE cne_transport_sender gauge
cne_transport_sender{address="/news-service/finance",status="active"} 1
cne_transport_sender{address="/news-service/sports",status="active"} 1
```

`cne_amqp_receiver` - This metrics indicates number of amqp receiver objects were created, grouped by address and status.
`cne_transport_receiver` - This metrics indicates number of transport receiver objects were created, grouped by address and status.

Example
```json
# HELP cne_amqp_receiver Metric to get number of receiver active
# TYPE cne_amqp_receiver gauge
cne_amqp_receiver{address="/news-service/finance",status="active"} 1
cne_amqp_receiver{address="/news-service/sports",status="active"} 1
```
# HELP cne_transport_receiver Metric to get number of receiver active
# TYPE cne_transport_receiver gauge
cne_transport_receiver{address="/news-service/finance",status="active"} 1
cne_transport_receiver{address="/news-service/sports",status="active"} 1
```

`cne_amqp_status_check_published` - This metrics indicates status check that were published via amqp , grouped by address and status.
`cne_transport_status_check_published` - This metrics indicates status check that were published via transport , grouped by address and status.

Example
```json
# HELP cne_amqp_status_check_published Metric to get number of status check published by the transport
# TYPE cne_amqp_status_check_published gauge
cne_amqp_status_check_published{address="/news-service/finance/status",status="failed"} 1
cne_amqp_status_check_published{address="/news-service/sports/status",status="connection reset"} 1
cne_amqp_status_check_published{address="/news-service/sports/status",status="success"} 1
```
# HELP cne_transport_status_check_published Metric to get number of status check published by the transport
# TYPE cne_transport_status_check_published gauge
cne_transport_status_check_published{address="/news-service/finance/status",status="failed"} 1
cne_transport_status_check_published{address="/news-service/sports/status",status="connection reset"} 1
cne_transport_status_check_published{address="/news-service/sports/status",status="success"} 1
```


Expand Down
62 changes: 31 additions & 31 deletions pkg/localmetrics/localmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,89 +34,89 @@ const (

var (

//amqpEventReceivedCount ... Total no of events received by the transport
amqpEventReceivedCount = prometheus.NewGaugeVec(
//transportEventReceivedCount ... Total no of events received by the transport
transportEventReceivedCount = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "cne_amqp_events_received",
Help: "Metric to get number of events received by the transport",
Name: "cne_transport_events_received",
Help: "Metric to get number of events received by the transport",
}, []string{"address", "status"})
//amqpEventPublishedCount ... Total no of events published by the transport
amqpEventPublishedCount = prometheus.NewGaugeVec(
//transportEventPublishedCount ... Total no of events published by the transport
transportEventPublishedCount = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "cne_amqp_events_published",
Name: "cne_transport_events_published",
Help: "Metric to get number of events published by the transport",
}, []string{"address", "status"})

//amqpConnectionResetCount ... Total no of connection resets
amqpConnectionResetCount = prometheus.NewGaugeVec(
//transportConnectionResetCount ... Total no of connection resets
transportConnectionResetCount = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "cne_amqp_connection_reset",
Name: "cne_transport_connection_reset",
Help: "Metric to get number of connection resets",
}, []string{})

//amqpSenderCount ... Total no of events published by the transport
amqpSenderCount = prometheus.NewGaugeVec(
//transportSenderCount ... Total no of events published by the transport
transportSenderCount = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "cne_amqp_sender",
Name: "cne_transport_sender",
Help: "Metric to get number of sender created",
}, []string{"address", "status"})

//amqpReceiverCount ... Total no of events published by the transport
amqpReceiverCount = prometheus.NewGaugeVec(
//transportReceiverCount ... Total no of events published by the transport
transportReceiverCount = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "cne_amqp_receiver",
Name: "cne_transport_receiver",
Help: "Metric to get number of receiver created",
}, []string{"address", "status"})

//amqpStatusCheckCount ... Total no of status check received by the transport
amqpStatusCheckCount = prometheus.NewGaugeVec(
//transportStatusCheckCount ... Total no of status check received by the transport
transportStatusCheckCount = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "cne_amqp_status_check_published",
Name: "cne_transport_status_check_published",
Help: "Metric to get number of status check published by the transport",
}, []string{"address", "status"})
)

// RegisterMetrics ...
func RegisterMetrics() {
prometheus.MustRegister(amqpEventReceivedCount)
prometheus.MustRegister(amqpEventPublishedCount)
prometheus.MustRegister(amqpConnectionResetCount)
prometheus.MustRegister(amqpSenderCount)
prometheus.MustRegister(amqpReceiverCount)
prometheus.MustRegister(amqpStatusCheckCount)
prometheus.MustRegister(transportEventReceivedCount)
prometheus.MustRegister(transportEventPublishedCount)
prometheus.MustRegister(transportConnectionResetCount)
prometheus.MustRegister(transportSenderCount)
prometheus.MustRegister(transportReceiverCount)
prometheus.MustRegister(transportStatusCheckCount)
}

// UpdateTransportConnectionResetCount ...
func UpdateTransportConnectionResetCount(val int) {
amqpConnectionResetCount.With(prometheus.Labels{}).Add(float64(val))
transportConnectionResetCount.With(prometheus.Labels{}).Add(float64(val))
}

// UpdateEventReceivedCount ...
func UpdateEventReceivedCount(address string, status MetricStatus, val int) {
amqpEventReceivedCount.With(
transportEventReceivedCount.With(
prometheus.Labels{"address": address, "status": string(status)}).Add(float64(val))
}

// UpdateEventCreatedCount ...
func UpdateEventCreatedCount(address string, status MetricStatus, val int) {
amqpEventPublishedCount.With(
transportEventPublishedCount.With(
prometheus.Labels{"address": address, "status": string(status)}).Add(float64(val))
}

// UpdateStatusCheckCount ...
func UpdateStatusCheckCount(address string, status MetricStatus, val int) {
amqpEventPublishedCount.With(
transportEventPublishedCount.With(
prometheus.Labels{"address": address, "status": string(status)}).Add(float64(val))
}

// UpdateSenderCreatedCount ...
func UpdateSenderCreatedCount(address string, status MetricStatus, val int) {
amqpSenderCount.With(
transportSenderCount.With(
prometheus.Labels{"address": address, "status": string(status)}).Add(float64(val))
}

// UpdateReceiverCreatedCount ...
func UpdateReceiverCreatedCount(address string, status MetricStatus, val int) {
amqpReceiverCount.With(
transportReceiverCount.With(
prometheus.Labels{"address": address, "status": string(status)}).Add(float64(val))
}
Loading

0 comments on commit 42df6b7

Please sign in to comment.