diff --git a/include/grpc/census.h b/include/grpc/census.h index 591d0dc52b7..ef6275fe58d 100644 --- a/include/grpc/census.h +++ b/include/grpc/census.h @@ -129,10 +129,14 @@ void census_set_trace_mask(int trace_mask); each logical operation. */ /** - This structure (opaquely) represents a timestamp as used by census to - record the time at which an RPC operation begins. + This structure represents a timestamp as used by census to record the time + at which an operation begins. */ -typedef struct census_timestamp census_timestamp; +typedef struct { + /* Use gpr_timespec for default implementation. High performance + * implementations should use a cycle-counter based timestamp. */ + gpr_timespec ts; +} census_timestamp; /** Mark the beginning of an RPC operation. The information required to call the @@ -148,7 +152,7 @@ typedef struct census_timestamp census_timestamp; @return A timestamp representing the operation start time. */ -census_timestamp *census_start_rpc_op_timestamp(void); +census_timestamp census_start_rpc_op_timestamp(void); /** Represent functions to map RPC name ID to service/method names. Census diff --git a/src/core/census/operation.c b/src/core/census/operation.c index a0196da6146..118eb0a47ad 100644 --- a/src/core/census/operation.c +++ b/src/core/census/operation.c @@ -34,7 +34,13 @@ /* TODO(aveitch): These are all placeholder implementations. */ -census_timestamp *census_start_rpc_op_timestamp(void) { return NULL; } +census_timestamp census_start_rpc_op_timestamp(void) { + census_timestamp ct; + /* TODO(aveitch): assumes gpr_timespec implementation of census_timestamp. */ + ct.ts = gpr_now(GPR_CLOCK_MONOTONIC); + return ct; +} + census_context *census_start_client_rpc_op( const census_context *context, gpr_int64 rpc_name_id, const census_rpc_name_info *rpc_name_info, const char *peer, int trace_mask,