-
Notifications
You must be signed in to change notification settings - Fork 836
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TUN-8701: Add metrics and adjust logs for datagram v3
Closes TUN-8701
- Loading branch information
Showing
11 changed files
with
189 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package v3 | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
) | ||
|
||
const ( | ||
namespace = "cloudflared" | ||
subsystem = "udp" | ||
) | ||
|
||
type Metrics interface { | ||
IncrementFlows() | ||
DecrementFlows() | ||
PayloadTooLarge() | ||
RetryFlowResponse() | ||
MigrateFlow() | ||
} | ||
|
||
type metrics struct { | ||
activeUDPFlows prometheus.Gauge | ||
totalUDPFlows prometheus.Counter | ||
payloadTooLarge prometheus.Counter | ||
retryFlowResponses prometheus.Counter | ||
migratedFlows prometheus.Counter | ||
} | ||
|
||
func (m *metrics) IncrementFlows() { | ||
m.totalUDPFlows.Inc() | ||
m.activeUDPFlows.Inc() | ||
} | ||
|
||
func (m *metrics) DecrementFlows() { | ||
m.activeUDPFlows.Dec() | ||
} | ||
|
||
func (m *metrics) PayloadTooLarge() { | ||
m.payloadTooLarge.Inc() | ||
} | ||
|
||
func (m *metrics) RetryFlowResponse() { | ||
m.retryFlowResponses.Inc() | ||
} | ||
|
||
func (m *metrics) MigrateFlow() { | ||
m.migratedFlows.Inc() | ||
} | ||
|
||
func NewMetrics(registerer prometheus.Registerer) Metrics { | ||
m := &metrics{ | ||
activeUDPFlows: prometheus.NewGauge(prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Subsystem: subsystem, | ||
Name: "active_flows", | ||
Help: "Concurrent count of UDP flows that are being proxied to any origin", | ||
}), | ||
totalUDPFlows: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: namespace, | ||
Subsystem: subsystem, | ||
Name: "total_flows", | ||
Help: "Total count of UDP flows that have been proxied to any origin", | ||
}), | ||
payloadTooLarge: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: namespace, | ||
Subsystem: subsystem, | ||
Name: "payload_too_large", | ||
Help: "Total count of UDP flows that have had origin payloads that are too large to proxy", | ||
}), | ||
retryFlowResponses: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: namespace, | ||
Subsystem: subsystem, | ||
Name: "retry_flow_responses", | ||
Help: "Total count of UDP flows that have had to send their registration response more than once", | ||
}), | ||
migratedFlows: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: namespace, | ||
Subsystem: subsystem, | ||
Name: "migrated_flows", | ||
Help: "Total count of UDP flows have been migrated across local connections", | ||
}), | ||
} | ||
registerer.MustRegister( | ||
m.activeUDPFlows, | ||
m.totalUDPFlows, | ||
m.payloadTooLarge, | ||
m.retryFlowResponses, | ||
m.migratedFlows, | ||
) | ||
return m | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package v3_test | ||
|
||
type noopMetrics struct{} | ||
|
||
func (noopMetrics) IncrementFlows() {} | ||
func (noopMetrics) DecrementFlows() {} | ||
func (noopMetrics) PayloadTooLarge() {} | ||
func (noopMetrics) RetryFlowResponse() {} | ||
func (noopMetrics) MigrateFlow() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.