Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions router/customdestinationmanager/customdestinationmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,14 @@ func (customManager *CustomManagerT) close(destID string) {
}

func (customManager *CustomManagerT) refreshClient(destID string) error {
startTime := time.Now()
defer func() {
pkgLogger.Debugn("[CDM]", logger.NewStringField("destType", customManager.destType),
logger.NewStringField("destID", destID),
logger.NewDurationField("refreshTime", time.Since(startTime)),
)
}()

customDestination, ok := customManager.client[destID]

if ok {
Expand Down
18 changes: 18 additions & 0 deletions services/oauth/v2/oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"
"time"

"github.com/google/uuid"
"github.com/tidwall/gjson"

"github.com/rudderlabs/rudder-go-kit/config"
Expand Down Expand Up @@ -182,22 +183,39 @@ func (h *OAuthHandler) RefreshToken(refTokenParams *RefreshTokenParams) (int, *A
}

func (h *OAuthHandler) GetTokenInfo(refTokenParams *RefreshTokenParams, logTypeName string, statsHandler OAuthStatsHandler) (int, *AuthResponse, error) {
// Create a logger with all context fields
log := h.Logger.Withn(
logger.NewIntField("WorkerId", int64(refTokenParams.WorkerID)),
logger.NewStringField("Call Type", logTypeName),
logger.NewStringField("AccountId", refTokenParams.AccountID),
obskit.DestinationID(refTokenParams.DestinationID),
obskit.WorkspaceID(refTokenParams.WorkspaceID),
obskit.DestinationType(refTokenParams.DestDefName),
)

// Add a unique request ID to trace this specific request through logs
requestID := uuid.New().String()
log = log.Withn(logger.NewStringField("RequestID", requestID))

log.Debugn("[request] :: Get Token Info request received")
startTime := time.Now()

log.Debugn("[request] :: Acquiring lock for account")
lockStartTime := time.Now()
h.CacheMutex.Lock(refTokenParams.AccountID)
lockAcquisitionTime := time.Since(lockStartTime)

log.Debugn("Lock acquisition took ",
logger.NewDurationField("duration", lockAcquisitionTime))

defer h.CacheMutex.Unlock(refTokenParams.AccountID)
defer func() {
log.Debugn("[request] :: Released lock for account")
statsHandler.SendTiming(startTime, "total_latency", stats.Tags{
"isCallToCpApi": "false",
})
}()

refTokenBody := RefreshTokenBodyParams{}
storedCache, ok := h.Cache.Load(refTokenParams.AccountID)
if ok {
Expand Down