| 1 |
# Copyright (c) 2016 Uber Technologies, Inc. |
| 2 |
# |
| 3 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
# you may not use this file except in compliance with the License. |
| 5 |
# You may obtain a copy of the License at |
| 6 |
# |
| 7 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
# |
| 9 |
# Unless required by applicable law or agreed to in writing, software |
| 10 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
# See the License for the specific language governing permissions and |
| 13 |
# limitations under the License. |
| 14 |
|
| 15 |
|
| 16 |
def trace_response_to_thriftrw(service, tr): |
| 17 |
if tr is None: |
| 18 |
return None |
| 19 |
return service.TraceResponse(span=observed_span_to_thriftrw(service, tr.span), |
| 20 |
downstream=trace_response_to_thriftrw(service, tr.downstream), |
| 21 |
notImplementedError=tr.notImplementedError or '') |
| 22 |
|
| 23 |
|
| 24 |
def downstream_to_thriftrw(service, downstream): |
| 25 |
if downstream is None: |
| 26 |
return None |
| 27 |
return service.Downstream(downstream.serviceName, |
| 28 |
downstream.serverRole, |
| 29 |
downstream.host, |
| 30 |
downstream.port, |
| 31 |
downstream.transport, |
| 32 |
downstream.downstream) |
| 33 |
|
| 34 |
|
| 35 |
def join_trace_request_to_thriftrw(service, jtr): |
| 36 |
return service.JoinTraceRequest(jtr.serverRole, downstream_to_thriftrw(service, jtr.downstream)) |
| 37 |
|
| 38 |
|
| 39 |
def observed_span_to_thriftrw(service, observed_span): |
| 40 |
return service.ObservedSpan(traceId=observed_span.traceId, |
| 41 |
sampled=observed_span.sampled, |
| 42 |
baggage=observed_span.baggage) |