From 851032a7ae03796eda80f0fe63bdafd8a20f38bb Mon Sep 17 00:00:00 2001 From: Alistair Veitch Date: Mon, 20 Jul 2015 11:59:13 -0700 Subject: [PATCH] address comments --- build.json | 2 +- include/grpc/census.h | 12 ++++++++-- src/core/census/record_stat.c | 6 ++--- .../census/{resource_id.h => rpc_stat_id.h} | 24 +++++++++---------- 4 files changed, 25 insertions(+), 19 deletions(-) rename src/core/census/{resource_id.h => rpc_stat_id.h} (66%) diff --git a/build.json b/build.json index a1104c6d88a..9bb27d75797 100644 --- a/build.json +++ b/build.json @@ -19,7 +19,7 @@ ], "headers": [ "src/core/census/context.h", - "src/core/census/resource_id.h" + "src/core/census/rpc_stat_id.h" ], "src": [ "src/core/census/context.c", diff --git a/include/grpc/census.h b/include/grpc/census.h index 9271d4f6a78..379783905aa 100644 --- a/include/grpc/census.h +++ b/include/grpc/census.h @@ -100,8 +100,16 @@ int census_context_deserialize(const char *buffer, census_context **context); * future census calls will result in undefined behavior. */ void census_context_destroy(census_context *context); -/* Record a new value against the given stats ID and context. */ -void census_record_stat(census_context *context, int resource_id, double value); +/* A census statistic to be recorded comprises two parts: an ID for the + * particular statistic and the value to be recorded against it. */ +typedef struct { + int id; + double value; +} census_stat; + +/* Record new stats against the given context. */ +void census_record_stat(census_context *context, census_stat *stats, + size_t nstats); #ifdef __cplusplus } diff --git a/src/core/census/record_stat.c b/src/core/census/record_stat.c index 7d5a350c49c..3dd918618b6 100644 --- a/src/core/census/record_stat.c +++ b/src/core/census/record_stat.c @@ -32,7 +32,7 @@ */ #include -#include "src/core/census/resource_id.h" +#include "src/core/census/rpc_stat_id.h" -void census_record_stat(census_context *context, int resource_id, - double value) {} +void census_record_stat(census_context *context, census_stat *stats, + size_t nstats) {} diff --git a/src/core/census/resource_id.h b/src/core/census/rpc_stat_id.h similarity index 66% rename from src/core/census/resource_id.h rename to src/core/census/rpc_stat_id.h index 89c31df311b..fc0aa6f43f6 100644 --- a/src/core/census/resource_id.h +++ b/src/core/census/rpc_stat_id.h @@ -31,18 +31,16 @@ * */ -#ifndef CENSUS_RESOURCE_ID_H -#define CENSUS_RESOURCE_ID_H +#ifndef CENSUS_RPC_STAT_ID_H +#define CENSUS_RPC_STAT_ID_H -/* Resource ID's used for census measurements. */ -#define RESOURCE_INVALID 0 /* Make default be invalid. */ -#define RESOURCE_RPC_CLIENT_REQUESTS 1 /* Count of client requests sent. */ -#define RESOURCE_RPC_SERVER_REQUESTS 2 /* Count of server requests sent. */ -#define RESOURCE_RPC_CLIENT_ERRORS 3 /* Client error counts. */ -#define RESOURCE_RPC_SERVER_ERRORS 4 /* Server error counts. */ -#define RESOURCE_RPC_CLIENT_LATENCY 5 /* Client side request latency. */ -#define RESOURCE_RPC_SERVER_LATENCY 6 /* Server side request latency. */ -#define RESOURCE_RPC_CLIENT_CPU 7 /* Client CPU processing time. */ -#define RESOURCE_RPC_SERVER_CPU 8 /* Server CPU processing time. */ +/* Stats ID's used for RPC measurements. */ +#define CENSUS_INVALID_STAT_ID 0 /* ID 0 is always invalid */ +#define CENSUS_RPC_CLIENT_REQUESTS 1 /* Count of client requests sent. */ +#define CENSUS_RPC_SERVER_REQUESTS 2 /* Count of server requests sent. */ +#define CENSUS_RPC_CLIENT_ERRORS 3 /* Client error counts. */ +#define CENSUS_RPC_SERVER_ERRORS 4 /* Server error counts. */ +#define CENSUS_RPC_CLIENT_LATENCY 5 /* Client side request latency. */ +#define CENSUS_RPC_SERVER_LATENCY 6 /* Server side request latency. */ -#endif /* CENSUS_RESOURCE_ID_H */ +#endif /* CENSUS_RPC_STAT_ID_H */