Skip to content

Commit bb0fa41

Browse files
nateberkopecclaude
andcommitted
Remove convert_dimensions method, dimensions must be hash
Simplifies dimension handling by requiring dimensions to always be a hash. Removes the convert_dimensions method and the unnecessary conditional logic for handling arrays or other types. Dimensions are now always expected as a hash and converted inline. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4027190 commit bb0fa41

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

lib/speedshop/cloudwatch/metric_reporter.rb

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def report(metric:, value:, dimensions: {}, namespace: nil)
6868

6969
return unless metric_allowed?(integration, metric_name)
7070

71-
dimensions_array = convert_dimensions(dimensions)
71+
dimensions_array = dimensions.map { |k, v| {name: k.to_s, value: v.to_s} }
7272
all_dimensions = dimensions_array + custom_dimensions
7373

7474
@mutex.synchronize do
@@ -144,17 +144,6 @@ def custom_dimensions
144144
def find_integration_for_metric(metric_name)
145145
@config.metrics.find { |int, metrics| metrics.include?(metric_name.to_sym) }&.first
146146
end
147-
148-
def convert_dimensions(dimensions)
149-
case dimensions
150-
when Hash
151-
dimensions.map { |k, v| {name: k.to_s, value: v.to_s} }
152-
when Array
153-
dimensions
154-
else
155-
[]
156-
end
157-
end
158147
end
159148
end
160149
end

test/support/doubles.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,7 @@ def initialize
1010
end
1111

1212
def report(metric:, value:, dimensions: {}, namespace: nil)
13-
dims = if dimensions.is_a?(Hash)
14-
dimensions.map { |k, v| {name: k.to_s, value: v.to_s} }
15-
elsif dimensions.is_a?(Array)
16-
dimensions
17-
else
18-
[]
19-
end
20-
13+
dims = dimensions.map { |k, v| {name: k.to_s, value: v.to_s} }
2114
@metrics_collected << {name: metric.to_s, value: value, dimensions: dims, namespace: namespace}
2215
end
2316

0 commit comments

Comments
 (0)