Skip to content

Commit d72db49

Browse files
author
Michal Tichák
committed
renaming
1 parent 161f49c commit d72db49

1 file changed

Lines changed: 34 additions & 34 deletions

File tree

core/integration/dcs/plugin.go

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,12 +1470,12 @@ func EORgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
14701470
metric := newMetric(runType, envId, "EOR")
14711471
defer monitoring.TimerSendSingle(&metric, monitoring.Millisecond)()
14721472
eor := "EOR"
1473-
detectorDurations := map[dcspb.Detector]time.Duration{}
1473+
durationsPerDetector := map[dcspb.Detector]time.Duration{}
14741474
start := time.Now()
14751475

1476-
wholeMetric := newMetric(runType, envId, eor)
1477-
wholeMetric.AddTag("detector", "All")
1478-
defer monitoring.TimerSendSingle(&wholeMetric, monitoring.Millisecond)()
1476+
totalCallDurationMetric := newMetric(runType, envId, eor)
1477+
totalCallDurationMetric.AddTag("detector", "All")
1478+
defer monitoring.TimerSendSingle(&totalCallDurationMetric, monitoring.Millisecond)()
14791479

14801480
var dcsEvent *dcspb.RunEvent
14811481
var err error
@@ -1495,15 +1495,15 @@ func EORgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
14951495
Error: err.Error(),
14961496
})
14971497

1498-
addFunctionResult(&wholeMetric, "timeout")
1498+
addFunctionResult(&totalCallDurationMetric, "timeout")
14991499
break
15001500
}
15011501
dcsEvent, err = stream.Recv()
15021502
if errors.Is(err, io.EOF) { // correct stream termination
15031503
log.Debug("DCS EOR event stream was closed from the DCS side (EOF)")
15041504
err = nil
15051505

1506-
addFunctionResult(&wholeMetric, "ok")
1506+
addFunctionResult(&totalCallDurationMetric, "ok")
15071507
break // no more data
15081508
}
15091509
if errors.Is(err, context.DeadlineExceeded) {
@@ -1523,7 +1523,7 @@ func EORgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
15231523
Error: err.Error(),
15241524
})
15251525

1526-
addFunctionResult(&wholeMetric, "timeout")
1526+
addFunctionResult(&totalCallDurationMetric, "timeout")
15271527
break
15281528
}
15291529
if err != nil { // stream termination in case of unknown or gRPC error
@@ -1545,7 +1545,7 @@ func EORgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
15451545
Payload: string(payloadJsonForKafka[:]),
15461546
Error: err.Error(),
15471547
})
1548-
addFunctionResult(&wholeMetric, "gRPC_timeout")
1548+
addFunctionResult(&totalCallDurationMetric, "gRPC_timeout")
15491549

15501550
} else if got == codes.Unknown { // unknown error, likely not a gRPC code
15511551
logMsg := "bad DCS EOR event received, any future DCS events are ignored"
@@ -1562,7 +1562,7 @@ func EORgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
15621562
Payload: string(payloadJsonForKafka[:]),
15631563
Error: logMsg,
15641564
})
1565-
addFunctionResult(&wholeMetric, "gRPC_unknown")
1565+
addFunctionResult(&totalCallDurationMetric, "gRPC_unknown")
15661566
} else { // some other gRPC error code
15671567
log.WithError(err).
15681568
Debug("DCS EOR call error")
@@ -1578,7 +1578,7 @@ func EORgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
15781578
Payload: string(payloadJsonForKafka[:]),
15791579
Error: err.Error(),
15801580
})
1581-
addFunctionResult(&wholeMetric, "gRPC_error")
1581+
addFunctionResult(&totalCallDurationMetric, "gRPC_error")
15821582
}
15831583

15841584
break
@@ -1594,7 +1594,7 @@ func EORgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
15941594
}
15951595

15961596
detectorStatusMap[dcsEvent.GetDetector()] = dcsEvent.GetState()
1597-
detectorDurations[dcsEvent.GetDetector()] = time.Since(start)
1597+
durationsPerDetector[dcsEvent.GetDetector()] = time.Since(start)
15981598
ecsDet := dcsToEcsDetector(dcsEvent.GetDetector())
15991599

16001600
if dcsEvent.GetState() == dcspb.DetectorState_EOR_FAILURE {
@@ -1707,7 +1707,7 @@ func EORgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
17071707
}
17081708
}
17091709

1710-
convertAndSendDetectorDurationsAndStates(eor, detectorStatusMap, detectorDurations, envId, runType, &wholeMetric)
1710+
convertAndSendDetectorDurationsAndStates(eor, detectorStatusMap, durationsPerDetector, envId, runType, &totalCallDurationMetric)
17111711

17121712
return err, payloadJsonForKafka
17131713
}
@@ -1720,9 +1720,9 @@ func SORgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
17201720
detectorDurations := map[dcspb.Detector]time.Duration{}
17211721
start := time.Now()
17221722

1723-
wholeMetric := newMetric(runType, envId, sor)
1724-
wholeMetric.AddTag("detector", "All")
1725-
defer monitoring.TimerSendSingle(&wholeMetric, monitoring.Millisecond)()
1723+
totalCallDurationMetric := newMetric(runType, envId, sor)
1724+
totalCallDurationMetric.AddTag("detector", "All")
1725+
defer monitoring.TimerSendSingle(&totalCallDurationMetric, monitoring.Millisecond)()
17261726

17271727
var dcsEvent *dcspb.RunEvent
17281728
var err error
@@ -1742,15 +1742,15 @@ func SORgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
17421742
Error: err.Error(),
17431743
})
17441744

1745-
addFunctionResult(&wholeMetric, "timeout")
1745+
addFunctionResult(&totalCallDurationMetric, "timeout")
17461746
break
17471747
}
17481748
dcsEvent, err = stream.Recv()
17491749
if errors.Is(err, io.EOF) { // correct stream termination
17501750
log.Debug("DCS SOR event stream was closed from the DCS side (EOF)")
17511751
err = nil
17521752

1753-
addFunctionResult(&wholeMetric, "ok")
1753+
addFunctionResult(&totalCallDurationMetric, "ok")
17541754
break // no more data
17551755
}
17561756
if errors.Is(err, context.DeadlineExceeded) {
@@ -1770,7 +1770,7 @@ func SORgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
17701770
Error: err.Error(),
17711771
})
17721772

1773-
addFunctionResult(&wholeMetric, "timeout")
1773+
addFunctionResult(&totalCallDurationMetric, "timeout")
17741774
break
17751775
}
17761776
if err != nil { // stream termination in case of unknown or gRPC error
@@ -1793,7 +1793,7 @@ func SORgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
17931793
Error: err.Error(),
17941794
})
17951795

1796-
addFunctionResult(&wholeMetric, "gRPC_timeout")
1796+
addFunctionResult(&totalCallDurationMetric, "gRPC_timeout")
17971797
} else if got == codes.Unknown { // unknown error, likely not a gRPC code
17981798
logMsg := "bad DCS SOR event received, any future DCS events are ignored"
17991799
log.WithError(err).
@@ -1809,7 +1809,7 @@ func SORgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
18091809
Payload: string(payloadJsonForKafka[:]),
18101810
Error: logMsg,
18111811
})
1812-
addFunctionResult(&wholeMetric, "gRPC_unknown")
1812+
addFunctionResult(&totalCallDurationMetric, "gRPC_unknown")
18131813
} else { // some other gRPC error code
18141814
log.WithError(err).
18151815
Debug("DCS SOR call error")
@@ -1825,7 +1825,7 @@ func SORgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
18251825
Payload: string(payloadJsonForKafka[:]),
18261826
Error: err.Error(),
18271827
})
1828-
addFunctionResult(&wholeMetric, "gRPC_error")
1828+
addFunctionResult(&totalCallDurationMetric, "gRPC_error")
18291829
}
18301830

18311831
break
@@ -1991,12 +1991,12 @@ func SORgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
19911991
}
19921992
}
19931993

1994-
convertAndSendDetectorDurationsAndStates(sor, detectorStatusMap, detectorDurations, envId, runType, &wholeMetric)
1994+
convertAndSendDetectorDurationsAndStates(sor, detectorStatusMap, detectorDurations, envId, runType, &totalCallDurationMetric)
19951995

19961996
return err, payloadJsonForKafka
19971997
}
19981998

1999-
func convertAndSendDetectorDurationsAndStates(method string, detectorStatusMap map[dcspb.Detector]dcspb.DetectorState, detectorDurations map[dcspb.Detector]time.Duration, envId, runType string, wholeMetric *monitoring.Metric) {
1999+
func convertAndSendDetectorDurationsAndStates(method string, detectorStatusMap map[dcspb.Detector]dcspb.DetectorState, detectorDurations map[dcspb.Detector]time.Duration, envId, runType string, totalCallMetric *monitoring.Metric) {
20002000
resultsMap := make(map[dcspb.DetectorState]int)
20012001
for dcsDet, state := range detectorStatusMap {
20022002
metric := newMetric(runType, envId, method)
@@ -2010,7 +2010,7 @@ func convertAndSendDetectorDurationsAndStates(method string, detectorStatusMap m
20102010
}
20112011
}
20122012
for detectorState, detectorCount := range resultsMap {
2013-
wholeMetric.SetFieldInt64(dcspb.DetectorState_name[int32(detectorState)], int64(detectorCount))
2013+
totalCallMetric.SetFieldInt64(dcspb.DetectorState_name[int32(detectorState)], int64(detectorCount))
20142014
}
20152015
}
20162016

@@ -2026,9 +2026,9 @@ func PFRgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
20262026
detectorDurations := map[dcspb.Detector]time.Duration{}
20272027
start := time.Now()
20282028

2029-
wholeMetric := newMetric(runType, envId, pfr)
2030-
wholeMetric.AddTag("detector", "All")
2031-
defer monitoring.TimerSendSingle(&wholeMetric, monitoring.Millisecond)()
2029+
totalCallDurationMetric := newMetric(runType, envId, pfr)
2030+
totalCallDurationMetric.AddTag("detector", "All")
2031+
defer monitoring.TimerSendSingle(&totalCallDurationMetric, monitoring.Millisecond)()
20322032

20332033
var err error
20342034
var dcsEvent *dcspb.RunEvent
@@ -2048,15 +2048,15 @@ func PFRgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
20482048
Error: err.Error(),
20492049
})
20502050

2051-
addFunctionResult(&wholeMetric, "timeout")
2051+
addFunctionResult(&totalCallDurationMetric, "timeout")
20522052
break
20532053
}
20542054
dcsEvent, err = stream.Recv()
20552055
if errors.Is(err, io.EOF) { // correct stream termination
20562056
log.Debug("DCS PFR event stream was closed from the DCS side (EOF)")
20572057
err = nil
20582058

2059-
addFunctionResult(&wholeMetric, "ok")
2059+
addFunctionResult(&totalCallDurationMetric, "ok")
20602060
break // no more data
20612061
}
20622062
if errors.Is(err, context.DeadlineExceeded) {
@@ -2076,7 +2076,7 @@ func PFRgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
20762076
Error: err.Error(),
20772077
})
20782078

2079-
addFunctionResult(&wholeMetric, "timeout")
2079+
addFunctionResult(&totalCallDurationMetric, "timeout")
20802080
break
20812081
}
20822082
if err != nil { // stream termination in case of unknown or gRPC error
@@ -2098,7 +2098,7 @@ func PFRgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
20982098
Payload: string(payloadJsonForKafka[:]),
20992099
Error: err.Error(),
21002100
})
2101-
addFunctionResult(&wholeMetric, "gRPC_timeout")
2101+
addFunctionResult(&totalCallDurationMetric, "gRPC_timeout")
21022102
} else if got == codes.Unknown { // unknown error, likely not a gRPC code
21032103
logMsg := "bad DCS PFR event received, any future DCS events are ignored"
21042104
log.WithError(err).
@@ -2115,7 +2115,7 @@ func PFRgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
21152115
Payload: string(payloadJsonForKafka[:]),
21162116
Error: logMsg,
21172117
})
2118-
addFunctionResult(&wholeMetric, "gRPC_unknown")
2118+
addFunctionResult(&totalCallDurationMetric, "gRPC_unknown")
21192119
} else { // some other gRPC error code
21202120
log.WithError(err).
21212121
Error("DCS PFR call error")
@@ -2131,7 +2131,7 @@ func PFRgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
21312131
Payload: string(payloadJsonForKafka[:]),
21322132
Error: err.Error(),
21332133
})
2134-
addFunctionResult(&wholeMetric, "gRPC_error")
2134+
addFunctionResult(&totalCallDurationMetric, "gRPC_error")
21352135
}
21362136

21372137
break
@@ -2297,7 +2297,7 @@ func PFRgRPCCommunicationLoop(ctx context.Context, timeout time.Duration, call *
22972297
}
22982298
}
22992299

2300-
convertAndSendDetectorDurationsAndStates(pfr, detectorStatusMap, detectorDurations, envId, runType, &wholeMetric)
2300+
convertAndSendDetectorDurationsAndStates(pfr, detectorStatusMap, detectorDurations, envId, runType, &totalCallDurationMetric)
23012301

23022302
return err, payloadJsonForKafka
23032303
}

0 commit comments

Comments
 (0)