Skip to content

Commit

Permalink
Improve Trace for Content and Node API #10033
Browse files Browse the repository at this point in the history
  • Loading branch information
rymsha committed Feb 13, 2023
1 parent 80ca049 commit c859147
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,12 @@ public ByteSource getBinary( final ContentId contentId, final BinaryReference bi
return Tracer.trace( "content.getBinary", trace -> {
trace.put( "id", contentId );
trace.put( "reference", binaryReference );
}, command::execute, ( trace, byteSource ) -> trace.put( "size", byteSource.sizeIfKnown().or( -1L ) ) );
}, command::execute, ( trace, byteSource ) -> {
if ( byteSource != null )
{
trace.put( "size", byteSource.sizeIfKnown().or( -1L ) );
}
} );
}

@Override
Expand All @@ -1132,7 +1137,12 @@ public ByteSource getBinary( final ContentId contentId, final ContentVersionId c
trace.put( "id", contentId );
trace.put( "versionId", contentVersionId );
trace.put( "reference", binaryReference );
}, command::execute, ( trace, byteSource ) -> trace.put( "size", byteSource.sizeIfKnown().or( -1L ) ) );
}, command::execute, ( trace, byteSource ) -> {
if ( byteSource != null )
{
trace.put( "size", byteSource.sizeIfKnown().or( -1L ) );
}
} );
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,12 @@ private Node doGetById( final NodeId id )
@Override
public Node getByPath( final NodePath path )
{
return Tracer.trace( "node.getByPath", trace -> trace.put( "path", path ), () -> executeGetByPath( path ),
( trace, node ) -> trace.put( "id", node.id() ) );
return Tracer.trace( "node.getByPath", trace -> trace.put( "path", path ), () -> executeGetByPath( path ), ( trace, node ) -> {
if ( node != null )
{
trace.put( "id", node.id() );
}
} );
}

private Node executeGetByPath( final NodePath path )
Expand Down Expand Up @@ -806,7 +810,12 @@ public ByteSource getBinary( final NodeId nodeId, final BinaryReference referenc
return Tracer.trace( "node.getBinary", trace -> {
trace.put( "id", nodeId );
trace.put( "reference", reference );
}, () -> executeGetBinary( nodeId, reference ), ( trace, byteSource ) -> trace.put( "size", byteSource.sizeIfKnown().or( -1L ) ) );
}, () -> executeGetBinary( nodeId, reference ), ( trace, byteSource ) -> {
if ( byteSource != null )
{
trace.put( "size", byteSource.sizeIfKnown().or( -1L ) );
}
} );
}

private ByteSource executeGetBinary( final NodeId nodeId, final BinaryReference reference )
Expand All @@ -827,11 +836,15 @@ private ByteSource executeGetBinary( final NodeId nodeId, final BinaryReference
public ByteSource getBinary( final NodeId nodeId, final NodeVersionId nodeVersionId, final BinaryReference reference )
{
return Tracer.trace( "node.getBinary", trace -> {
trace.put( "id", nodeId );
trace.put( "versionId", nodeVersionId );
trace.put( "reference", reference );
}, () -> executeGetBinary( nodeId, nodeVersionId, reference ),
( trace, byteSource ) -> trace.put( "size", byteSource.sizeIfKnown().or( -1L ) ) );
trace.put( "id", nodeId );
trace.put( "versionId", nodeVersionId );
trace.put( "reference", reference );
}, () -> executeGetBinary( nodeId, nodeVersionId, reference ), ( trace, byteSource ) -> {
if ( byteSource != null )
{
trace.put( "size", byteSource.sizeIfKnown().or( -1L ) );
}
} );
}

private ByteSource executeGetBinary( final NodeId nodeId, final NodeVersionId nodeVersionId, final BinaryReference reference )
Expand Down

0 comments on commit c859147

Please sign in to comment.