@@ -19,11 +19,9 @@ import (
19
19
"github.com/newrelic/newrelic-php-agent/daemon/internal/newrelic/utilization"
20
20
)
21
21
22
- var (
23
- ErrPayloadTooLarge = errors .New ("payload too large" )
24
- ErrUnauthorized = errors .New ("unauthorized" )
25
- ErrUnsupportedMedia = errors .New ("unsupported media" )
26
- )
22
+ var ErrPayloadTooLarge = errors .New ("payload too large" )
23
+ var ErrUnauthorized = errors .New ("unauthorized" )
24
+ var ErrUnsupportedMedia = errors .New ("unsupported media" )
27
25
28
26
type rpmException struct {
29
27
Message string `json:"message"`
@@ -460,7 +458,7 @@ func TestUsageHarvest(t *testing.T) {
460
458
// of harvests. So we extract the time from what we receive
461
459
time1 := strings .Split (string (cp1 .data ), "," )[1 ]
462
460
time2 := strings .Split (string (cp1 .data ), "," )[2 ]
463
- expectedJSON1 : = `["one",` + time1 + `,` + time2 + `,` +
461
+ var expectedJSON1 = `["one",` + time1 + `,` + time2 + `,` +
464
462
`[[{"name":"Instance/Reporting"},[1,0,0,0,0,0]],` +
465
463
`[{"name":"Supportability/AnalyticsEvents/TotalEventsSeen"},[0,0,0,0,0,0]],` +
466
464
`[{"name":"Supportability/AnalyticsEvents/TotalEventsSent"},[0,0,0,0,0,0]],` +
@@ -480,7 +478,7 @@ func TestUsageHarvest(t *testing.T) {
480
478
`[{"name":"Supportability/SpanEvent/TotalEventsSent"},[0,0,0,0,0,0]]]]`
481
479
time1 = strings .Split (string (cp2 .data ), "," )[1 ]
482
480
time2 = strings .Split (string (cp2 .data ), "," )[2 ]
483
- expectedJSON2 : = `["one",` + time1 + `,` + time2 + `,` +
481
+ var expectedJSON2 = `["one",` + time1 + `,` + time2 + `,` +
484
482
`[[{"name":"Supportability/C/Collector/Output/Bytes"},[1,1253,0,0,0,0]],` +
485
483
`[{"name":"Supportability/C/Collector/metric_data/Output/Bytes"},[1,1253,0,0,0,0]]]]`
486
484
@@ -536,7 +534,7 @@ func TestUsageHarvestExceedChannel(t *testing.T) {
536
534
time1 := strings .Split (string (cp .data ), "," )[1 ]
537
535
time2 := strings .Split (string (cp .data ), "," )[2 ]
538
536
// The data usage channel only holds 25 points until dropping data
539
- expectedJSON : = `["one",` + time1 + `,` + time2 + `,` +
537
+ var expectedJSON = `["one",` + time1 + `,` + time2 + `,` +
540
538
`[[{"name":"Supportability/C/Collector/Output/Bytes"},[25,5275,0,0,0,0]],` +
541
539
`[{"name":"Supportability/C/Collector/analytic_event_data/Output/Bytes"},[25,5275,0,0,0,0]]]]`
542
540
@@ -596,7 +594,7 @@ func TestSupportabilityHarvest(t *testing.T) {
596
594
// of harvests. So we extract the time from what we receive
597
595
time1 := strings .Split (string (cp1 .data ), "," )[1 ]
598
596
time2 := strings .Split (string (cp1 .data ), "," )[2 ]
599
- expectedJSON : = `["one",` + time1 + `,` + time2 + `,` +
597
+ var expectedJSON = `["one",` + time1 + `,` + time2 + `,` +
600
598
`[[{"name":"Instance/Reporting"},[2,0,0,0,0,0]],` +
601
599
`[{"name":"Supportability/Agent/Collector/HTTPError/408"},[1,0,0,0,0,0]],` + // Check for HTTPError Supportability metric
602
600
`[{"name":"Supportability/Agent/Collector/metric_data/Attempts"},[1,0,0,0,0,0]],` + // Metrics were sent first when the 408 error occurred, so check for the metric failure.
@@ -619,7 +617,7 @@ func TestSupportabilityHarvest(t *testing.T) {
619
617
time1 = strings .Split (string (cp2 .data ), "," )[1 ]
620
618
time2 = strings .Split (string (cp2 .data ), "," )[2 ]
621
619
// includes usage of the first data usage metrics sent
622
- expectedJSON2 : = `["one",` + time1 + `,` + time2 + `,` +
620
+ var expectedJSON2 = `["one",` + time1 + `,` + time2 + `,` +
623
621
`[[{"name":"Supportability/C/Collector/Output/Bytes"},[2,1584,0,0,0,0]],` +
624
622
`[{"name":"Supportability/C/Collector/metric_data/Output/Bytes"},[2,1584,0,0,0,0]]]]`
625
623
@@ -949,7 +947,7 @@ func TestProcessorHarvestSplitTxnEvents(t *testing.T) {
949
947
// usage metrics comparison
950
948
time1 := strings .Split (string (cp3 .data ), "," )[1 ]
951
949
time2 := strings .Split (string (cp3 .data ), "," )[2 ]
952
- expectedJSON : = `["one",` + time1 + `,` + time2 + `,` +
950
+ var expectedJSON = `["one",` + time1 + `,` + time2 + `,` +
953
951
`[[{"name":"Supportability/C/Collector/Output/Bytes"},[6,289520,0,0,0,0]],` +
954
952
`[{"name":"Supportability/C/Collector/analytic_event_data/Output/Bytes"},[5,288261,0,0,0,0]],` +
955
953
`[{"name":"Supportability/C/Collector/metric_data/Output/Bytes"},[1,1259,0,0,0,0]]]]`
@@ -1485,6 +1483,7 @@ func TestShouldConnect(t *testing.T) {
1485
1483
// Be aware the agentLimit will be scaled down by 12 (60/5) before being compared to the
1486
1484
// collectorLimit.
1487
1485
func runMockedCollectorHarvestLimitTest (t * testing.T , eventType string , agentLimit uint64 , collectorLimit uint64 , testName string ) {
1486
+
1488
1487
// setup non-zero agent limits for log events
1489
1488
// NOTE: This limit is based on a 60 second harvest period!
1490
1489
// So the actual value used to compare to the collector
@@ -1565,6 +1564,7 @@ func runMockedCollectorHarvestLimitTest(t *testing.T, eventType string, agentLim
1565
1564
}
1566
1565
1567
1566
func TestConnectNegotiateLogEventLimits (t * testing.T ) {
1567
+
1568
1568
// these tests exist for the log events (TestConnectNegotiateLogEventsLimit()) because at some point
1569
1569
// the collector would return the default limit (833) if 0 was passed as the log limit. These tests
1570
1570
// exercise logic in the daemon to enforce the smaller agent value
@@ -1573,9 +1573,11 @@ func TestConnectNegotiateLogEventLimits(t *testing.T) {
1573
1573
runMockedCollectorHarvestLimitTest (t , "log_event_data" , 100 * 12 , 100 , "agent log limit equal to collector" )
1574
1574
runMockedCollectorHarvestLimitTest (t , "log_event_data" , 0 , 100 , "agent log limit == 0, collector != 0" )
1575
1575
runMockedCollectorHarvestLimitTest (t , "log_event_data" , 100 * 12 , 0 , "agent log limit != 0, collector == 0" )
1576
+
1576
1577
}
1577
1578
1578
1579
func TestConnectNegotiateCustomEventLimits (t * testing.T ) {
1580
+
1579
1581
runMockedCollectorHarvestLimitTest (t , "custom_event_data" , 110 * 12 , 100 , "agent custom limit larger than collector" )
1580
1582
runMockedCollectorHarvestLimitTest (t , "custom_event_data" , 100 * 12 , 100 , "agent custom limit equal to collector" )
1581
1583
}
@@ -1598,6 +1600,7 @@ func TestProcessLogEventLimit(t *testing.T) {
1598
1600
}
1599
1601
1600
1602
func TestMissingAgentAndCollectorHarvestLimit (t * testing.T ) {
1603
+
1601
1604
// tests missing agent and collector harvest limits will not crash daemon
1602
1605
// and results in empty final harvest values
1603
1606
appInfo := sampleAppInfo
0 commit comments