Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #205 from Netflix/add-metrics-to-metadataserver
Browse files Browse the repository at this point in the history
Add metrics to metadata service
  • Loading branch information
sargun committed Nov 27, 2018
2 parents 51102f3 + 45c17a2 commit e319a50
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions metadataserver/iam.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package metadataserver

import (
"net/http"

"context"
"encoding/json"
"fmt"
"net/http"
"regexp"
"strings"
"sync/atomic"
"time"

"github.com/Netflix/titus-executor/metadataserver/metrics"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/arn"
"github.com/aws/aws-sdk-go/aws/awserr"
Expand Down Expand Up @@ -265,15 +265,20 @@ func (proxy *iamProxy) notifyRoleAccessed(ctx context.Context, r *http.Request)
ran.overriddenSessionLifetime = &dur
}
}
metrics.PublishIncrementCounter("iam.notifyRoleAccessed.count")
select {
case <-ctx.Done():
log.Warning("Context done, before notify role access message sent: ", ctx.Err())
metrics.PublishIncrementCounter("iam.notifyRoleAccessed.sent.timeout")
case proxy.roleAcccessed <- ran:
metrics.PublishIncrementCounter("iam.notifyRoleAccessed.sent.success")
}
select {
case <-ctx.Done():
log.Warning("Context done, before notify role access message processed: ", ctx.Err())
metrics.PublishIncrementCounter("iam.notifyRoleAccessed.processed.timeout")
case <-ran.processed:
metrics.PublishIncrementCounter("iam.notifyRoleAccessed.processed.success")
}
}

Expand Down Expand Up @@ -321,7 +326,9 @@ func (proxy *iamProxy) doAssumeRole(sessionLifetime time.Duration) {
RoleArn: aws.String(proxy.arn.String()),
RoleSessionName: aws.String(generateSessionName(proxy.titusTaskInstanceID)),
}
now := time.Now()
result, err := proxy.sts.AssumeRoleWithContext(ctx, input)
metrics.PublishTimer("iam.assumeRoleTime", time.Since(now))
output := &roleAssumptionState{
assumeRoleGenerated: time.Now(),
assumeRoleOutput: result,
Expand Down

0 comments on commit e319a50

Please sign in to comment.