void emit_metrics(UserRecord ur) { if (ur.Attempts().Count == 0) { return; } bool successful = ur.Attempts()[ur.Attempts().Count - 1].Success(); string shard_id = ""; if (successful) { shard_id = ur.Attempts()[ur.Attempts().Count - 1].Shard_id(); } else if (ur.Predicted_shard() != -1) { shard_id = ShardMap.shard_id_to_str((ulong)ur.Predicted_shard()); } Action <string, double> put = (name, val) => { var f = metrics_manager_.finder().set_name(name).set_stream(ur.Stream()); if (!string.IsNullOrEmpty(shard_id)) { f.set_shard(shard_id); } f.find().Put(val); }; if (successful) { put(Names.UserRecordsPut, 1); put(Names.UserRecordsDataPut, ur.Data().Length); } else { put(Names.UserRecordsPut, 0); if (ur.Attempts()[ur.Attempts().Count - 1].Error_code() == "Expired") { put(Names.UserRecordExpired, 1); } } var last = ur.Arrival(); foreach (var a in ur.Attempts()) { put(Names.BufferingTime, (a.Start() - last).TotalMilliseconds); last = a.End(); } put(Names.RetriesPerRecord, ur.Attempts().Count - 1); }
public MetricsPutter put( string name, double val, ulong shard_id = 0, string err_code = null) { var f = metrics_manager.finder().set_name(name); if (!string.IsNullOrEmpty(err_code)) { f.set_error_code(err_code); } f.set_stream(stream); if (shard_id != 0) { f.set_shard(ShardMap.shard_id_to_str(shard_id)); } f.find().Put(val); return(this); }
void report_outstanding() { foreach (var kv in pipelines_) { metrics_manager_.finder() .set_name(Names.UserRecordsPending) .set_stream(kv.Key) .find() .Put(kv.Value.outstanding_user_records()); } var delay = 200; if (null == report_outstanding_) { report_outstanding_ = executor_.Schedule(() => { report_outstanding(); }, delay); } else { report_outstanding_.reschedule(delay); } }