Skip to content

Commit e37d908

Browse files
committed
More tweaks for SSM instrumentation
I'm not duplicating this annotation key anymore, although the setting of the variable and read in defer might be weirder... I'm also recording an error if the context is canceled, but if X-Ray can't do OTel events then maybe this is broken too?
1 parent a7223ba commit e37d908

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

internal/slack/token.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ func AWSParameter(name string, ttl time.Duration) TokenProvider {
7777
)
7878

7979
return func(ctx context.Context) (string, error) {
80+
var cached bool
81+
8082
ctx, span := tracer.Start(ctx, "slack.AWSParameter")
8183
defer span.End()
8284

@@ -85,18 +87,20 @@ func AWSParameter(name string, ttl time.Duration) TokenProvider {
8587
defer func() {
8688
<-lock
8789
span.SetAttributes(
90+
attribute.Bool("randomizer.slack.ssm.cached", cached),
8891
attribute.Int64("randomizer.slack.ssm.expiry", expiry.Unix()))
8992
}()
93+
9094
case <-ctx.Done():
95+
span.RecordError(ctx.Err())
9196
return "", ctx.Err()
9297
}
9398

9499
if time.Now().Before(expiry) {
95-
span.SetAttributes(attribute.Bool("randomizer.slack.ssm.cached", true))
100+
cached = true
96101
return token, nil
97102
}
98103

99-
span.SetAttributes(attribute.Bool("randomizer.slack.ssm.cached", false))
100104
cfg, err := awsconfig.New(ctx)
101105
if err != nil {
102106
return "", err

0 commit comments

Comments
 (0)