Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent prefix for system events and metrics. Closes #425 #486

Merged
merged 3 commits into from
Jul 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/system-events-and-plugin-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
System Events are special type of events emitted by the Event Gateway instance internally. They are emitted on each stage
of event processing flow starting from receiving event to function invocation end. Those events are:

* `gateway.event.received` - the event is emitted when an event was received by Events API. Data fields:
* `eventgateway.event.received` - the event is emitted when an event was received by Events API. Data fields:
* `event` - event payload
* `path` - Events API path
* `headers` - HTTP request headers
* `gateway.function.invoking` - the event emitted before invoking a function. Data fields:
* `eventgateway.function.invoking` - the event emitted before invoking a function. Data fields:
* `event` - event payload
* `functionId` - registered function ID
* `gateway.function.invoked` - the event emitted after successful function invocation. Data fields:
* `eventgateway.function.invoked` - the event emitted after successful function invocation. Data fields:
* `event` - event payload
* `functionId` - registered function ID
* `result` - function response
* `gateway.function.invocationFailed` - the event emitted after failed function invocation. Data fields:
* `eventgateway.function.invocationFailed` - the event emitted after failed function invocation. Data fields:
* `event` - event payload
* `functionId` - registered function ID
* `error` - invocation error
Expand Down
2 changes: 1 addition & 1 deletion event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (e *Event) Validate() error {

// IsSystem indicates if the event is a system event.
func (e *Event) IsSystem() bool {
return strings.HasPrefix(string(e.EventType), "gateway.")
return strings.HasPrefix(string(e.EventType), "eventgateway.")
}

// MarshalLogObject is a part of zapcore.ObjectMarshaler interface
Expand Down
8 changes: 4 additions & 4 deletions event/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

// SystemEventReceivedType is a system event emitted when the Event Gateway receives an event.
const SystemEventReceivedType = TypeName("gateway.event.received")
const SystemEventReceivedType = TypeName("eventgateway.event.received")

// SystemEventReceivedData struct.
type SystemEventReceivedData struct {
Expand All @@ -15,7 +15,7 @@ type SystemEventReceivedData struct {
}

// SystemFunctionInvokingType is a system event emitted before invoking a function.
const SystemFunctionInvokingType = TypeName("gateway.function.invoking")
const SystemFunctionInvokingType = TypeName("eventgateway.function.invoking")

// SystemFunctionInvokingData struct.
type SystemFunctionInvokingData struct {
Expand All @@ -25,7 +25,7 @@ type SystemFunctionInvokingData struct {
}

// SystemFunctionInvokedType is a system event emitted after successful function invocation.
const SystemFunctionInvokedType = TypeName("gateway.function.invoked")
const SystemFunctionInvokedType = TypeName("eventgateway.function.invoked")

// SystemFunctionInvokedData struct.
type SystemFunctionInvokedData struct {
Expand All @@ -36,7 +36,7 @@ type SystemFunctionInvokedData struct {
}

// SystemFunctionInvocationFailedType is a system event emitted after successful function invocation.
const SystemFunctionInvocationFailedType = TypeName("gateway.function.invocationFailed")
const SystemFunctionInvocationFailedType = TypeName("eventgateway.function.invocationFailed")

// SystemFunctionInvocationFailedData struct.
type SystemFunctionInvocationFailedData struct {
Expand Down
12 changes: 6 additions & 6 deletions httpapi/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func init() {

var metricEventTypes = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "gateway",
Namespace: "eventgateway",
Subsystem: "eventtypes",
Name: "total",
Help: "Gauge of created event types count.",
Expand All @@ -28,7 +28,7 @@ var metricEventTypes = prometheus.NewGaugeVec(

var metricFunctions = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "gateway",
Namespace: "eventgateway",
Subsystem: "functions",
Name: "total",
Help: "Gauge of registered functions count.",
Expand All @@ -38,7 +38,7 @@ var metricFunctions = prometheus.NewGaugeVec(

var metricSubscriptions = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "gateway",
Namespace: "eventgateway",
Subsystem: "subscriptions",
Name: "total",
Help: "Gauge of created subscriptions count.",
Expand All @@ -48,7 +48,7 @@ var metricSubscriptions = prometheus.NewGaugeVec(

var metricCORS = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "gateway",
Namespace: "eventgateway",
Subsystem: "cors",
Name: "total",
Help: "Gauge of created CORS configurations count.",
Expand All @@ -58,15 +58,15 @@ var metricCORS = prometheus.NewGaugeVec(

var metricConfigRequests = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "gateway",
Namespace: "eventgateway",
Subsystem: "config",
Name: "requests_total",
Help: "Total of Config API requests.",
}, []string{"space", "resource", "operation"})

var metricConfigRequestDuration = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "gateway",
Namespace: "eventgateway",
Subsystem: "config",
Name: "request_duration_seconds",
Help: "Bucketed histogram of request duration of Config API requests",
Expand Down
10 changes: 5 additions & 5 deletions router/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,39 @@ func init() {

var metricEventsReceived = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "gateway",
Namespace: "eventgateway",
Subsystem: "events",
Name: "received_total",
Help: "Total of events received.",
}, []string{"space", "type"})

var metricEventsProcessed = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "gateway",
Namespace: "eventgateway",
Subsystem: "events",
Name: "processed_total",
Help: "Total of processed events.",
}, []string{"space", "type"})

var metricEventsDropped = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "gateway",
Namespace: "eventgateway",
Subsystem: "events",
Name: "dropped_total",
Help: "Total of events dropped due to insufficient processing power.",
}, []string{"space", "type"})

var metricBacklog = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: "gateway",
Namespace: "eventgateway",
Subsystem: "events",
Name: "backlog",
Help: "Gauge of asynchronous events count waiting to be processed.",
})

var metricProcessingDuration = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "gateway",
Namespace: "eventgateway",
Subsystem: "events",
Name: "custom_processing_seconds",
Help: "Bucketed histogram of processing duration of an event. " +
Expand Down
2 changes: 1 addition & 1 deletion router/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestRouterServeHTTP(t *testing.T) {
router := setupTestRouter(target)

req, _ := http.NewRequest(http.MethodPost, "/", nil)
req.Header.Set("Event", "gateway.something")
req.Header.Set("Event", "eventgateway.something")
recorder := httptest.NewRecorder()
router.ServeHTTP(recorder, req)

Expand Down