2016-05-09 26 views
9

Sto cercando di capire perché la mia chiamata grpc non funziona, ma non riesco a capire come attivare il debug, così posso vedere i dati che vengono inviati e ricevuti tramite la connessione grpc.Come eseguire il debug della chiamata a grpc?

Come si attiva il debug per le chiamate grpc?

risposta

15

È possibile impostare la variabile GRPC_TRACE ambiente all avere grpc dump di un sacco di dati su ciò che il collegamento sta facendo:

export GRPC_TRACE=all 

Modifica dal commento: a quanto pare è anche necessario impostare:

export GRPC_VERBOSITY=DEBUG 
+0

Ho provato questo e non ho visto nulla nella console. C'è qualcos'altro che hai fatto nella tua applicazione per ottenere l'output? – PudgePacket

+2

Ah, trovato https://github.com/grpc/grpc/issues/7960#issuecomment-250801871 – PudgePacket

+0

https://github.com/grpc/grpc/blob/master/doc/environment_variables.md –

1

In Golang, è necessario impostare il GODEBUG environment variable per vedere HTTP2 tracce, vale a dire le intestazioni fissati dal gRPC:

GODEBUG=http2debug=1 # enable verbose HTTP/2 debug logs 
GODEBUG=http2debug=2 # ... even more verbose, with frame dumps 

L'output verrà quindi inviato a stdout. Ecco un esempio:

{"level":"info","msg":"2017/06/11 08:52:20 http2: Framer 0xc42009c0e0: wrote SETTINGS len=0","time":"2017-06-11T08:52:20Z"} 
{"level":"info","msg":"2017/06/11 08:52:20 http2: Framer 0xc42009c0e0: wrote WINDOW_UPDATE len=4 (conn) incr=983025","time":"2017-06-11T08:52:20Z"} 
{"level":"info","msg":"2017/06/11 08:52:20 http2: Framer 0xc42009c0e0: read SETTINGS len=18, settings: ENABLE_PUSH=0, MAX_CONCURRENT_STREAMS=0, INITIAL_WINDOW_SIZE=1048576","time":"2017-06-11T08:52:20Z"} 
{"level":"info","msg":"2017/06/11 08:52:20 http2: Framer 0xc42009c0e0: read WINDOW_UPDATE len=4 (conn) incr=983041","time":"2017-06-11T08:52:20Z"} 
{"level":"info","msg":"2017/06/11 08:52:20 http2: Framer 0xc42009c0e0: wrote SETTINGS flags=ACK len=0","time":"2017-06-11T08:52:20Z"} 
{"level":"info","msg":"2017/06/11 08:52:20 http2: Framer 0xc42009c0e0: read SETTINGS flags=ACK len=0","time":"2017-06-11T08:52:20Z"} 
{"level":"info","msg":"2017/06/11 08:52:20 http2: Framer 0xc42009c0e0: read HEADERS flags=END_HEADERS|PRIORITY stream=3 len=249","time":"2017-06-11T08:52:20Z"} 
{"level":"info","msg":"2017/06/11 08:52:20 http2: decoded hpack field header field \":authority\" = \"\"","time":"2017-06-11T08:52:20Z"} 
{"level":"info","msg":"2017/06/11 08:52:20 http2: decoded hpack field header field \":path\" = \"/internal.push.v1.UnifiedDevicePush/SendMessage\"","time":"2017-06-11T08:52:20Z"} 
{"level":"info","msg":"2017/06/11 08:52:20 http2: decoded hpack field header field \":method\" = \"POST\"","time":"2017-06-11T08:52:20Z"} 
{"level":"info","msg":"2017/06/11 08:52:20 http2: decoded hpack field header field \":scheme\" = \"http\"","time":"2017-06-11T08:52:20Z"} 
{"level":"info","msg":"2017/06/11 08:52:20 http2: decoded hpack field header field \"content-type\" = \"application/grpc\"","time":"2017-06-11T08:52:20Z"} 
{"level":"info","msg":"2017/06/11 08:52:20 http2: decoded hpack field header field \"te\" = \"trailers\"","time":"2017-06-11T08:52:20Z"} 
{"level":"info","msg":"2017/06/11 08:52:20 http2: decoded hpack field header field \"user-agent\" = \"grpc-java-netty/1.0.3\"","time":"2017-06-11T08:52:20Z"} 
{"level":"info","msg":"2017/06/11 08:52:20 http2: decoded hpack field header field \"root-common.xirequestid-bin\" = \"ChIJzE6lBfCTCsYRoIIJujc92JY=\"","time":"2017-06-11T08:52:20Z"} 
{"level":"info","msg":"2017/06/11 08:52:20 http2: decoded hpack field header field \"te\" = \"trailers\"","time":"2017-06-11T08:52:20Z"} 
+0

@Dominik - grazie per la modifica. Devo essere stato alto quando ho scritto questa risposta: / – FuzzyAmi