You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Robert Lu (Jira)" <ji...@apache.org> on 2024/11/15 02:52:00 UTC

[jira] [Created] (THRIFT-5834) The solution of trace/record an request at ThriftServer?

Robert Lu created THRIFT-5834:
---------------------------------

             Summary: The solution of trace/record an request at ThriftServer?
                 Key: THRIFT-5834
                 URL: https://issues.apache.org/jira/browse/THRIFT-5834
             Project: Thrift
          Issue Type: Question
          Components: Java - Library
    Affects Versions: 0.21.0
         Environment: * Thrift 0.21.0
 * Java 17
            Reporter: Robert Lu


I am using TThreadedSelectorServer as Thrift server, but I noticed, when the request is processing, it's impossiable to get remote ip at implement of AsyncIface.

The method siganature is
{code:java}
void methodName(request var1, AsyncMethodCallback var2) throws TException;
{code}
Cannot get remote ip from args or this.

So, I was trying to record remote ip in MDC, I found {{org.apache.thrift.server.TServerEventHandler#createContext}}

 

but the calling is following:
{code:java}
public FrameBuffer(
        final TNonblockingTransport trans,
        final SelectionKey selectionKey,
        final AbstractSelectThread selectThread)
        throws TTransportException {
      trans_ = trans;
      selectionKey_ = selectionKey;
      selectThread_ = selectThread;
      buffer_ = ByteBuffer.allocate(4);

      frameTrans_ = new TMemoryInputTransport();
      response_ = new TByteArrayOutputStream();
      inTrans_ = inputTransportFactory_.getTransport(frameTrans_);
      outTrans_ = outputTransportFactory_.getTransport(new TIOStreamTransport(response_));
      inProt_ = inputProtocolFactory_.getProtocol(inTrans_);
      outProt_ = outputProtocolFactory_.getProtocol(outTrans_);

      if (eventHandler_ != null) {
        context_ = eventHandler_.createContext(inProt_, outProt_);
      } else {
        context_ = null;
      }
    } {code}
I coud get remote ip from selectionKey, but still couldn't get remote-ip in {{eventHandler_.createContext}} .

 
 # Is there any way to record remote-ip and othere reuqest-related information, in interface implement, logging, trace?
 # Could we just use TNonblockingTransport in inProt_, not TMemoryInputTransport?
 # More generally, is there any plan to intergate with OpenTelemetry?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)