MCPcopy Create free account
hub / github.com/dan-v/lambda-nat-proxy / LogMetrics

Function LogMetrics

pkg/shared/logger.go:134–160  ·  view source on GitHub ↗

LogMetrics logs performance metrics

(component string, metrics map[string]interface{})

Source from the content-addressed store, hash-verified

132
133// LogMetrics logs performance metrics
134func LogMetrics(component string, metrics map[string]interface{}) {
135 attrs := []slog.Attr{
136 slog.String("component", component),
137 slog.Time("timestamp", time.Now()),
138 }
139
140 for key, value := range metrics {
141 switch v := value.(type) {
142 case string:
143 attrs = append(attrs, slog.String(key, v))
144 case int:
145 attrs = append(attrs, slog.Int(key, v))
146 case int64:
147 attrs = append(attrs, slog.Int64(key, v))
148 case float64:
149 attrs = append(attrs, slog.Float64(key, v))
150 case bool:
151 attrs = append(attrs, slog.Bool(key, v))
152 case time.Duration:
153 attrs = append(attrs, slog.Duration(key, v))
154 default:
155 attrs = append(attrs, slog.Any(key, v))
156 }
157 }
158
159 StructuredInfo("Performance metrics", attrs...)
160}
161
162// SetLogLevel dynamically sets the log level
163func SetLogLevel(level slog.Level) {

Callers

nothing calls this directly

Calls 1

StructuredInfoFunction · 0.85

Tested by

no test coverage detected