Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set unit when sending NetSim metrics #24757

Merged
merged 2 commits into from Sep 12, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions shared/middleware/net_sim_api.rb
Expand Up @@ -225,7 +225,7 @@ def owns_shard?(shard_id)

# Block request if payload is unusually large.
if body_string.length > MAX_REQUEST_SIZE
record_metric("InsertTooLarge_#{table_name}", body_string.length)
record_metric("InsertTooLarge_#{table_name}", body_string.length, 'Bytes')
too_large
end

Expand All @@ -251,7 +251,7 @@ def owns_shard?(shard_id)
table = get_table(shard_id, table_name)
result = values.map {|value| table.insert(value, request.ip)}

record_metric("InsertBytes_#{table_name}", body_string.length)
record_metric("InsertBytes_#{table_name}", body_string.length, 'Bytes')
record_metric("InsertRows_#{table_name}", values.count)

# Finally, if we are not performing a multi-insert, denormalize our
Expand Down Expand Up @@ -355,7 +355,7 @@ def validate_wire(shard_id, wire)

# Block request if payload is unusually large.
if body_string.length > MAX_REQUEST_SIZE
record_metric("UpdateTooLarge_#{table_name}", body_string.length)
record_metric("UpdateTooLarge_#{table_name}", body_string.length, 'Bytes')
too_large
end

Expand All @@ -369,7 +369,7 @@ def validate_wire(shard_id, wire)
json_bad_request
end

record_metric("UpdateBytes_#{table_name}", body_string.length)
record_metric("UpdateBytes_#{table_name}", body_string.length, 'Bytes')

dont_cache
content_type :json
Expand Down Expand Up @@ -504,7 +504,7 @@ def delete_messages_for_nodes(shard_id, node_ids)
# @param [String] event_type - unique metric key within NetSimApi
# @param [Number] value (default 1) value of measurement, omit if we only care
# about event counts.
def record_metric(event_type, value = 1)
def record_metric(event_type, value = 1, unit = 'Count')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super small - I would add a param comment for the new param, just because we have them for the others

return unless CDO.netsim_enable_metrics
Cdo::Metrics.push('NetSimApi',
[
Expand Down