lib/fluent/metrics_backends.rb in fluent-plugin-buffered-metrics-0.0.2 vs lib/fluent/metrics_backends.rb in fluent-plugin-buffered-metrics-0.0.3
- old
+ new
@@ -169,16 +169,18 @@
def get_connection_parameters_defaults
return { 'proto' => 'tcp', 'host' => 'localhost', 'port' => 2003 }
end
def serialize_entry(entry,time)
- return sprintf(
- '%s%s %s %i',
- entry.key?('prefix') ? entry['prefix'] + '.' : '',
- entry['name'],entry['value'].to_s,
- time.to_i
- )
+ unless entry.nil? or not entry.key?('name') or not entry.key?('value') or entry['name'].empty? or not entry['value'].is_a?(Numeric)
+ return sprintf(
+ '%s%s %s %i',
+ entry.key?('prefix') ? entry['prefix'] + '.' : '',
+ entry['name'],entry['value'].to_s,
+ time.to_i
+ )
+ end
end
end
class MetricsBackendStatsd < MetricsBackend
@@ -186,15 +188,17 @@
def get_connection_parameters_defaults
return { 'proto' => 'udp', 'host' => 'localhost', 'port' => 8215 }
end
def serialize_entry(entry,time)
- return sprintf(
- '%s%s:%s|c',
- entry.key?('prefix') ? entry['prefix'] + '.' : '',
- entry['name'],
- entry['value'].to_i
- )
+ unless entry.nil? or not entry.key?('name') or not entry.key?('value') or entry['name'].empty? or not entry['value'].is_a?(Numeric)
+ return sprintf(
+ '%s%s:%s|c',
+ entry.key?('prefix') ? entry['prefix'] + '.' : '',
+ entry['name'],
+ entry['value'].to_i
+ )
+ end
end
end
end