Skip to content

Commit

Permalink
feat: Adds support for comparison_delta to sentry_metric_alert (#441
Browse files Browse the repository at this point in the history
)
  • Loading branch information
agadzik authored May 16, 2024
1 parent bf68995 commit d5d88a6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-mux v0.16.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0
github.com/jianyuan/go-sentry/v2 v2.8.0
github.com/jianyuan/go-sentry/v2 v2.8.1
golang.org/x/oauth2 v0.20.0
golang.org/x/sync v0.7.0
)
Expand Down
8 changes: 8 additions & 0 deletions sentry/resource_sentry_metric_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ func resourceSentryMetricAlert() *schema.Resource {
Optional: true,
Description: "The value at which the Alert rule resolves",
},
"comparison_delta": {
Type: schema.TypeFloat,
Optional: true,
Description: "An optional int representing the time delta to use as the comparison period, in minutes. Required when using a percentage change threshold",
},
"trigger": {
Type: schema.TypeList,
Required: true,
Expand Down Expand Up @@ -190,6 +195,9 @@ func resourceSentryMetricAlertObject(d *schema.ResourceData) *sentry.MetricAlert
if v, ok := d.GetOk("resolve_threshold"); ok {
alert.ResolveThreshold = sentry.Float64(v.(float64))
}
if v, ok := d.GetOk("comparison_delta"); ok {
alert.ComparisonDelta = sentry.Float64(v.(float64))
}
if v, ok := d.GetOk("owner"); ok {
alert.Owner = sentry.String(v.(string))
}
Expand Down
2 changes: 2 additions & 0 deletions sentry/resource_sentry_metric_alert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func TestAccSentryMetricAlert_basic(t *testing.T) {
resource.TestCheckResourceAttr(rn, "time_window", "50"),
resource.TestCheckResourceAttr(rn, "threshold_type", "0"),
resource.TestCheckResourceAttr(rn, "resolve_threshold", "100"),
resource.TestCheckResourceAttr(rn, "comparison_delta", "100"),
resource.TestCheckResourceAttrPtr(rn, "internal_id", &alertID),
)
}
Expand Down Expand Up @@ -126,6 +127,7 @@ resource "sentry_metric_alert" "test" {
time_window = 50.0
threshold_type = 0
resolve_threshold = 100.0
comparison_delta = 100.0
trigger {
action {
Expand Down

0 comments on commit d5d88a6

Please sign in to comment.