Skip to content

Commit

Permalink
fix: Webhook-related instruments
Browse files Browse the repository at this point in the history
* fix: also instrument webhooks that do not reach the wire
* fix: register the webhook instrumentation
  • Loading branch information
azazeal authored Feb 27, 2024
1 parent c798735 commit fb4cd6f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 2 additions & 4 deletions authority/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,14 +675,13 @@ func (a *Authority) callEnrichingWebhooksSSH(ctx context.Context, prov provision
if webhookCtl == nil {
return
}
defer func() { a.meter.SSHWebhookEnriched(prov, err) }()

var whEnrichReq *webhook.RequestBody
if whEnrichReq, err = webhook.NewRequestBody(
webhook.WithSSHCertificateRequest(cr),
); err == nil {
err = webhookCtl.Enrich(ctx, whEnrichReq)

a.meter.SSHWebhookEnriched(prov, err)
}

return
Expand All @@ -692,14 +691,13 @@ func (a *Authority) callAuthorizingWebhooksSSH(ctx context.Context, prov provisi
if webhookCtl == nil {
return
}
defer func() { a.meter.SSHWebhookAuthorized(prov, err) }()

var whAuthBody *webhook.RequestBody
if whAuthBody, err = webhook.NewRequestBody(
webhook.WithSSHCertificate(cert, certTpl),
); err == nil {
err = webhookCtl.Authorize(ctx, whAuthBody)

a.meter.SSHWebhookAuthorized(prov, err)
}

return
Expand Down
6 changes: 2 additions & 4 deletions authority/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,7 @@ func (a *Authority) callEnrichingWebhooksX509(ctx context.Context, prov provisio
if webhookCtl == nil {
return
}
defer func() { a.meter.X509WebhookEnriched(prov, err) }()

var attested *webhook.AttestationData
if attData != nil {
Expand All @@ -1013,8 +1014,6 @@ func (a *Authority) callEnrichingWebhooksX509(ctx context.Context, prov provisio
webhook.WithAttestationData(attested),
); err == nil {
err = webhookCtl.Enrich(ctx, whEnrichReq)

a.meter.X509WebhookEnriched(prov, err)
}

return
Expand All @@ -1024,6 +1023,7 @@ func (a *Authority) callAuthorizingWebhooksX509(ctx context.Context, prov provis
if webhookCtl == nil {
return
}
defer func() { a.meter.X509WebhookAuthorized(prov, err) }()

var attested *webhook.AttestationData
if attData != nil {
Expand All @@ -1038,8 +1038,6 @@ func (a *Authority) callAuthorizingWebhooksX509(ctx context.Context, prov provis
webhook.WithAttestationData(attested),
); err == nil {
err = webhookCtl.Authorize(ctx, whAuthBody)

a.meter.X509WebhookAuthorized(prov, err)
}

return
Expand Down
4 changes: 4 additions & 0 deletions internal/metrix/meter.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ func New() (m *Meter) {
m.ssh.rekeyed,
m.ssh.renewed,
m.ssh.signed,
m.ssh.webhookAuthorized,
m.ssh.webhookEnriched,
m.x509.rekeyed,
m.x509.renewed,
m.x509.signed,
m.x509.webhookAuthorized,
m.x509.webhookEnriched,
m.kms.signed,
m.kms.errors,
)
Expand Down

0 comments on commit fb4cd6f

Please sign in to comment.