Skip to content

Commit d9e68aa

Browse files
committed
Play with the SSM instrumentation a little more
First, X-Ray doesn't support OTel events. Second, the expiry timestamp is more stable and consistent to emit as an attribute. Especially since the duration was computed _after_ the check to decide whether to use the cache, so was inherently stale.
1 parent 8b92919 commit d9e68aa

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

internal/slack/token.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,23 @@ func AWSParameter(name string, ttl time.Duration) TokenProvider {
8080
ctx, span := tracer.Start(ctx, "AWSParameterTokenProvider")
8181
defer span.End()
8282

83-
span.AddEvent("LockStart")
8483
select {
8584
case lock <- struct{}{}:
86-
span.AddEvent("Lock")
87-
defer func() { <-lock }()
85+
defer func() {
86+
<-lock
87+
span.SetAttributes(
88+
attribute.Int64("randomizer.slack.ssm.expiry", expiry.Unix()))
89+
}()
8890
case <-ctx.Done():
89-
span.AddEvent("LockCancel")
9091
return "", ctx.Err()
9192
}
9293

9394
if time.Now().Before(expiry) {
94-
span.SetAttributes(
95-
attribute.Float64(
96-
"randomizer.slack.awsparameter.ttl",
97-
time.Until(expiry).Seconds()))
95+
span.SetAttributes(attribute.Bool("randomizer.slack.ssm.cached", true))
9896
return token, nil
9997
}
10098

99+
span.SetAttributes(attribute.Bool("randomizer.slack.ssm.cached", false))
101100
cfg, err := awsconfig.New(ctx)
102101
if err != nil {
103102
return "", err

0 commit comments

Comments
 (0)