Skip to content

Commit 8b92919

Browse files
committed
Experiment with Slack SSM instrumentation
I'm just playing with the library at this point; not sure any of this will be that useful.
1 parent 4393888 commit 8b92919

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

internal/slack/slack.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ import (
1010
"net/url"
1111
"strings"
1212

13+
"go.opentelemetry.io/otel"
14+
1315
"github.com/featherbread/randomizer/internal/randomizer"
1416
)
1517

18+
var tracer = otel.Tracer("github.com/featherbread/randomizer/internal/slack")
19+
1620
// App serves the randomizer through the Slack slash command API.
1721
//
1822
// App supports legacy static verification tokens to confirm the legitimacy of

internal/slack/token.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/aws/aws-sdk-go-v2/aws"
1111
"github.com/aws/aws-sdk-go-v2/service/ssm"
12+
"go.opentelemetry.io/otel/attribute"
1213

1314
"github.com/featherbread/randomizer/internal/awsconfig"
1415
)
@@ -76,14 +77,24 @@ func AWSParameter(name string, ttl time.Duration) TokenProvider {
7677
)
7778

7879
return func(ctx context.Context) (string, error) {
80+
ctx, span := tracer.Start(ctx, "AWSParameterTokenProvider")
81+
defer span.End()
82+
83+
span.AddEvent("LockStart")
7984
select {
8085
case lock <- struct{}{}:
86+
span.AddEvent("Lock")
8187
defer func() { <-lock }()
8288
case <-ctx.Done():
89+
span.AddEvent("LockCancel")
8390
return "", ctx.Err()
8491
}
8592

8693
if time.Now().Before(expiry) {
94+
span.SetAttributes(
95+
attribute.Float64(
96+
"randomizer.slack.awsparameter.ttl",
97+
time.Until(expiry).Seconds()))
8798
return token, nil
8899
}
89100

0 commit comments

Comments
 (0)