diff options
-rw-r--r-- | BUILD | 3 | ||||
-rw-r--r-- | build.json | 1 | ||||
-rw-r--r-- | gRPC.podspec | 2 | ||||
-rw-r--r-- | include/grpc/census.h | 32 | ||||
-rw-r--r-- | src/core/census/aggregation.h | 66 | ||||
-rw-r--r-- | tools/doxygen/Doxyfile.core.internal | 1 | ||||
-rw-r--r-- | tools/run_tests/sources_and_headers.json | 4 | ||||
-rw-r--r-- | vsprojects/grpc/grpc.vcxproj | 1 | ||||
-rw-r--r-- | vsprojects/grpc/grpc.vcxproj.filters | 3 | ||||
-rw-r--r-- | vsprojects/grpc_unsecure/grpc_unsecure.vcxproj | 1 | ||||
-rw-r--r-- | vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters | 3 |
11 files changed, 89 insertions, 28 deletions
@@ -245,6 +245,7 @@ cc_library( "src/core/transport/stream_op.h", "src/core/transport/transport.h", "src/core/transport/transport_impl.h", + "src/core/census/aggregation.h", "src/core/census/context.h", "src/core/census/rpc_metric_id.h", "src/core/httpcli/httpcli_security_connector.c", @@ -514,6 +515,7 @@ cc_library( "src/core/transport/stream_op.h", "src/core/transport/transport.h", "src/core/transport/transport_impl.h", + "src/core/census/aggregation.h", "src/core/census/context.h", "src/core/census/rpc_metric_id.h", "src/core/surface/init_unsecure.c", @@ -1271,6 +1273,7 @@ objc_library( "src/core/transport/stream_op.h", "src/core/transport/transport.h", "src/core/transport/transport_impl.h", + "src/core/census/aggregation.h", "src/core/census/context.h", "src/core/census/rpc_metric_id.h", ], diff --git a/build.json b/build.json index d62a7f34b8..644253afc8 100644 --- a/build.json +++ b/build.json @@ -18,6 +18,7 @@ "include/grpc/census.h" ], "headers": [ + "src/core/census/aggregation.h", "src/core/census/context.h", "src/core/census/rpc_metric_id.h" ], diff --git a/gRPC.podspec b/gRPC.podspec index ff191c5073..d0e1e2d848 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -247,6 +247,7 @@ Pod::Spec.new do |s| 'src/core/transport/stream_op.h', 'src/core/transport/transport.h', 'src/core/transport/transport_impl.h', + 'src/core/census/aggregation.h', 'src/core/census/context.h', 'src/core/census/rpc_metric_id.h', 'grpc/grpc_security.h', @@ -520,6 +521,7 @@ Pod::Spec.new do |s| 'src/core/transport/stream_op.h', 'src/core/transport/transport.h', 'src/core/transport/transport_impl.h', + 'src/core/census/aggregation.h', 'src/core/census/context.h', 'src/core/census/rpc_metric_id.h' diff --git a/include/grpc/census.h b/include/grpc/census.h index 9c0291bf96..2f36665d46 100644 --- a/include/grpc/census.h +++ b/include/grpc/census.h @@ -411,34 +411,10 @@ typedef struct { void census_record_values(census_context *context, census_value *values, size_t nvalues); -/** Structure used to describe an aggregation type. */ -typedef struct { - /* Create a new aggregation. The pointer returned can be used in future calls - to clone(), free(), record(), data() and reset(). */ - void *(*create)(const void *create_arg); - /* Make a copy of an aggregation created by create() */ - void *(*clone)(const void *aggregation); - /* Destroy an aggregation created by create() */ - void (*free)(void *aggregation); - /* Record a new value against aggregation. */ - void (*record)(void *aggregation, double value); - /* Return current aggregation data. The caller must cast this object into - the correct type for the aggregation result. The object returned can be - freed by using free_data(). */ - void *(*data)(const void *aggregation); - /* free data returned by data() */ - void (*free_data)(void *data); - /* Reset an aggregation to default (zero) values. */ - void (*reset)(void *aggregation); - /* Merge 'from' aggregation into 'to'. Both aggregations must be compatible */ - void (*merge)(void *to, const void *from); - /* Fill buffer with printable string version of aggregation contents. For - debugging only. Returns the number of bytes added to buffer (a value == n - implies the buffer was of insufficient size). */ - size_t (*print)(const void *aggregation, char *buffer, size_t n); -} census_aggregation_ops; - -/* Predefined aggregation types. */ +/** Type representing a particular aggregation */ +typedef struct census_aggregation_ops census_aggregation_ops; + +/* Predefined aggregation types, for use with census_view_create(). */ extern census_aggregation_ops census_agg_sum; extern census_aggregation_ops census_agg_distribution; extern census_aggregation_ops census_agg_histogram; diff --git a/src/core/census/aggregation.h b/src/core/census/aggregation.h new file mode 100644 index 0000000000..e9bc6ada96 --- /dev/null +++ b/src/core/census/aggregation.h @@ -0,0 +1,66 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stddef.h> + +#ifndef GRPC_INTERNAL_CORE_CENSUS_AGGREGATION_H +#define GRPC_INTERNAL_CORE_CENSUS_AGGREGATION_H + +/** Structure used to describe an aggregation type. */ +struct census_aggregation_ops { + /* Create a new aggregation. The pointer returned can be used in future calls + to clone(), free(), record(), data() and reset(). */ + void *(*create)(const void *create_arg); + /* Make a copy of an aggregation created by create() */ + void *(*clone)(const void *aggregation); + /* Destroy an aggregation created by create() */ + void (*free)(void *aggregation); + /* Record a new value against aggregation. */ + void (*record)(void *aggregation, double value); + /* Return current aggregation data. The caller must cast this object into + the correct type for the aggregation result. The object returned can be + freed by using free_data(). */ + void *(*data)(const void *aggregation); + /* free data returned by data() */ + void (*free_data)(void *data); + /* Reset an aggregation to default (zero) values. */ + void (*reset)(void *aggregation); + /* Merge 'from' aggregation into 'to'. Both aggregations must be compatible */ + void (*merge)(void *to, const void *from); + /* Fill buffer with printable string version of aggregation contents. For + debugging only. Returns the number of bytes added to buffer (a value == n + implies the buffer was of insufficient size). */ + size_t (*print)(const void *aggregation, char *buffer, size_t n); +}; + +#endif /* GRPC_INTERNAL_CORE_CENSUS_AGGREGATION_H */ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 26846011ae..729f8bf2ff 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -881,6 +881,7 @@ src/core/transport/metadata.h \ src/core/transport/stream_op.h \ src/core/transport/transport.h \ src/core/transport/transport_impl.h \ +src/core/census/aggregation.h \ src/core/census/context.h \ src/core/census/rpc_metric_id.h \ src/core/httpcli/httpcli_security_connector.c \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 40a9fa4075..36f8dc6f27 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -12229,6 +12229,7 @@ "include/grpc/grpc.h", "include/grpc/grpc_security.h", "include/grpc/status.h", + "src/core/census/aggregation.h", "src/core/census/context.h", "src/core/census/grpc_filter.h", "src/core/census/rpc_metric_id.h", @@ -12356,6 +12357,7 @@ "include/grpc/grpc.h", "include/grpc/grpc_security.h", "include/grpc/status.h", + "src/core/census/aggregation.h", "src/core/census/context.c", "src/core/census/context.h", "src/core/census/grpc_context.c", @@ -12707,6 +12709,7 @@ "include/grpc/compression.h", "include/grpc/grpc.h", "include/grpc/status.h", + "src/core/census/aggregation.h", "src/core/census/context.h", "src/core/census/grpc_filter.h", "src/core/census/rpc_metric_id.h", @@ -12820,6 +12823,7 @@ "include/grpc/compression.h", "include/grpc/grpc.h", "include/grpc/status.h", + "src/core/census/aggregation.h", "src/core/census/context.c", "src/core/census/context.h", "src/core/census/grpc_context.c", diff --git a/vsprojects/grpc/grpc.vcxproj b/vsprojects/grpc/grpc.vcxproj index 68be5277f0..6857f7c9a2 100644 --- a/vsprojects/grpc/grpc.vcxproj +++ b/vsprojects/grpc/grpc.vcxproj @@ -343,6 +343,7 @@ <ClInclude Include="..\..\src\core\transport\stream_op.h" /> <ClInclude Include="..\..\src\core\transport\transport.h" /> <ClInclude Include="..\..\src\core\transport\transport_impl.h" /> + <ClInclude Include="..\..\src\core\census\aggregation.h" /> <ClInclude Include="..\..\src\core\census\context.h" /> <ClInclude Include="..\..\src\core\census\rpc_metric_id.h" /> </ItemGroup> diff --git a/vsprojects/grpc/grpc.vcxproj.filters b/vsprojects/grpc/grpc.vcxproj.filters index c6d88b827a..dc35c0535f 100644 --- a/vsprojects/grpc/grpc.vcxproj.filters +++ b/vsprojects/grpc/grpc.vcxproj.filters @@ -791,6 +791,9 @@ <ClInclude Include="..\..\src\core\transport\transport_impl.h"> <Filter>src\core\transport</Filter> </ClInclude> + <ClInclude Include="..\..\src\core\census\aggregation.h"> + <Filter>src\core\census</Filter> + </ClInclude> <ClInclude Include="..\..\src\core\census\context.h"> <Filter>src\core\census</Filter> </ClInclude> diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj index 5aeaf89ac5..bec4ebf692 100644 --- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj @@ -326,6 +326,7 @@ <ClInclude Include="..\..\src\core\transport\stream_op.h" /> <ClInclude Include="..\..\src\core\transport\transport.h" /> <ClInclude Include="..\..\src\core\transport\transport_impl.h" /> + <ClInclude Include="..\..\src\core\census\aggregation.h" /> <ClInclude Include="..\..\src\core\census\context.h" /> <ClInclude Include="..\..\src\core\census\rpc_metric_id.h" /> </ItemGroup> diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters index ff8f3e18fa..63d69222e8 100644 --- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -689,6 +689,9 @@ <ClInclude Include="..\..\src\core\transport\transport_impl.h"> <Filter>src\core\transport</Filter> </ClInclude> + <ClInclude Include="..\..\src\core\census\aggregation.h"> + <Filter>src\core\census</Filter> + </ClInclude> <ClInclude Include="..\..\src\core\census\context.h"> <Filter>src\core\census</Filter> </ClInclude> |