| 55 | |
| 56 | |
| 57 | class TracingServerMiddlewareFactory(flight.ServerMiddlewareFactory): |
| 58 | def start_call(self, info, headers): |
| 59 | print("Starting new call:", info) |
| 60 | if TRACE_HEADER in headers: |
| 61 | trace_id = headers[TRACE_HEADER][0] |
| 62 | print("Found trace header with value:", trace_id) |
| 63 | TraceContext.set_trace_id(trace_id) |
| 64 | return TracingServerMiddleware(TraceContext.current_trace_id()) |
| 65 | |
| 66 | |
| 67 | class TracingClientMiddleware(flight.ClientMiddleware): |