Skip to content

Commit fb4cd6f

Browse files
authored
fix: Webhook-related instruments
* fix: also instrument webhooks that do not reach the wire * fix: register the webhook instrumentation
1 parent c798735 commit fb4cd6f

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

authority/ssh.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -675,14 +675,13 @@ func (a *Authority) callEnrichingWebhooksSSH(ctx context.Context, prov provision
675675
if webhookCtl == nil {
676676
return
677677
}
678+
defer func() { a.meter.SSHWebhookEnriched(prov, err) }()
678679

679680
var whEnrichReq *webhook.RequestBody
680681
if whEnrichReq, err = webhook.NewRequestBody(
681682
webhook.WithSSHCertificateRequest(cr),
682683
); err == nil {
683684
err = webhookCtl.Enrich(ctx, whEnrichReq)
684-
685-
a.meter.SSHWebhookEnriched(prov, err)
686685
}
687686

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

696696
var whAuthBody *webhook.RequestBody
697697
if whAuthBody, err = webhook.NewRequestBody(
698698
webhook.WithSSHCertificate(cert, certTpl),
699699
); err == nil {
700700
err = webhookCtl.Authorize(ctx, whAuthBody)
701-
702-
a.meter.SSHWebhookAuthorized(prov, err)
703701
}
704702

705703
return

authority/tls.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@ func (a *Authority) callEnrichingWebhooksX509(ctx context.Context, prov provisio
999999
if webhookCtl == nil {
10001000
return
10011001
}
1002+
defer func() { a.meter.X509WebhookEnriched(prov, err) }()
10021003

10031004
var attested *webhook.AttestationData
10041005
if attData != nil {
@@ -1013,8 +1014,6 @@ func (a *Authority) callEnrichingWebhooksX509(ctx context.Context, prov provisio
10131014
webhook.WithAttestationData(attested),
10141015
); err == nil {
10151016
err = webhookCtl.Enrich(ctx, whEnrichReq)
1016-
1017-
a.meter.X509WebhookEnriched(prov, err)
10181017
}
10191018

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

10281028
var attested *webhook.AttestationData
10291029
if attData != nil {
@@ -1038,8 +1038,6 @@ func (a *Authority) callAuthorizingWebhooksX509(ctx context.Context, prov provis
10381038
webhook.WithAttestationData(attested),
10391039
); err == nil {
10401040
err = webhookCtl.Authorize(ctx, whAuthBody)
1041-
1042-
a.meter.X509WebhookAuthorized(prov, err)
10431041
}
10441042

10451043
return

internal/metrix/meter.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ func New() (m *Meter) {
4242
m.ssh.rekeyed,
4343
m.ssh.renewed,
4444
m.ssh.signed,
45+
m.ssh.webhookAuthorized,
46+
m.ssh.webhookEnriched,
4547
m.x509.rekeyed,
4648
m.x509.renewed,
4749
m.x509.signed,
50+
m.x509.webhookAuthorized,
51+
m.x509.webhookEnriched,
4852
m.kms.signed,
4953
m.kms.errors,
5054
)

0 commit comments

Comments
 (0)