Skip to content

Commit

Permalink
resolved aditya's questions
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianlin-Zhao committed Aug 21, 2020
1 parent 185e8a3 commit 432ab0d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions api/include/opentelemetry/trace/propagation/http_trace_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,9 @@ class HttpTraceContext : public HTTPTextFormat<T>
}
}

static uint8_t[] GenerateBuffer(nostd::string_view string, int bytes)
static void GenerateBuffer(nostd::string_view string, int bytes, uint8_t[] buffer)
{
const char *str_id = string.begin();
uint8_t buf[bytes / 2];
for (int i = 0; i < bytes; i++)
{
int tmp = HexToInt(str_id[i]);
Expand All @@ -122,12 +121,16 @@ class HttpTraceContext : public HTTPTextFormat<T>

static TraceId GenerateTraceIdFromString(nostd::string_view trace_id)
{
return TraceId(GenerateBuffer(trace_id, kTraceIdBytes));
uint8_t buf[kTraceIdBytes / 2];
GenerateBuffer(trace_id, kTraceIdBytes, buf);
return TraceId(buf);
}

static SpanId GenerateSpanIdFromString(nostd::string_view span_id)
{
return SpanId(GenerateBuffer(span_id, kSpanIdBytes));
uint8_t buf[kSpanIdBytes / 2];
GenerateBuffer(span_id, kSpanIdBytes, buf);
return SpanId(buf);
}

static TraceFlags GenerateTraceFlagsFromString(nostd::string_view trace_flags)
Expand Down

0 comments on commit 432ab0d

Please sign in to comment.