Skip to content

Commit

Permalink
Changes in zipkin reporter related to concrete time in rust
Browse files Browse the repository at this point in the history
  • Loading branch information
cattibrie authored and pierrechevalier83 committed Aug 7, 2019
1 parent f3f2c12 commit 0403383
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/python/pants/engine/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,15 @@ def extern_store_utf8(self, context_handle, utf8_ptr, utf8_len):
c = self._ffi.from_handle(context_handle)
return c.to_value(self._ffi.string(utf8_ptr, utf8_len).decode())

@_extern_decl('Handle', ['ExternContext*', 'uint64_t'])
def extern_store_u64(self, context_handle, u64):
"""Given a context and uint64_t, return a new Handle to represent the uint64_t."""
c = self._ffi.from_handle(context_handle)
return c.to_value(u64)

@_extern_decl('Handle', ['ExternContext*', 'int64_t'])
def extern_store_i64(self, context_handle, i64):
"""Given a context and int32_t, return a new Handle to represent the int32_t."""
"""Given a context and int64_t, return a new Handle to represent the int64_t."""
c = self._ffi.from_handle(context_handle)
return c.to_value(i64)

Expand Down Expand Up @@ -683,6 +689,7 @@ def init_externs():
self.ffi_lib.extern_store_dict,
self.ffi_lib.extern_store_bytes,
self.ffi_lib.extern_store_utf8,
self.ffi_lib.extern_store_u64,
self.ffi_lib.extern_store_i64,
self.ffi_lib.extern_store_f64,
self.ffi_lib.extern_store_bool,
Expand Down
17 changes: 15 additions & 2 deletions src/python/pants/reporting/zipkin_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

logger = logging.getLogger(__name__)

NANOSECONDS_PER_SECOND = 1000000000.0


class HTTPTransportHandler(BaseTransportHandler):
def __init__(self, endpoint):
Expand Down Expand Up @@ -156,7 +158,14 @@ def close(self):
def bulk_record_workunits(self, engine_workunits):
"""A collection of workunits from v2 engine part"""
for workunit in engine_workunits:
duration = workunit['end_timestamp'] - workunit['start_timestamp']
start_timestamp = from_secs_and_nanos_to_float(
workunit['start_secs'],
workunit['start_nanos']
)
duration = from_secs_and_nanos_to_float(
workunit['duration_secs'],
workunit['duration_nanos']
)

local_tracer = get_default_tracer()

Expand All @@ -176,5 +185,9 @@ def bulk_record_workunits(self, engine_workunits):
flags='0', # flags: stores flags header. Currently unused
is_sampled=True,
)
span.start_timestamp = workunit['start_timestamp']
span.start_timestamp = start_timestamp
span.stop()


def from_secs_and_nanos_to_float(secs, nanos):
return secs + ( nanos / NANOSECONDS_PER_SECOND )

0 comments on commit 0403383

Please sign in to comment.