@@ -25,8 +25,9 @@ class FootprintForkedTest extends DDSpecification {
2525 setup :
2626 CountDownLatch latch = new CountDownLatch (1 )
2727 ValidatingSink sink = new ValidatingSink (latch)
28- DDAgentFeaturesDiscovery features = Mock (DDAgentFeaturesDiscovery )
29- features. supportsMetrics() >> true
28+ DDAgentFeaturesDiscovery features = Stub (DDAgentFeaturesDiscovery ) {
29+ it. supportsMetrics() >> true
30+ }
3031 ConflatingMetricsAggregator aggregator = new ConflatingMetricsAggregator (
3132 new WellKnownTags (" runtimeid" ," hostname" , " env" , " service" , " version" ," language" ),
3233 []. toSet() as Set<String > ,
@@ -35,8 +36,10 @@ class FootprintForkedTest extends DDSpecification {
3536 1000 ,
3637 1000 ,
3738 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)
4043 aggregator. start()
4144
4245 when : " lots of traces are published"
@@ -70,7 +73,8 @@ class FootprintForkedTest extends DDSpecification {
7073 assert latch. await(30 , SECONDS )
7174
7275 then :
73- footprint(aggregator) - baseline <= 10 * 1024 * 1024
76+ def layout = footprint(aggregator, features)
77+ layout. totalSize() - baseline. totalSize() <= 10 * 1024 * 1024
7478
7579 cleanup :
7680 aggregator. close()
@@ -134,9 +138,14 @@ class FootprintForkedTest extends DDSpecification {
134138 }
135139
136140
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
141150 }
142151}
0 commit comments