diff --git a/include/grpc/census.h b/include/grpc/census.h index 362433739264260d3b3f85e7df83b485e51c7570..69507a8cf72a74e85dc8b6b947b8208660eefa9c 100644 --- a/include/grpc/census.h +++ b/include/grpc/census.h @@ -59,15 +59,15 @@ enum census_features { * census_initialize() will return a non-zero value. It is an error to call * census_initialize() more than once (without an intervening * census_shutdown()). */ -int census_initialize(int features); -void census_shutdown(void); +CENSUS_API int census_initialize(int features); +CENSUS_API void census_shutdown(void); /** Return the features supported by the current census implementation (not all * features will be available on all platforms). */ -int census_supported(void); +CENSUS_API int census_supported(void); /** Return the census features currently enabled. */ -int census_enabled(void); +CENSUS_API int census_enabled(void); /** A Census Context is a handle used by Census to represent the current tracing @@ -145,16 +145,16 @@ typedef struct { tags used in its creation. @return A new, valid census_context. */ -census_context *census_context_create(const census_context *base, - const census_tag *tags, int ntags, - census_context_status const **status); +CENSUS_API census_context *census_context_create( + const census_context *base, const census_tag *tags, int ntags, + census_context_status const **status); /* Destroy a context. Once this function has been called, the context cannot be reused. */ -void census_context_destroy(census_context *context); +CENSUS_API void census_context_destroy(census_context *context); /* Get a pointer to the original status from the context creation. */ -const census_context_status *census_context_get_status( +CENSUS_API const census_context_status *census_context_get_status( const census_context *context); /* Structure used for iterating over the tegs in a context. API clients should @@ -168,17 +168,18 @@ typedef struct { } census_context_iterator; /* Initialize a census_tag_iterator. Must be called before first use. */ -void census_context_initialize_iterator(const census_context *context, - census_context_iterator *iterator); +CENSUS_API void census_context_initialize_iterator( + const census_context *context, census_context_iterator *iterator); /* Get the contents of the "next" tag in the context. If there are no more tags, returns 0 (and 'tag' contents will be unchanged), otherwise returns 1. */ -int census_context_next_tag(census_context_iterator *iterator, census_tag *tag); +CENSUS_API int census_context_next_tag(census_context_iterator *iterator, + census_tag *tag); /* Get a context tag by key. Returns 0 if the key is not present. */ -int census_context_get_tag(const census_context *context, const char *key, - census_tag *tag); +CENSUS_API int census_context_get_tag(const census_context *context, + const char *key, census_tag *tag); /* Tag set encode/decode functionality. These functionas are intended for use by RPC systems only, for purposes of transmitting/receiving contexts. @@ -200,14 +201,17 @@ int census_context_get_tag(const census_context *context, const char *key, [buffer, buffer + *print_buf_size) and binary tags into [returned-ptr, returned-ptr + *bin_buf_size) (and the returned pointer should be buffer + *print_buf_size) */ -char *census_context_encode(const census_context *context, char *buffer, - size_t buf_size, size_t *print_buf_size, - size_t *bin_buf_size); +CENSUS_API char *census_context_encode(const census_context *context, + char *buffer, size_t buf_size, + size_t *print_buf_size, + size_t *bin_buf_size); /* Decode context buffers encoded with census_context_encode(). Returns NULL if there is an error in parsing either buffer. */ -census_context *census_context_decode(const char *buffer, size_t size, - const char *bin_buffer, size_t bin_size); +CENSUS_API census_context *census_context_decode(const char *buffer, + size_t size, + const char *bin_buffer, + size_t bin_size); /* Distributed traces can have a number of options. */ enum census_trace_mask_values { @@ -217,10 +221,10 @@ enum census_trace_mask_values { /** Get the current trace mask associated with this context. The value returned will be the logical or of census_trace_mask_values values. */ -int census_trace_mask(const census_context *context); +CENSUS_API int census_trace_mask(const census_context *context); /** Set the trace mask associated with a context. */ -void census_set_trace_mask(int trace_mask); +CENSUS_API void census_set_trace_mask(int trace_mask); /* The concept of "operation" is a fundamental concept for Census. In an RPC system, and operation typcially represents a single RPC, or a significant @@ -268,7 +272,7 @@ typedef struct { @return A timestamp representing the operation start time. */ -census_timestamp census_start_rpc_op_timestamp(void); +CENSUS_API census_timestamp census_start_rpc_op_timestamp(void); /** Represent functions to map RPC name ID to service/method names. Census @@ -320,7 +324,7 @@ typedef struct { @return A new census context. */ -census_context *census_start_client_rpc_op( +CENSUS_API census_context *census_start_client_rpc_op( const census_context *context, int64_t rpc_name_id, const census_rpc_name_info *rpc_name_info, const char *peer, int trace_mask, const census_timestamp *start_time); @@ -328,7 +332,8 @@ census_context *census_start_client_rpc_op( /** Add peer information to a context representing a client RPC operation. */ -void census_set_rpc_client_peer(census_context *context, const char *peer); +CENSUS_API void census_set_rpc_client_peer(census_context *context, + const char *peer); /** Start a server RPC operation. Returns a new context to be used in future @@ -348,7 +353,7 @@ void census_set_rpc_client_peer(census_context *context, const char *peer); @return A new census context. */ -census_context *census_start_server_rpc_op( +CENSUS_API census_context *census_start_server_rpc_op( const char *buffer, int64_t rpc_name_id, const census_rpc_name_info *rpc_name_info, const char *peer, int trace_mask, census_timestamp *start_time); @@ -378,8 +383,9 @@ census_context *census_start_server_rpc_op( @return A new census context. */ -census_context *census_start_op(census_context *context, const char *family, - const char *name, int trace_mask); +CENSUS_API census_context *census_start_op(census_context *context, + const char *family, const char *name, + int trace_mask); /** End an operation started by any of the census_start_*_op*() calls. The @@ -390,7 +396,7 @@ census_context *census_start_op(census_context *context, const char *family, @param status status associated with the operation. Not interpreted by census. */ -void census_end_op(census_context *context, int status); +CENSUS_API void census_end_op(census_context *context, int status); #define CENSUS_TRACE_RECORD_START_OP ((uint32_t)0) #define CENSUS_TRACE_RECORD_END_OP ((uint32_t)1) @@ -402,8 +408,8 @@ void census_end_op(census_context *context, int status); @param buffer Pointer to buffer to use @param n Number of bytes in buffer */ -void census_trace_print(census_context *context, uint32_t type, - const char *buffer, size_t n); +CENSUS_API void census_trace_print(census_context *context, uint32_t type, + const char *buffer, size_t n); /** Trace record. */ typedef struct { @@ -424,7 +430,7 @@ typedef struct { while scanning is ongoing. @returns 0 on success, non-zero on failure (e.g. if a scan is already ongoing) */ -int census_trace_scan_start(int consume); +CENSUS_API int census_trace_scan_start(int consume); /** Get a trace record. The data pointed to by the trace buffer is guaranteed stable until the next census_get_trace_record() call (if the consume @@ -435,10 +441,10 @@ int census_trace_scan_start(int consume); census_trace_scan_start()), 0 if there is no more trace data (and trace_record will not be modified) or 1 otherwise. */ -int census_get_trace_record(census_trace_record *trace_record); +CENSUS_API int census_get_trace_record(census_trace_record *trace_record); /** End a scan previously started by census_trace_scan_start() */ -void census_trace_scan_end(); +CENSUS_API void census_trace_scan_end(); /* Core stats collection API's. The following concepts are used: * Aggregation: A collection of values. Census supports the following @@ -469,8 +475,8 @@ typedef struct { } census_value; /* Record new usage values against the given context. */ -void census_record_values(census_context *context, census_value *values, - size_t nvalues); +CENSUS_API void census_record_values(census_context *context, + census_value *values, size_t nvalues); /** Type representing a particular aggregation */ typedef struct census_aggregation_ops census_aggregation_ops; @@ -502,24 +508,25 @@ typedef struct census_view census_view; */ /* TODO(aveitch): consider if context is the right argument type to pass in tags. */ -census_view *census_view_create(uint32_t metric_id, const census_context *tags, - const census_aggregation *aggregations, - size_t naggregations); +CENSUS_API census_view *census_view_create( + uint32_t metric_id, const census_context *tags, + const census_aggregation *aggregations, size_t naggregations); /** Destroy a previously created view. */ -void census_view_delete(census_view *view); +CENSUS_API void census_view_delete(census_view *view); /** Metric ID associated with a view */ -size_t census_view_metric(const census_view *view); +CENSUS_API size_t census_view_metric(const census_view *view); /** Number of aggregations associated with view. */ -size_t census_view_naggregations(const census_view *view); +CENSUS_API size_t census_view_naggregations(const census_view *view); /** Get tags associated with view. */ -const census_context *census_view_tags(const census_view *view); +CENSUS_API const census_context *census_view_tags(const census_view *view); /** Get aggregation descriptors associated with a view. */ -const census_aggregation *census_view_aggregrations(const census_view *view); +CENSUS_API const census_aggregation *census_view_aggregrations( + const census_view *view); /** Holds all the aggregation data for a particular view instantiation. Forms part of the data returned by census_view_data(). */ @@ -538,10 +545,11 @@ typedef struct { @param view View from which to get data. @return Full set of data for all aggregations for the view. */ -const census_view_data *census_view_get_data(const census_view *view); +CENSUS_API const census_view_data *census_view_get_data( + const census_view *view); /** Reset all view data to zero for the specified view */ -void census_view_reset(census_view *view); +CENSUS_API void census_view_reset(census_view *view); #ifdef __cplusplus }