Created
May 31, 2017 14:13
-
-
Save mainroach/61f2f8d16e3ee76b89fabcd1b4f0e2c1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TraceContext(object): | |
def write(self): | |
… | |
# Breakup our given cloud tracing context so we can get the flags out of it | |
trace_id, root_span_id = self.cloud_trace_context.split(';')[0].split('/') | |
# Grab our spans object as a json blob | |
spans = [s.json() for s in _trace_context.spans] | |
#catch | |
if len(spans)==0: | |
spans.append({"spanId":16384}) | |
for s in spans: | |
s['parentSpanId'] = root_span_id | |
traces_body = { | |
'projectId': projectId, | |
'traceId': trace_id, | |
'spans': spans | |
} | |
body={ | |
"traces":[traces_body] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment