Skip to content

Commit 54108e4

Browse files
feat: Available set eventTypes when create alerts. (#69)
When you create dataset: events. By default he create eventTypes:['errors']. So you can't create alerts with event_type: default or both.
1 parent 42e3d51 commit 54108e4

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

sentry/metric_alerts.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type MetricAlert struct {
1313
Name *string `json:"name,omitempty"`
1414
Environment *string `json:"environment,omitempty"`
1515
DataSet *string `json:"dataset,omitempty"`
16+
EventTypes []string `json:"eventTypes,omitempty"`
1617
Query *string `json:"query,omitempty"`
1718
Aggregate *string `json:"aggregate,omitempty"`
1819
TimeWindow *float64 `json:"timeWindow,omitempty"`

sentry/metric_alerts_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func TestMetricAlertService_List(t *testing.T) {
2424
"name": "pump-station-alert",
2525
"environment": "production",
2626
"dataset": "transactions",
27+
"eventTypes": ["transaction"],
2728
"query": "http.url:http://service/unreadmessages",
2829
"aggregate": "p50(transaction.duration)",
2930
"thresholdType": 0,
@@ -75,6 +76,7 @@ func TestMetricAlertService_List(t *testing.T) {
7576
DataSet: String("transactions"),
7677
Query: String("http.url:http://service/unreadmessages"),
7778
Aggregate: String("p50(transaction.duration)"),
79+
EventTypes: []string{"transaction"},
7880
ThresholdType: Int(0),
7981
ResolveThreshold: Float64(100.0),
8082
TimeWindow: Float64(5.0),
@@ -123,6 +125,7 @@ func TestMetricAlertService_Get(t *testing.T) {
123125
"name": "pump-station-alert",
124126
"environment": "production",
125127
"dataset": "transactions",
128+
"eventTypes": ["transaction"],
126129
"query": "http.url:http://service/unreadmessages",
127130
"aggregate": "p50(transaction.duration)",
128131
"timeWindow": 10,
@@ -171,6 +174,7 @@ func TestMetricAlertService_Get(t *testing.T) {
171174
Name: String("pump-station-alert"),
172175
Environment: String("production"),
173176
DataSet: String("transactions"),
177+
EventTypes: []string{"transaction"},
174178
Query: String("http.url:http://service/unreadmessages"),
175179
Aggregate: String("p50(transaction.duration)"),
176180
TimeWindow: Float64(10),
@@ -220,6 +224,7 @@ func TestMetricAlertService_Create(t *testing.T) {
220224
"name": "pump-station-alert",
221225
"environment": "production",
222226
"dataset": "transactions",
227+
"eventTypes": ["transaction"],
223228
"query": "http.url:http://service/unreadmessages",
224229
"aggregate": "p50(transaction.duration)",
225230
"timeWindow": 10,
@@ -304,6 +309,7 @@ func TestMetricAlertService_Create(t *testing.T) {
304309
Name: String("pump-station-alert"),
305310
Environment: String("production"),
306311
DataSet: String("transactions"),
312+
EventTypes: []string{"transaction"},
307313
Query: String("http.url:http://service/unreadmessages"),
308314
Aggregate: String("p50(transaction.duration)"),
309315
ThresholdType: Int(0),
@@ -405,6 +411,7 @@ func TestMetricAlertService_Update(t *testing.T) {
405411
"name": "pump-station-alert",
406412
"environment": "production",
407413
"dataset": "transactions",
414+
"eventTypes": ["transaction"],
408415
"query": "http.url:http://service/unreadmessages",
409416
"aggregate": "p50(transaction.duration)",
410417
"timeWindow": 10,
@@ -453,6 +460,7 @@ func TestMetricAlertService_Update(t *testing.T) {
453460
Name: String("pump-station-alert"),
454461
Environment: String("production"),
455462
DataSet: String("transactions"),
463+
EventTypes: []string{"transaction"},
456464
Query: String("http.url:http://service/unreadmessages"),
457465
Aggregate: String("p50(transaction.duration)"),
458466
ThresholdType: Int(0),

0 commit comments

Comments
 (0)