mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-25 09:08:45 +05:00
updated processEEs to pass metrics in a map to event
This commit is contained in:
committed by
Dan Christian Bogos
parent
7560328388
commit
7131698daf
@@ -317,7 +317,7 @@ func (sS *StatService) processThresholds(sQs StatQueues, opts map[string]any) (e
|
||||
return
|
||||
}
|
||||
|
||||
// processThresholds will pass the event for statQueue to EEs
|
||||
// processEEs will pass the event for statQueue to EEs
|
||||
func (sS *StatService) processEEs(sQs StatQueues, opts map[string]any) (err error) {
|
||||
if len(sS.cgrcfg.StatSCfg().EEsConns) == 0 {
|
||||
return
|
||||
@@ -327,26 +327,28 @@ func (sS *StatService) processEEs(sQs StatQueues, opts map[string]any) (err erro
|
||||
opts = make(map[string]any)
|
||||
}
|
||||
for _, sq := range sQs {
|
||||
metrics := make(map[string]any)
|
||||
for metricID, metric := range sq.SQMetrics {
|
||||
metrics[metricID] = metric.GetValue(sS.cgrcfg.GeneralCfg().RoundingDecimals)
|
||||
}
|
||||
cgrEv := &utils.CGREvent{
|
||||
Tenant: sq.Tenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]any{
|
||||
utils.EventType: utils.StatUpdate,
|
||||
utils.StatID: sq.ID,
|
||||
utils.Metrics: metrics,
|
||||
},
|
||||
APIOpts: opts,
|
||||
}
|
||||
for metricID, metric := range sq.SQMetrics {
|
||||
cgrEv.Event[metricID] = metric.GetValue(sS.cgrcfg.GeneralCfg().RoundingDecimals)
|
||||
}
|
||||
cgrEventId := &CGREventWithEeIDs{
|
||||
cgrEventWithID := &CGREventWithEeIDs{
|
||||
CGREvent: cgrEv,
|
||||
EeIDs: sS.cgrcfg.StatSCfg().EEsExporterIDs,
|
||||
}
|
||||
var reply map[string]map[string]any
|
||||
if err := sS.connMgr.Call(context.TODO(), sS.cgrcfg.StatSCfg().EEsConns,
|
||||
utils.EeSv1ProcessEvent,
|
||||
cgrEventId, &reply); err != nil &&
|
||||
cgrEventWithID, &reply); err != nil &&
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
utils.Logger.Warning(
|
||||
fmt.Sprintf("<StatS> error: %s processing event %+v with EEs.", err.Error(), cgrEv))
|
||||
|
||||
@@ -77,10 +77,10 @@ func TestStatsEEsExport(t *testing.T) {
|
||||
{"tag": "EventType", "path": "*uch.EventType", "type": "*variable", "value": "~*req.EventType"},
|
||||
{"tag": "StatID", "path": "*uch.StatID", "type": "*variable", "value": "~*req.StatID"},
|
||||
{"tag": "ExporterID", "path": "*uch.ExporterID", "type": "*variable", "value": "~*opts.*exporterID"},
|
||||
{"tag": "SumUsage", "path": "*uch.SumUsage", "type": "*variable", "value": "~*req.*sum#~*req.Usage"},
|
||||
{"tag": "AverageCallCost", "path": "*uch.AverageCallCost", "type": "*variable", "value": "~*req.*acc"},
|
||||
{"tag": "AnswerSeizureRatio", "path": "*uch.AnswerSeizureRatio", "type": "*variable", "value": "~*req.*asr"},
|
||||
{"tag": "TotalCallDuration", "path": "*uch.TotalCallDuration", "type": "*variable", "value": "~*req.*tcd"},
|
||||
{"tag": "SumUsage", "path": "*uch.SumUsage", "type": "*variable", "value": "~*req.Metrics.*sum#~*req.Usage"},
|
||||
{"tag": "AverageCallCost", "path": "*uch.AverageCallCost", "type": "*variable", "value": "~*req.Metrics.*acc"},
|
||||
{"tag": "AnswerSeizureRatio", "path": "*uch.AnswerSeizureRatio", "type": "*variable", "value": "~*req.Metrics.*asr"},
|
||||
{"tag": "TotalCallDuration", "path": "*uch.TotalCallDuration", "type": "*variable", "value": "~*req.Metrics.*tcd"},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user