Skip to content

Commit

Permalink
as: Update errWebhookDisabled attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaspcr committed Feb 12, 2025
1 parent 2bd39e6 commit c85ad3f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2764,7 +2764,7 @@
},
"error:pkg/applicationserver/io/web/sink:webhook_disabled": {
"translations": {
"en": "webhook disabled"
"en": "webhook {webhook_id} of application {application_id} is disabled"
},
"description": {
"package": "pkg/applicationserver/io/web/sink",
Expand Down
10 changes: 8 additions & 2 deletions pkg/applicationserver/io/web/sink/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"net/http"
"time"

"go.thethings.network/lorawan-stack/v3/pkg/applicationserver/io/web/internal"
"go.thethings.network/lorawan-stack/v3/pkg/errors"
"go.thethings.network/lorawan-stack/v3/pkg/ttnpb"
"google.golang.org/protobuf/types/known/timestamppb"
Expand Down Expand Up @@ -60,7 +61,9 @@ const (
healthStateUnhealthy
)

var errWebhookDisabled = errors.DefineAborted("webhook_disabled", "webhook disabled")
var errWebhookDisabled = errors.DefineAborted(
"webhook_disabled", "webhook {webhook_id} of application {application_id} is disabled",
)

// preRunCheck verifies if the webhook should be executed.
func (hcs *healthCheckSink) preRunCheck(ctx context.Context) (healthState, error) {
Expand Down Expand Up @@ -102,7 +105,10 @@ func (hcs *healthCheckSink) preRunCheck(ctx context.Context) (healthState, error

default:
// The webhook is above the threshold, and the cooldown period has not passed yet.
return healthStateUnhealthy, errWebhookDisabled.New()
return healthStateUnhealthy, errWebhookDisabled.WithAttributes(
"application_id", internal.WebhookIDFromContext(ctx).ApplicationIds.ApplicationId,
"webhook_id", internal.WebhookIDFromContext(ctx).WebhookId,
)
}

default:
Expand Down

0 comments on commit c85ad3f

Please sign in to comment.