5959import static io .trino .filesystem .tracing .CacheSystemAttributes .CACHE_FILE_WRITE_POSITION ;
6060import static io .trino .filesystem .tracing .CacheSystemAttributes .CACHE_FILE_WRITE_SIZE ;
6161import static io .trino .filesystem .tracing .CacheSystemAttributes .CACHE_KEY ;
62+ import static io .trino .filesystem .tracing .FileSystemAttributes .FILE_LOCATION ;
63+ import static io .trino .filesystem .tracing .FileSystemAttributes .FILE_READ_POSITION ;
64+ import static io .trino .filesystem .tracing .FileSystemAttributes .FILE_READ_SIZE ;
6265import static io .trino .testing .MultisetAssertions .assertMultisetsEqual ;
66+ import static java .util .Objects .requireNonNull ;
6367import static java .util .stream .Collectors .toCollection ;
6468import static org .assertj .core .api .Assertions .assertThat ;
6569
@@ -128,7 +132,7 @@ public void testCache()
128132 .addCopies (new CacheOperationSpan ("AlluxioCacheManager.get" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), 0 , 11 ), readTimes )
129133 .add (new CacheOperationSpan ("AlluxioCacheManager.put" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), 0 , 11 ))
130134 .add (new CacheOperationSpan ("Alluxio.writeCache" , location .toString (), 11 ))
131- .add (new CacheOperationSpan ("Alluxio.readExternal " , location .toString (), 11 ))
135+ .add (new CacheOperationSpan ("Input.readFully " , location .toString (), 11 ))
132136 .build ());
133137
134138 byte [] modifiedContent = "modified content" .getBytes (StandardCharsets .UTF_8 );
@@ -140,7 +144,7 @@ public void testCache()
140144 readTimes = 7 ;
141145 assertCacheOperations (location , modifiedContent , readTimes ,
142146 ImmutableMultiset .<CacheOperationSpan >builder ()
143- .add (new CacheOperationSpan ("Alluxio.readExternal " , location .toString (), 16 ))
147+ .add (new CacheOperationSpan ("Input.readFully " , location .toString (), 16 ))
144148 .add (new CacheOperationSpan ("Alluxio.writeCache" , location .toString (), 16 ))
145149 .add (new CacheOperationSpan ("AlluxioCacheManager.put" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), 0 , 16 ))
146150 .addCopies (new CacheOperationSpan ("AlluxioCacheManager.get" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), 0 , 16 ), readTimes )
@@ -165,7 +169,7 @@ public void testPartialCacheHits()
165169 ImmutableMultiset .<CacheOperationSpan >builder ()
166170 .add (new CacheOperationSpan ("Alluxio.readCached" , "memory:///partial" , 0 , PAGE_SIZE ))
167171 .add (new CacheOperationSpan ("AlluxioCacheManager.get" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), 0 , PAGE_SIZE ))
168- .add (new CacheOperationSpan ("Alluxio.readExternal " , location .toString (), 0 , PAGE_SIZE ))
172+ .add (new CacheOperationSpan ("Input.readFully " , location .toString (), 0 , PAGE_SIZE ))
169173 .add (new CacheOperationSpan ("Alluxio.writeCache" , location .toString (), 0 , PAGE_SIZE ))
170174 .add (new CacheOperationSpan ("AlluxioCacheManager.put" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), 0 , PAGE_SIZE ))
171175 .build ());
@@ -175,7 +179,7 @@ public void testPartialCacheHits()
175179 .add (new CacheOperationSpan ("Alluxio.readCached" , location .toString (), 0 , PAGE_SIZE + 10 ))
176180 .add (new CacheOperationSpan ("AlluxioCacheManager.get" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), 0 , PAGE_SIZE ))
177181 .add (new CacheOperationSpan ("AlluxioCacheManager.get" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), PAGE_SIZE , PAGE_SIZE ))
178- .add (new CacheOperationSpan ("Alluxio.readExternal " , location .toString (), PAGE_SIZE , 10 ))
182+ .add (new CacheOperationSpan ("Input.readFully " , location .toString (), PAGE_SIZE , PAGE_SIZE ))
179183 .add (new CacheOperationSpan ("Alluxio.writeCache" , location .toString (), PAGE_SIZE , PAGE_SIZE ))
180184 .add (new CacheOperationSpan ("AlluxioCacheManager.put" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), PAGE_SIZE , PAGE_SIZE ))
181185 .build ());
@@ -214,7 +218,7 @@ public void testMultiPageExternalsReads()
214218 .add (new CacheOperationSpan ("AlluxioCacheManager.put" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), 0 , PAGE_SIZE ))
215219 .add (new CacheOperationSpan ("AlluxioCacheManager.put" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), PAGE_SIZE , PAGE_SIZE ))
216220 .add (new CacheOperationSpan ("Alluxio.readCached" , location .toString (), PAGE_SIZE + 1 ))
217- .add (new CacheOperationSpan ("Alluxio.readExternal " , location .toString (), PAGE_SIZE + 1 ))
221+ .add (new CacheOperationSpan ("Input.readFully " , location .toString (), PAGE_SIZE * 2 ))
218222 .add (new CacheOperationSpan ("Alluxio.writeCache" , location .toString (), PAGE_SIZE * 2 ))
219223 .build ());
220224 cacheKeyProvider .increaseCacheVersion ();
@@ -223,7 +227,7 @@ public void testMultiPageExternalsReads()
223227 .add (new CacheOperationSpan ("AlluxioCacheManager.get" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), 0 , PAGE_SIZE ))
224228 .add (new CacheOperationSpan ("AlluxioCacheManager.put" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), 0 , PAGE_SIZE ))
225229 .add (new CacheOperationSpan ("AlluxioCacheManager.put" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), PAGE_SIZE , PAGE_SIZE ))
226- .add (new CacheOperationSpan ("Alluxio.readExternal " , location .toString (), 2 * PAGE_SIZE ))
230+ .add (new CacheOperationSpan ("Input.readFully " , location .toString (), 2 * PAGE_SIZE ))
227231 .add (new CacheOperationSpan ("Alluxio.readCached" , location .toString (), 2 * PAGE_SIZE ))
228232 .add (new CacheOperationSpan ("Alluxio.writeCache" , location .toString (), 2 * PAGE_SIZE ))
229233 .build ());
@@ -276,7 +280,7 @@ public void testCacheWithMissingPage()
276280 .addCopies (new CacheOperationSpan ("AlluxioCacheManager.get" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), 0 , 12 ), readTimes )
277281 .add (new CacheOperationSpan ("AlluxioCacheManager.put" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), 0 , 12 ))
278282 .add (new CacheOperationSpan ("Alluxio.writeCache" , location .toString (), 12 ))
279- .add (new CacheOperationSpan ("Alluxio.readExternal " , location .toString (), 12 ))
283+ .add (new CacheOperationSpan ("Input.readFully " , location .toString (), 12 ))
280284 .build ());
281285
282286 TrinoInputFile inputFile = fileSystem .newInputFile (location );
@@ -289,7 +293,7 @@ public void testCacheWithMissingPage()
289293 ImmutableMultiset .<CacheOperationSpan >builder ()
290294 .add (new CacheOperationSpan ("Alluxio.readCached" , location .toString (), 12 ))
291295 .add (new CacheOperationSpan ("AlluxioCacheManager.get" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), 12 ))
292- .add (new CacheOperationSpan ("Alluxio.readExternal " , location .toString (), 12 ))
296+ .add (new CacheOperationSpan ("Input.readFully " , location .toString (), 12 ))
293297 .add (new CacheOperationSpan ("Alluxio.writeCache" , location .toString (), 12 ))
294298 .add (new CacheOperationSpan ("AlluxioCacheManager.put" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), 0 , 12 ))
295299 .build ());
@@ -313,7 +317,7 @@ public void testCacheWithCorruptedPage()
313317 .addCopies (new CacheOperationSpan ("AlluxioCacheManager.get" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), 0 , 14 ), readTimes )
314318 .add (new CacheOperationSpan ("AlluxioCacheManager.put" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), 0 , 14 ))
315319 .add (new CacheOperationSpan ("Alluxio.writeCache" , location .toString (), 14 ))
316- .add (new CacheOperationSpan ("Alluxio.readExternal " , location .toString (), 14 ))
320+ .add (new CacheOperationSpan ("Input.readFully " , location .toString (), 14 ))
317321 .build ());
318322
319323 TrinoInputFile inputFile = fileSystem .newInputFile (location );
@@ -326,7 +330,7 @@ public void testCacheWithCorruptedPage()
326330 ImmutableMultiset .<CacheOperationSpan >builder ()
327331 .add (new CacheOperationSpan ("Alluxio.readCached" , location .toString (), 14 ))
328332 .add (new CacheOperationSpan ("AlluxioCacheManager.get" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), 14 ))
329- .add (new CacheOperationSpan ("Alluxio.readExternal " , location .toString (), 14 ))
333+ .add (new CacheOperationSpan ("Input.readFully " , location .toString (), 14 ))
330334 .add (new CacheOperationSpan ("Alluxio.writeCache" , location .toString (), 14 ))
331335 .add (new CacheOperationSpan ("AlluxioCacheManager.put" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), 0 , 14 ))
332336 .build ());
@@ -366,7 +370,7 @@ private void assertUnCachedRead(Location location, int fileSize)
366370 ImmutableMultiset .Builder <CacheOperationSpan > builder = ImmutableMultiset .<CacheOperationSpan >builder ()
367371 .add (new CacheOperationSpan ("Alluxio.readCached" , location .toString (), fileSize ))
368372 .add (new CacheOperationSpan ("Alluxio.writeCache" , location .toString (), fileSize ))
369- .add (new CacheOperationSpan ("Alluxio.readExternal " , location .toString (), fileSize ));
373+ .add (new CacheOperationSpan ("Input.readFully " , location .toString (), fileSize ));
370374
371375 for (int offset = 0 ; offset < fileSize ; offset = offset + PAGE_SIZE ) {
372376 builder .add (new CacheOperationSpan ("AlluxioCacheManager.put" , cacheKey (location , cacheKeyProvider .currentCacheVersion ()), offset , PAGE_SIZE ));
@@ -412,8 +416,9 @@ private void assertCacheOperations(Location location, byte[] content, int readTi
412416
413417 private Multiset <CacheOperationSpan > getCacheOperations (List <SpanData > spans )
414418 {
415- return spans .stream ().filter (span -> span .getName ().startsWith ("Alluxio" ))
416- .map (CacheOperationSpan ::create )
419+ return spans .stream ()
420+ .filter (span -> span .getName ().startsWith ("Input." ) || span .getName ().startsWith ("Alluxio" ))
421+ .map (CacheOperationSpan ::create )
417422 .collect (toCollection (HashMultiset ::create ));
418423 }
419424
@@ -429,18 +434,20 @@ public static CacheOperationSpan create(SpanData span)
429434 Attributes attributes = span .getAttributes ();
430435
431436 long length = switch (span .getName ()) {
432- case "Alluxio.readCached" , "Alluxio.readExternal " , "AlluxioCacheManager.get" -> attributes .get (CACHE_FILE_READ_SIZE );
437+ case "Alluxio.readCached" , "Alluxio.readExternalStream " , "AlluxioCacheManager.get" -> attributes .get (CACHE_FILE_READ_SIZE );
433438 case "Alluxio.writeCache" , "AlluxioCacheManager.put" -> attributes .get (CACHE_FILE_WRITE_SIZE );
439+ case "Input.readFully" -> attributes .get (FILE_READ_SIZE );
434440 default -> throw new IllegalArgumentException ("Unrecognized span " + span .getName () + " [" + span .getAttributes () + "]" );
435441 };
436442
437443 long position = switch (span .getName ()) {
438- case "Alluxio.readCached" , "Alluxio.readExternal " , "AlluxioCacheManager.get" -> attributes .get (CACHE_FILE_READ_POSITION );
444+ case "Alluxio.readCached" , "Alluxio.readExternalStream " , "AlluxioCacheManager.get" -> attributes .get (CACHE_FILE_READ_POSITION );
439445 case "Alluxio.writeCache" , "AlluxioCacheManager.put" -> attributes .get (CACHE_FILE_WRITE_POSITION );
446+ case "Input.readFully" -> attributes .get (FILE_READ_POSITION );
440447 default -> throw new IllegalArgumentException ("Unrecognized span " + span .getName () + " [" + span .getAttributes () + "]" );
441448 };
442449
443- return new CacheOperationSpan (span .getName (), firstNonNull ( attributes . get ( CACHE_FILE_LOCATION ), attributes . get ( CACHE_KEY ) ), position , length );
450+ return new CacheOperationSpan (span .getName (), getLocation ( span ), position , length );
444451 }
445452
446453 @ Override
@@ -454,4 +461,12 @@ private static String cacheKey(Location location, int cacheVersion)
454461 {
455462 return testingCacheKeyForLocation (location , cacheVersion );
456463 }
464+
465+ private static String getLocation (SpanData span )
466+ {
467+ if (span .getName ().startsWith ("Input." )) {
468+ return requireNonNull (span .getAttributes ().get (FILE_LOCATION ));
469+ }
470+ return firstNonNull (span .getAttributes ().get (CACHE_FILE_LOCATION ), span .getAttributes ().get (CACHE_KEY ));
471+ }
457472}
0 commit comments