Skip to content

Commit

Permalink
fix: don't assume attribute type in oteltracing (#1483)
Browse files Browse the repository at this point in the history
  • Loading branch information
VinozzZ authored Feb 12, 2025
1 parent a81349d commit d9224c4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cmd/refinery/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,18 @@ func main() {
// add telemetry callback so husky can enrich spans with attributes
husky.AddTelemetryAttributeFunc = func(ctx context.Context, key string, value any) {
span := trace.SpanFromContext(ctx)
span.SetAttributes(attribute.String(key, value.(string)))
switch v := value.(type) {
case string:
span.SetAttributes(attribute.String(key, v))
case bool:
span.SetAttributes(attribute.Bool(key, v))
case int:
span.SetAttributes(attribute.Int(key, v))
case float64:
span.SetAttributes(attribute.Float64(key, v))
default:
span.SetAttributes(attribute.String(key, fmt.Sprintf("%v", v)))
}
}
}
defer shutdown()
Expand Down

0 comments on commit d9224c4

Please sign in to comment.