Skip to content

Commit

Permalink
chore: expose metrics log level
Browse files Browse the repository at this point in the history
  • Loading branch information
andyzhangx committed Apr 17, 2024
1 parent 41d0175 commit 5e55daa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/metrics/azure_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,16 @@ type operationCallMetrics struct {
type MetricContext struct {
start time.Time
attributes []string
// log level in ObserveOperationWithResult
LogLevel int32
}

// NewMetricContext creates a new MetricContext.
func NewMetricContext(prefix, request, resourceGroup, subscriptionID, source string) *MetricContext {
return &MetricContext{
start: time.Now(),
attributes: []string{prefix + "_" + request, strings.ToLower(resourceGroup), subscriptionID, source},
LogLevel: 3,
}
}

Expand Down Expand Up @@ -104,7 +107,7 @@ func (mc *MetricContext) ObserveOperationWithResult(isOperationSucceeded bool, l
}
mc.CountFailedOperation()
}
mc.logLatency(3, latency, append(labelAndValues, "result_code", resultCode)...)
mc.logLatency(mc.LogLevel, latency, append(labelAndValues, "result_code", resultCode)...)
}

func (mc *MetricContext) logLatency(logLevel int32, latency float64, additionalKeysAndValues ...interface{}) {
Expand Down

0 comments on commit 5e55daa

Please sign in to comment.