Package io.grpc

Class StreamTracer

  • Direct Known Subclasses:
    ClientStreamTracer, ServerStreamTracer

    @ExperimentalApi("https://github.com/grpc/grpc-java/issues/2861")
    @ThreadSafe
    public abstract class StreamTracer
    extends java.lang.Object
    Listens to events on a stream to collect metrics.

    DO NOT MOCK: Use TestStreamTracer. Mocks are not thread-safe

    • Constructor Summary

      Constructors 
      Constructor Description
      StreamTracer()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void inboundMessage​(int seqNo)
      An inbound message has been received by the stream.
      void inboundMessageRead​(int seqNo, long optionalWireSize, long optionalUncompressedSize)
      An inbound message has been fully read from the transport.
      void inboundUncompressedSize​(long bytes)
      The uncompressed size of some inbound data is revealed.
      void inboundWireSize​(long bytes)
      The wire size of some inbound data is revealed.
      void outboundMessage​(int seqNo)
      An outbound message has been passed to the stream.
      void outboundMessageSent​(int seqNo, long optionalWireSize, long optionalUncompressedSize)
      An outbound message has been serialized and sent to the transport.
      void outboundUncompressedSize​(long bytes)
      The uncompressed size of some outbound data is revealed.
      void outboundWireSize​(long bytes)
      The wire size of some outbound data is revealed.
      void streamClosed​(Status status)
      Stream is closed.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StreamTracer

        public StreamTracer()
    • Method Detail

      • streamClosed

        public void streamClosed​(Status status)
        Stream is closed. This will be called exactly once.
      • outboundMessage

        public void outboundMessage​(int seqNo)
        An outbound message has been passed to the stream. This is called as soon as the stream knows about the message, but doesn't have further guarantee such as whether the message is serialized or not.
        Parameters:
        seqNo - the sequential number of the message within the stream, starting from 0. It can be used to correlate with outboundMessageSent(int, long, long) for the same message.
      • inboundMessage

        public void inboundMessage​(int seqNo)
        An inbound message has been received by the stream. This is called as soon as the stream knows about the message, but doesn't have further guarantee such as whether the message is deserialized or not.
        Parameters:
        seqNo - the sequential number of the message within the stream, starting from 0. It can be used to correlate with inboundMessageRead(int, long, long) for the same message.
      • outboundMessageSent

        public void outboundMessageSent​(int seqNo,
                                        long optionalWireSize,
                                        long optionalUncompressedSize)
        An outbound message has been serialized and sent to the transport.
        Parameters:
        seqNo - the sequential number of the message within the stream, starting from 0. It can be used to correlate with outboundMessage(int) for the same message.
        optionalWireSize - the wire size of the message. -1 if unknown
        optionalUncompressedSize - the uncompressed serialized size of the message. -1 if unknown
      • inboundMessageRead

        public void inboundMessageRead​(int seqNo,
                                       long optionalWireSize,
                                       long optionalUncompressedSize)
        An inbound message has been fully read from the transport.
        Parameters:
        seqNo - the sequential number of the message within the stream, starting from 0. It can be used to correlate with inboundMessage(int) for the same message.
        optionalWireSize - the wire size of the message. -1 if unknown
        optionalUncompressedSize - the uncompressed serialized size of the message. -1 if unknown
      • outboundWireSize

        public void outboundWireSize​(long bytes)
        The wire size of some outbound data is revealed. This can only used to record the accumulative outbound wire size. There is no guarantee wrt timing or granularity of this method.
      • outboundUncompressedSize

        public void outboundUncompressedSize​(long bytes)
        The uncompressed size of some outbound data is revealed. This can only used to record the accumulative outbound uncompressed size. There is no guarantee wrt timing or granularity of this method.
      • inboundWireSize

        public void inboundWireSize​(long bytes)
        The wire size of some inbound data is revealed. This can only be used to record the accumulative received wire size. There is no guarantee wrt timing or granularity of this method.
      • inboundUncompressedSize

        public void inboundUncompressedSize​(long bytes)
        The uncompressed size of some inbound data is revealed. This can only used to record the accumulative received uncompressed size. There is no guarantee wrt timing or granularity of this method.