@@ -25,8 +25,9 @@ class FootprintForkedTest extends DDSpecification {
25
25
setup :
26
26
CountDownLatch latch = new CountDownLatch (1 )
27
27
ValidatingSink sink = new ValidatingSink (latch)
28
- DDAgentFeaturesDiscovery features = Mock (DDAgentFeaturesDiscovery )
29
- features. supportsMetrics() >> true
28
+ DDAgentFeaturesDiscovery features = Stub (DDAgentFeaturesDiscovery ) {
29
+ it. supportsMetrics() >> true
30
+ }
30
31
ConflatingMetricsAggregator aggregator = new ConflatingMetricsAggregator (
31
32
new WellKnownTags (" runtimeid" ," hostname" , " env" , " service" , " version" ," language" ),
32
33
[]. toSet() as Set<String > ,
@@ -35,8 +36,10 @@ class FootprintForkedTest extends DDSpecification {
35
36
1000 ,
36
37
1000 ,
37
38
100 ,
38
- SECONDS )
39
- long baseline = footprint(aggregator)
39
+ SECONDS
40
+ )
41
+ // Removing the 'features' as it's a mock, and mocks are heavyweight, e.g. around 22MiB
42
+ def baseline = footprint(aggregator, features)
40
43
aggregator. start()
41
44
42
45
when : " lots of traces are published"
@@ -70,7 +73,8 @@ class FootprintForkedTest extends DDSpecification {
70
73
assert latch. await(30 , SECONDS )
71
74
72
75
then :
73
- footprint(aggregator) - baseline <= 10 * 1024 * 1024
76
+ def layout = footprint(aggregator, features)
77
+ layout. totalSize() - baseline. totalSize() <= 10 * 1024 * 1024
74
78
75
79
cleanup :
76
80
aggregator. close()
@@ -134,9 +138,14 @@ class FootprintForkedTest extends DDSpecification {
134
138
}
135
139
136
140
137
- static long footprint (Object o ) {
138
- GraphLayout layout = GraphLayout . parseInstance(o)
139
- System . err. println (layout. toFootprint())
140
- return layout. totalSize()
141
+ static GraphLayout footprint (Object root , Object ... excludedRootFieldInstance ) {
142
+ GraphLayout layout = GraphLayout . parseInstance(root)
143
+
144
+ excludedRootFieldInstance. each {
145
+ layout = layout. subtract(GraphLayout . parseInstance(it))
146
+ }
147
+
148
+ println layout. toFootprint()
149
+ return layout
141
150
}
142
151
}
0 commit comments