mirror of https://github.com/grpc/grpc.git
commit
1fd6235791
216 changed files with 13669 additions and 2393 deletions
@ -0,0 +1,6 @@ |
|||||||
|
Files generated for use by Census stats and trace recording subsystem. |
||||||
|
|
||||||
|
#Files |
||||||
|
* census.pb.{h,c} - Generated from src/core/ext/census/census.proto, using the |
||||||
|
script `tools/codegen/core/gen_nano_proto.sh src/proto/census/census.proto |
||||||
|
$PWD/src/core/ext/census/gen src/core/ext/census/gen` |
@ -0,0 +1,179 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2016, 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. |
||||||
|
* |
||||||
|
*/ |
||||||
|
/* Automatically generated nanopb constant definitions */ |
||||||
|
/* Generated by nanopb-0.3.5-dev */ |
||||||
|
|
||||||
|
#include "src/core/ext/census/gen/census.pb.h" |
||||||
|
|
||||||
|
#if PB_PROTO_HEADER_VERSION != 30 |
||||||
|
#error Regenerate this file with the current version of nanopb generator. |
||||||
|
#endif |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const pb_field_t google_census_Duration_fields[3] = { |
||||||
|
PB_FIELD( 1, INT64 , OPTIONAL, STATIC , FIRST, google_census_Duration, seconds, seconds, 0), |
||||||
|
PB_FIELD( 2, INT32 , OPTIONAL, STATIC , OTHER, google_census_Duration, nanos, seconds, 0), |
||||||
|
PB_LAST_FIELD |
||||||
|
}; |
||||||
|
|
||||||
|
const pb_field_t google_census_Timestamp_fields[3] = { |
||||||
|
PB_FIELD( 1, INT64 , OPTIONAL, STATIC , FIRST, google_census_Timestamp, seconds, seconds, 0), |
||||||
|
PB_FIELD( 2, INT32 , OPTIONAL, STATIC , OTHER, google_census_Timestamp, nanos, seconds, 0), |
||||||
|
PB_LAST_FIELD |
||||||
|
}; |
||||||
|
|
||||||
|
const pb_field_t google_census_Metric_fields[5] = { |
||||||
|
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_Metric, name, name, 0), |
||||||
|
PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_Metric, description, name, 0), |
||||||
|
PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_Metric, unit, description, &google_census_Metric_MeasurementUnit_fields), |
||||||
|
PB_FIELD( 4, INT32 , OPTIONAL, STATIC , OTHER, google_census_Metric, id, unit, 0), |
||||||
|
PB_LAST_FIELD |
||||||
|
}; |
||||||
|
|
||||||
|
const pb_field_t google_census_Metric_BasicUnit_fields[2] = { |
||||||
|
PB_FIELD( 1, UENUM , OPTIONAL, STATIC , FIRST, google_census_Metric_BasicUnit, type, type, 0), |
||||||
|
PB_LAST_FIELD |
||||||
|
}; |
||||||
|
|
||||||
|
const pb_field_t google_census_Metric_MeasurementUnit_fields[4] = { |
||||||
|
PB_FIELD( 1, INT32 , OPTIONAL, STATIC , FIRST, google_census_Metric_MeasurementUnit, prefix, prefix, 0), |
||||||
|
PB_FIELD( 2, MESSAGE , REPEATED, CALLBACK, OTHER, google_census_Metric_MeasurementUnit, numerator, prefix, &google_census_Metric_BasicUnit_fields), |
||||||
|
PB_FIELD( 3, MESSAGE , REPEATED, CALLBACK, OTHER, google_census_Metric_MeasurementUnit, denominator, numerator, &google_census_Metric_BasicUnit_fields), |
||||||
|
PB_LAST_FIELD |
||||||
|
}; |
||||||
|
|
||||||
|
const pb_field_t google_census_AggregationDescriptor_fields[3] = { |
||||||
|
PB_ONEOF_FIELD(options, 1, MESSAGE , ONEOF, STATIC , FIRST, google_census_AggregationDescriptor, bucket_boundaries, bucket_boundaries, &google_census_AggregationDescriptor_BucketBoundaries_fields), |
||||||
|
PB_ONEOF_FIELD(options, 2, MESSAGE , ONEOF, STATIC , FIRST, google_census_AggregationDescriptor, interval_boundaries, interval_boundaries, &google_census_AggregationDescriptor_IntervalBoundaries_fields), |
||||||
|
PB_LAST_FIELD |
||||||
|
}; |
||||||
|
|
||||||
|
const pb_field_t google_census_AggregationDescriptor_BucketBoundaries_fields[2] = { |
||||||
|
PB_FIELD( 1, DOUBLE , REPEATED, CALLBACK, FIRST, google_census_AggregationDescriptor_BucketBoundaries, bounds, bounds, 0), |
||||||
|
PB_LAST_FIELD |
||||||
|
}; |
||||||
|
|
||||||
|
const pb_field_t google_census_AggregationDescriptor_IntervalBoundaries_fields[2] = { |
||||||
|
PB_FIELD( 1, DOUBLE , REPEATED, CALLBACK, FIRST, google_census_AggregationDescriptor_IntervalBoundaries, window_size, window_size, 0), |
||||||
|
PB_LAST_FIELD |
||||||
|
}; |
||||||
|
|
||||||
|
const pb_field_t google_census_Distribution_fields[5] = { |
||||||
|
PB_FIELD( 1, INT64 , OPTIONAL, STATIC , FIRST, google_census_Distribution, count, count, 0), |
||||||
|
PB_FIELD( 2, DOUBLE , OPTIONAL, STATIC , OTHER, google_census_Distribution, mean, count, 0), |
||||||
|
PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_Distribution, range, mean, &google_census_Distribution_Range_fields), |
||||||
|
PB_FIELD( 4, INT64 , REPEATED, CALLBACK, OTHER, google_census_Distribution, bucket_count, range, 0), |
||||||
|
PB_LAST_FIELD |
||||||
|
}; |
||||||
|
|
||||||
|
const pb_field_t google_census_Distribution_Range_fields[3] = { |
||||||
|
PB_FIELD( 1, DOUBLE , OPTIONAL, STATIC , FIRST, google_census_Distribution_Range, min, min, 0), |
||||||
|
PB_FIELD( 2, DOUBLE , OPTIONAL, STATIC , OTHER, google_census_Distribution_Range, max, min, 0), |
||||||
|
PB_LAST_FIELD |
||||||
|
}; |
||||||
|
|
||||||
|
const pb_field_t google_census_IntervalStats_fields[2] = { |
||||||
|
PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, google_census_IntervalStats, window, window, &google_census_IntervalStats_Window_fields), |
||||||
|
PB_LAST_FIELD |
||||||
|
}; |
||||||
|
|
||||||
|
const pb_field_t google_census_IntervalStats_Window_fields[4] = { |
||||||
|
PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, google_census_IntervalStats_Window, window_size, window_size, &google_census_Duration_fields), |
||||||
|
PB_FIELD( 2, INT64 , OPTIONAL, STATIC , OTHER, google_census_IntervalStats_Window, count, window_size, 0), |
||||||
|
PB_FIELD( 3, DOUBLE , OPTIONAL, STATIC , OTHER, google_census_IntervalStats_Window, mean, count, 0), |
||||||
|
PB_LAST_FIELD |
||||||
|
}; |
||||||
|
|
||||||
|
const pb_field_t google_census_Tag_fields[3] = { |
||||||
|
PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, google_census_Tag, key, key, 0), |
||||||
|
PB_FIELD( 2, STRING , OPTIONAL, STATIC , OTHER, google_census_Tag, value, key, 0), |
||||||
|
PB_LAST_FIELD |
||||||
|
}; |
||||||
|
|
||||||
|
const pb_field_t google_census_View_fields[6] = { |
||||||
|
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_View, name, name, 0), |
||||||
|
PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_View, description, name, 0), |
||||||
|
PB_FIELD( 3, INT32 , OPTIONAL, STATIC , OTHER, google_census_View, metric_id, description, 0), |
||||||
|
PB_FIELD( 4, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_View, aggregation, metric_id, &google_census_AggregationDescriptor_fields), |
||||||
|
PB_FIELD( 5, STRING , REPEATED, CALLBACK, OTHER, google_census_View, tag_key, aggregation, 0), |
||||||
|
PB_LAST_FIELD |
||||||
|
}; |
||||||
|
|
||||||
|
const pb_field_t google_census_Aggregation_fields[6] = { |
||||||
|
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_Aggregation, name, name, 0), |
||||||
|
PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_Aggregation, description, name, 0), |
||||||
|
PB_ONEOF_FIELD(data, 3, MESSAGE , ONEOF, STATIC , OTHER, google_census_Aggregation, distribution, description, &google_census_Distribution_fields), |
||||||
|
PB_ONEOF_FIELD(data, 4, MESSAGE , ONEOF, STATIC , OTHER, google_census_Aggregation, interval_stats, description, &google_census_IntervalStats_fields), |
||||||
|
PB_FIELD( 5, MESSAGE , REPEATED, CALLBACK, OTHER, google_census_Aggregation, tag, data.interval_stats, &google_census_Tag_fields), |
||||||
|
PB_LAST_FIELD |
||||||
|
}; |
||||||
|
|
||||||
|
const pb_field_t google_census_ViewAggregations_fields[4] = { |
||||||
|
PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, google_census_ViewAggregations, aggregation, aggregation, &google_census_Aggregation_fields), |
||||||
|
PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_ViewAggregations, start, aggregation, &google_census_Timestamp_fields), |
||||||
|
PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_ViewAggregations, end, start, &google_census_Timestamp_fields), |
||||||
|
PB_LAST_FIELD |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
/* Check that field information fits in pb_field_t */ |
||||||
|
#if !defined(PB_FIELD_32BIT) |
||||||
|
/* If you get an error here, it means that you need to define PB_FIELD_32BIT
|
||||||
|
* compile-time option. You can do that in pb.h or on compiler command line. |
||||||
|
*
|
||||||
|
* The reason you need to do this is that some of your messages contain tag |
||||||
|
* numbers or field sizes that are larger than what can fit in 8 or 16 bit |
||||||
|
* field descriptors. |
||||||
|
*/ |
||||||
|
PB_STATIC_ASSERT((pb_membersize(google_census_Metric, unit) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Metric, unit) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Distribution, range) < 65536 && pb_membersize(google_census_IntervalStats, window) < 65536 && pb_membersize(google_census_IntervalStats_Window, window_size) < 65536 && pb_membersize(google_census_View, aggregation) < 65536 && pb_membersize(google_census_Aggregation, data.distribution) < 65536 && pb_membersize(google_census_Aggregation, data.interval_stats) < 65536 && pb_membersize(google_census_Metric, unit) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Metric, unit) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Distribution, range) < 65536 && pb_membersize(google_census_IntervalStats, window) < 65536 && pb_membersize(google_census_IntervalStats_Window, window_size) < 65536 && pb_membersize(google_census_View, aggregation) < 65536 && pb_membersize(google_census_Aggregation, data.distribution) < 65536 && pb_membersize(google_census_Aggregation, data.interval_stats) < 65536 && pb_membersize(google_census_Aggregation, tag) < 65536 && pb_membersize(google_census_ViewAggregations, aggregation) < 65536 && pb_membersize(google_census_ViewAggregations, start) < 65536 && pb_membersize(google_census_ViewAggregations, end) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_google_census_Duration_google_census_Timestamp_google_census_Metric_google_census_Metric_BasicUnit_google_census_Metric_MeasurementUnit_google_census_AggregationDescriptor_google_census_AggregationDescriptor_BucketBoundaries_google_census_AggregationDescriptor_IntervalBoundaries_google_census_Distribution_google_census_Distribution_Range_google_census_IntervalStats_google_census_IntervalStats_Window_google_census_Tag_google_census_View_google_census_Aggregation_google_census_ViewAggregations) |
||||||
|
#endif |
||||||
|
|
||||||
|
#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) |
||||||
|
/* If you get an error here, it means that you need to define PB_FIELD_16BIT
|
||||||
|
* compile-time option. You can do that in pb.h or on compiler command line. |
||||||
|
*
|
||||||
|
* The reason you need to do this is that some of your messages contain tag |
||||||
|
* numbers or field sizes that are larger than what can fit in the default |
||||||
|
* 8 bit descriptors. |
||||||
|
*/ |
||||||
|
PB_STATIC_ASSERT((pb_membersize(google_census_Metric, unit) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Metric, unit) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Distribution, range) < 256 && pb_membersize(google_census_IntervalStats, window) < 256 && pb_membersize(google_census_IntervalStats_Window, window_size) < 256 && pb_membersize(google_census_View, aggregation) < 256 && pb_membersize(google_census_Aggregation, data.distribution) < 256 && pb_membersize(google_census_Aggregation, data.interval_stats) < 256 && pb_membersize(google_census_Metric, unit) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Metric, unit) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Distribution, range) < 256 && pb_membersize(google_census_IntervalStats, window) < 256 && pb_membersize(google_census_IntervalStats_Window, window_size) < 256 && pb_membersize(google_census_View, aggregation) < 256 && pb_membersize(google_census_Aggregation, data.distribution) < 256 && pb_membersize(google_census_Aggregation, data.interval_stats) < 256 && pb_membersize(google_census_Aggregation, tag) < 256 && pb_membersize(google_census_ViewAggregations, aggregation) < 256 && pb_membersize(google_census_ViewAggregations, start) < 256 && pb_membersize(google_census_ViewAggregations, end) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_google_census_Duration_google_census_Timestamp_google_census_Metric_google_census_Metric_BasicUnit_google_census_Metric_MeasurementUnit_google_census_AggregationDescriptor_google_census_AggregationDescriptor_BucketBoundaries_google_census_AggregationDescriptor_IntervalBoundaries_google_census_Distribution_google_census_Distribution_Range_google_census_IntervalStats_google_census_IntervalStats_Window_google_census_Tag_google_census_View_google_census_Aggregation_google_census_ViewAggregations) |
||||||
|
#endif |
||||||
|
|
||||||
|
|
||||||
|
/* On some platforms (such as AVR), double is really float.
|
||||||
|
* These are not directly supported by nanopb, but see example_avr_double. |
||||||
|
* To get rid of this error, remove any double fields from your .proto. |
||||||
|
*/ |
||||||
|
PB_STATIC_ASSERT(sizeof(double) == 8, DOUBLE_MUST_BE_8_BYTES) |
||||||
|
|
@ -0,0 +1,294 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2016, 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. |
||||||
|
* |
||||||
|
*/ |
||||||
|
/* Automatically generated nanopb header */ |
||||||
|
/* Generated by nanopb-0.3.5-dev */ |
||||||
|
|
||||||
|
#ifndef GRPC_CORE_EXT_CENSUS_GEN_CENSUS_PB_H |
||||||
|
#define GRPC_CORE_EXT_CENSUS_GEN_CENSUS_PB_H |
||||||
|
#include "third_party/nanopb/pb.h" |
||||||
|
#if PB_PROTO_HEADER_VERSION != 30 |
||||||
|
#error Regenerate this file with the current version of nanopb generator. |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Enum definitions */ |
||||||
|
typedef enum _google_census_Metric_BasicUnit_Measure { |
||||||
|
google_census_Metric_BasicUnit_Measure_UNKNOWN = 0, |
||||||
|
google_census_Metric_BasicUnit_Measure_BITS = 1, |
||||||
|
google_census_Metric_BasicUnit_Measure_BYTES = 2, |
||||||
|
google_census_Metric_BasicUnit_Measure_SECS = 3, |
||||||
|
google_census_Metric_BasicUnit_Measure_CORES = 4, |
||||||
|
google_census_Metric_BasicUnit_Measure_MAX_UNITS = 5 |
||||||
|
} google_census_Metric_BasicUnit_Measure; |
||||||
|
|
||||||
|
/* Struct definitions */ |
||||||
|
typedef struct _google_census_AggregationDescriptor_BucketBoundaries { |
||||||
|
pb_callback_t bounds; |
||||||
|
} google_census_AggregationDescriptor_BucketBoundaries; |
||||||
|
|
||||||
|
typedef struct _google_census_AggregationDescriptor_IntervalBoundaries { |
||||||
|
pb_callback_t window_size; |
||||||
|
} google_census_AggregationDescriptor_IntervalBoundaries; |
||||||
|
|
||||||
|
typedef struct _google_census_IntervalStats { |
||||||
|
pb_callback_t window; |
||||||
|
} google_census_IntervalStats; |
||||||
|
|
||||||
|
typedef struct _google_census_AggregationDescriptor { |
||||||
|
pb_size_t which_options; |
||||||
|
union { |
||||||
|
google_census_AggregationDescriptor_BucketBoundaries bucket_boundaries; |
||||||
|
google_census_AggregationDescriptor_IntervalBoundaries interval_boundaries; |
||||||
|
} options; |
||||||
|
} google_census_AggregationDescriptor; |
||||||
|
|
||||||
|
typedef struct _google_census_Distribution_Range { |
||||||
|
bool has_min; |
||||||
|
double min; |
||||||
|
bool has_max; |
||||||
|
double max; |
||||||
|
} google_census_Distribution_Range; |
||||||
|
|
||||||
|
typedef struct _google_census_Duration { |
||||||
|
bool has_seconds; |
||||||
|
int64_t seconds; |
||||||
|
bool has_nanos; |
||||||
|
int32_t nanos; |
||||||
|
} google_census_Duration; |
||||||
|
|
||||||
|
typedef struct _google_census_Metric_BasicUnit { |
||||||
|
bool has_type; |
||||||
|
google_census_Metric_BasicUnit_Measure type; |
||||||
|
} google_census_Metric_BasicUnit; |
||||||
|
|
||||||
|
typedef struct _google_census_Metric_MeasurementUnit { |
||||||
|
bool has_prefix; |
||||||
|
int32_t prefix; |
||||||
|
pb_callback_t numerator; |
||||||
|
pb_callback_t denominator; |
||||||
|
} google_census_Metric_MeasurementUnit; |
||||||
|
|
||||||
|
typedef struct _google_census_Tag { |
||||||
|
bool has_key; |
||||||
|
char key[255]; |
||||||
|
bool has_value; |
||||||
|
char value[255]; |
||||||
|
} google_census_Tag; |
||||||
|
|
||||||
|
typedef struct _google_census_Timestamp { |
||||||
|
bool has_seconds; |
||||||
|
int64_t seconds; |
||||||
|
bool has_nanos; |
||||||
|
int32_t nanos; |
||||||
|
} google_census_Timestamp; |
||||||
|
|
||||||
|
typedef struct _google_census_Distribution { |
||||||
|
bool has_count; |
||||||
|
int64_t count; |
||||||
|
bool has_mean; |
||||||
|
double mean; |
||||||
|
bool has_range; |
||||||
|
google_census_Distribution_Range range; |
||||||
|
pb_callback_t bucket_count; |
||||||
|
} google_census_Distribution; |
||||||
|
|
||||||
|
typedef struct _google_census_IntervalStats_Window { |
||||||
|
bool has_window_size; |
||||||
|
google_census_Duration window_size; |
||||||
|
bool has_count; |
||||||
|
int64_t count; |
||||||
|
bool has_mean; |
||||||
|
double mean; |
||||||
|
} google_census_IntervalStats_Window; |
||||||
|
|
||||||
|
typedef struct _google_census_Metric { |
||||||
|
pb_callback_t name; |
||||||
|
pb_callback_t description; |
||||||
|
bool has_unit; |
||||||
|
google_census_Metric_MeasurementUnit unit; |
||||||
|
bool has_id; |
||||||
|
int32_t id; |
||||||
|
} google_census_Metric; |
||||||
|
|
||||||
|
typedef struct _google_census_View { |
||||||
|
pb_callback_t name; |
||||||
|
pb_callback_t description; |
||||||
|
bool has_metric_id; |
||||||
|
int32_t metric_id; |
||||||
|
bool has_aggregation; |
||||||
|
google_census_AggregationDescriptor aggregation; |
||||||
|
pb_callback_t tag_key; |
||||||
|
} google_census_View; |
||||||
|
|
||||||
|
typedef struct _google_census_ViewAggregations { |
||||||
|
pb_callback_t aggregation; |
||||||
|
bool has_start; |
||||||
|
google_census_Timestamp start; |
||||||
|
bool has_end; |
||||||
|
google_census_Timestamp end; |
||||||
|
} google_census_ViewAggregations; |
||||||
|
|
||||||
|
typedef struct _google_census_Aggregation { |
||||||
|
pb_callback_t name; |
||||||
|
pb_callback_t description; |
||||||
|
pb_size_t which_data; |
||||||
|
union { |
||||||
|
google_census_Distribution distribution; |
||||||
|
google_census_IntervalStats interval_stats; |
||||||
|
} data; |
||||||
|
pb_callback_t tag; |
||||||
|
} google_census_Aggregation; |
||||||
|
|
||||||
|
/* Default values for struct fields */ |
||||||
|
|
||||||
|
/* Initializer values for message structs */ |
||||||
|
#define google_census_Duration_init_default {false, 0, false, 0} |
||||||
|
#define google_census_Timestamp_init_default {false, 0, false, 0} |
||||||
|
#define google_census_Metric_init_default {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Metric_MeasurementUnit_init_default, false, 0} |
||||||
|
#define google_census_Metric_BasicUnit_init_default {false, (google_census_Metric_BasicUnit_Measure)0} |
||||||
|
#define google_census_Metric_MeasurementUnit_init_default {false, 0, {{NULL}, NULL}, {{NULL}, NULL}} |
||||||
|
#define google_census_AggregationDescriptor_init_default {0, {google_census_AggregationDescriptor_BucketBoundaries_init_default}} |
||||||
|
#define google_census_AggregationDescriptor_BucketBoundaries_init_default {{{NULL}, NULL}} |
||||||
|
#define google_census_AggregationDescriptor_IntervalBoundaries_init_default {{{NULL}, NULL}} |
||||||
|
#define google_census_Distribution_init_default {false, 0, false, 0, false, google_census_Distribution_Range_init_default, {{NULL}, NULL}} |
||||||
|
#define google_census_Distribution_Range_init_default {false, 0, false, 0} |
||||||
|
#define google_census_IntervalStats_init_default {{{NULL}, NULL}} |
||||||
|
#define google_census_IntervalStats_Window_init_default {false, google_census_Duration_init_default, false, 0, false, 0} |
||||||
|
#define google_census_Tag_init_default {false, "", false, ""} |
||||||
|
#define google_census_View_init_default {{{NULL}, NULL}, {{NULL}, NULL}, false, 0, false, google_census_AggregationDescriptor_init_default, {{NULL}, NULL}} |
||||||
|
#define google_census_Aggregation_init_default {{{NULL}, NULL}, {{NULL}, NULL}, 0, {google_census_Distribution_init_default}, {{NULL}, NULL}} |
||||||
|
#define google_census_ViewAggregations_init_default {{{NULL}, NULL}, false, google_census_Timestamp_init_default, false, google_census_Timestamp_init_default} |
||||||
|
#define google_census_Duration_init_zero {false, 0, false, 0} |
||||||
|
#define google_census_Timestamp_init_zero {false, 0, false, 0} |
||||||
|
#define google_census_Metric_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Metric_MeasurementUnit_init_zero, false, 0} |
||||||
|
#define google_census_Metric_BasicUnit_init_zero {false, (google_census_Metric_BasicUnit_Measure)0} |
||||||
|
#define google_census_Metric_MeasurementUnit_init_zero {false, 0, {{NULL}, NULL}, {{NULL}, NULL}} |
||||||
|
#define google_census_AggregationDescriptor_init_zero {0, {google_census_AggregationDescriptor_BucketBoundaries_init_zero}} |
||||||
|
#define google_census_AggregationDescriptor_BucketBoundaries_init_zero {{{NULL}, NULL}} |
||||||
|
#define google_census_AggregationDescriptor_IntervalBoundaries_init_zero {{{NULL}, NULL}} |
||||||
|
#define google_census_Distribution_init_zero {false, 0, false, 0, false, google_census_Distribution_Range_init_zero, {{NULL}, NULL}} |
||||||
|
#define google_census_Distribution_Range_init_zero {false, 0, false, 0} |
||||||
|
#define google_census_IntervalStats_init_zero {{{NULL}, NULL}} |
||||||
|
#define google_census_IntervalStats_Window_init_zero {false, google_census_Duration_init_zero, false, 0, false, 0} |
||||||
|
#define google_census_Tag_init_zero {false, "", false, ""} |
||||||
|
#define google_census_View_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, false, 0, false, google_census_AggregationDescriptor_init_zero, {{NULL}, NULL}} |
||||||
|
#define google_census_Aggregation_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, 0, {google_census_Distribution_init_zero}, {{NULL}, NULL}} |
||||||
|
#define google_census_ViewAggregations_init_zero {{{NULL}, NULL}, false, google_census_Timestamp_init_zero, false, google_census_Timestamp_init_zero} |
||||||
|
|
||||||
|
/* Field tags (for use in manual encoding/decoding) */ |
||||||
|
#define google_census_AggregationDescriptor_BucketBoundaries_bounds_tag 1 |
||||||
|
#define google_census_AggregationDescriptor_IntervalBoundaries_window_size_tag 1 |
||||||
|
#define google_census_IntervalStats_window_tag 1 |
||||||
|
#define google_census_AggregationDescriptor_bucket_boundaries_tag 1 |
||||||
|
|
||||||
|
#define google_census_AggregationDescriptor_interval_boundaries_tag 2 |
||||||
|
#define google_census_Distribution_Range_min_tag 1 |
||||||
|
#define google_census_Distribution_Range_max_tag 2 |
||||||
|
#define google_census_Duration_seconds_tag 1 |
||||||
|
#define google_census_Duration_nanos_tag 2 |
||||||
|
#define google_census_Metric_BasicUnit_type_tag 1 |
||||||
|
#define google_census_Metric_MeasurementUnit_prefix_tag 1 |
||||||
|
#define google_census_Metric_MeasurementUnit_numerator_tag 2 |
||||||
|
#define google_census_Metric_MeasurementUnit_denominator_tag 3 |
||||||
|
#define google_census_Tag_key_tag 1 |
||||||
|
#define google_census_Tag_value_tag 2 |
||||||
|
#define google_census_Timestamp_seconds_tag 1 |
||||||
|
#define google_census_Timestamp_nanos_tag 2 |
||||||
|
#define google_census_Distribution_count_tag 1 |
||||||
|
#define google_census_Distribution_mean_tag 2 |
||||||
|
#define google_census_Distribution_range_tag 3 |
||||||
|
#define google_census_Distribution_bucket_count_tag 4 |
||||||
|
#define google_census_IntervalStats_Window_window_size_tag 1 |
||||||
|
#define google_census_IntervalStats_Window_count_tag 2 |
||||||
|
#define google_census_IntervalStats_Window_mean_tag 3 |
||||||
|
#define google_census_Metric_name_tag 1 |
||||||
|
#define google_census_Metric_description_tag 2 |
||||||
|
#define google_census_Metric_unit_tag 3 |
||||||
|
#define google_census_Metric_id_tag 4 |
||||||
|
#define google_census_View_name_tag 1 |
||||||
|
#define google_census_View_description_tag 2 |
||||||
|
#define google_census_View_metric_id_tag 3 |
||||||
|
#define google_census_View_aggregation_tag 4 |
||||||
|
#define google_census_View_tag_key_tag 5 |
||||||
|
#define google_census_ViewAggregations_aggregation_tag 1 |
||||||
|
#define google_census_ViewAggregations_start_tag 2 |
||||||
|
#define google_census_ViewAggregations_end_tag 3 |
||||||
|
#define google_census_Aggregation_distribution_tag 3 |
||||||
|
|
||||||
|
#define google_census_Aggregation_interval_stats_tag 4 |
||||||
|
#define google_census_Aggregation_name_tag 1 |
||||||
|
#define google_census_Aggregation_description_tag 2 |
||||||
|
#define google_census_Aggregation_tag_tag 5 |
||||||
|
|
||||||
|
/* Struct field encoding specification for nanopb */ |
||||||
|
extern const pb_field_t google_census_Duration_fields[3]; |
||||||
|
extern const pb_field_t google_census_Timestamp_fields[3]; |
||||||
|
extern const pb_field_t google_census_Metric_fields[5]; |
||||||
|
extern const pb_field_t google_census_Metric_BasicUnit_fields[2]; |
||||||
|
extern const pb_field_t google_census_Metric_MeasurementUnit_fields[4]; |
||||||
|
extern const pb_field_t google_census_AggregationDescriptor_fields[3]; |
||||||
|
extern const pb_field_t google_census_AggregationDescriptor_BucketBoundaries_fields[2]; |
||||||
|
extern const pb_field_t google_census_AggregationDescriptor_IntervalBoundaries_fields[2]; |
||||||
|
extern const pb_field_t google_census_Distribution_fields[5]; |
||||||
|
extern const pb_field_t google_census_Distribution_Range_fields[3]; |
||||||
|
extern const pb_field_t google_census_IntervalStats_fields[2]; |
||||||
|
extern const pb_field_t google_census_IntervalStats_Window_fields[4]; |
||||||
|
extern const pb_field_t google_census_Tag_fields[3]; |
||||||
|
extern const pb_field_t google_census_View_fields[6]; |
||||||
|
extern const pb_field_t google_census_Aggregation_fields[6]; |
||||||
|
extern const pb_field_t google_census_ViewAggregations_fields[4]; |
||||||
|
|
||||||
|
/* Maximum encoded size of messages (where known) */ |
||||||
|
#define google_census_Duration_size 22 |
||||||
|
#define google_census_Timestamp_size 22 |
||||||
|
#define google_census_Metric_BasicUnit_size 2 |
||||||
|
#define google_census_Distribution_Range_size 18 |
||||||
|
#define google_census_IntervalStats_Window_size 44 |
||||||
|
#define google_census_Tag_size 516 |
||||||
|
|
||||||
|
/* Message IDs (where set with "msgid" option) */ |
||||||
|
#ifdef PB_MSGID |
||||||
|
|
||||||
|
#define CENSUS_MESSAGES \ |
||||||
|
|
||||||
|
|
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} /* extern "C" */ |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,132 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2016, 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 <limits.h> |
||||||
|
#include <string.h> |
||||||
|
|
||||||
|
#include <grpc/support/alloc.h> |
||||||
|
#include <grpc/support/sync.h> |
||||||
|
|
||||||
|
#include "src/core/ext/load_reporting/load_reporting.h" |
||||||
|
#include "src/core/ext/load_reporting/load_reporting_filter.h" |
||||||
|
#include "src/core/lib/channel/channel_stack_builder.h" |
||||||
|
#include "src/core/lib/surface/channel_init.h" |
||||||
|
|
||||||
|
struct grpc_load_reporting_config { |
||||||
|
grpc_load_reporting_fn fn; |
||||||
|
void *user_data; |
||||||
|
}; |
||||||
|
|
||||||
|
grpc_load_reporting_config *grpc_load_reporting_config_create( |
||||||
|
grpc_load_reporting_fn fn, void *user_data) { |
||||||
|
GPR_ASSERT(fn != NULL); |
||||||
|
grpc_load_reporting_config *lrc = |
||||||
|
gpr_malloc(sizeof(grpc_load_reporting_config)); |
||||||
|
lrc->fn = fn; |
||||||
|
lrc->user_data = user_data; |
||||||
|
return lrc; |
||||||
|
} |
||||||
|
|
||||||
|
grpc_load_reporting_config *grpc_load_reporting_config_copy( |
||||||
|
grpc_load_reporting_config *src) { |
||||||
|
return grpc_load_reporting_config_create(src->fn, src->user_data); |
||||||
|
} |
||||||
|
|
||||||
|
void grpc_load_reporting_config_destroy(grpc_load_reporting_config *lrc) { |
||||||
|
gpr_free(lrc); |
||||||
|
} |
||||||
|
|
||||||
|
void grpc_load_reporting_config_call( |
||||||
|
grpc_load_reporting_config *lrc, |
||||||
|
const grpc_load_reporting_call_data *call_data) { |
||||||
|
lrc->fn(call_data, lrc->user_data); |
||||||
|
} |
||||||
|
|
||||||
|
static bool is_load_reporting_enabled(const grpc_channel_args *a) { |
||||||
|
if (a == NULL) return false; |
||||||
|
for (size_t i = 0; i < a->num_args; i++) { |
||||||
|
if (0 == strcmp(a->args[i].key, GRPC_ARG_ENABLE_LOAD_REPORTING)) { |
||||||
|
return a->args[i].value.pointer.p != NULL; |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
static bool maybe_add_load_reporting_filter(grpc_channel_stack_builder *builder, |
||||||
|
void *arg) { |
||||||
|
const grpc_channel_args *args = |
||||||
|
grpc_channel_stack_builder_get_channel_arguments(builder); |
||||||
|
if (is_load_reporting_enabled(args)) { |
||||||
|
return grpc_channel_stack_builder_prepend_filter( |
||||||
|
builder, (const grpc_channel_filter *)arg, NULL, NULL); |
||||||
|
} |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
static void lrd_arg_destroy(void *p) { grpc_load_reporting_config_destroy(p); } |
||||||
|
|
||||||
|
static void *lrd_arg_copy(void *p) { |
||||||
|
return grpc_load_reporting_config_copy(p); |
||||||
|
} |
||||||
|
|
||||||
|
static int lrd_arg_cmp(void *a, void *b) { |
||||||
|
grpc_load_reporting_config *lhs = a; |
||||||
|
grpc_load_reporting_config *rhs = b; |
||||||
|
return !(lhs->fn == rhs->fn && lhs->user_data == rhs->user_data); |
||||||
|
} |
||||||
|
|
||||||
|
static const grpc_arg_pointer_vtable lrd_ptr_vtable = { |
||||||
|
lrd_arg_copy, lrd_arg_destroy, lrd_arg_cmp}; |
||||||
|
|
||||||
|
grpc_arg grpc_load_reporting_config_create_arg( |
||||||
|
grpc_load_reporting_config *lrc) { |
||||||
|
grpc_arg arg; |
||||||
|
arg.type = GRPC_ARG_POINTER; |
||||||
|
arg.key = GRPC_ARG_ENABLE_LOAD_REPORTING; |
||||||
|
arg.value.pointer.p = lrc; |
||||||
|
arg.value.pointer.vtable = &lrd_ptr_vtable; |
||||||
|
return arg; |
||||||
|
} |
||||||
|
|
||||||
|
/* Plugin registration */ |
||||||
|
|
||||||
|
void grpc_load_reporting_plugin_init(void) { |
||||||
|
grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX, |
||||||
|
maybe_add_load_reporting_filter, |
||||||
|
(void *)&grpc_load_reporting_filter); |
||||||
|
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX, |
||||||
|
maybe_add_load_reporting_filter, |
||||||
|
(void *)&grpc_load_reporting_filter); |
||||||
|
} |
||||||
|
|
||||||
|
void grpc_load_reporting_plugin_shutdown() {} |
@ -0,0 +1,75 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2016, 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. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef GRPC_CORE_EXT_LOAD_REPORTING_LOAD_REPORTING_H |
||||||
|
#define GRPC_CORE_EXT_LOAD_REPORTING_LOAD_REPORTING_H |
||||||
|
|
||||||
|
#include "src/core/lib/iomgr/closure.h" |
||||||
|
#include "src/core/lib/surface/call.h" |
||||||
|
|
||||||
|
typedef struct grpc_load_reporting_config grpc_load_reporting_config; |
||||||
|
|
||||||
|
/** Call information to be passed to the provided load reporting function upon
|
||||||
|
* completion of the call */ |
||||||
|
typedef struct grpc_load_reporting_call_data { |
||||||
|
const grpc_call_stats *stats; /**< Stats for the call */ |
||||||
|
const char *trailing_md_string; /**< LR trailing metadata info */ |
||||||
|
} grpc_load_reporting_call_data; |
||||||
|
|
||||||
|
/** Custom function to be called by the load reporting filter. */ |
||||||
|
typedef void (*grpc_load_reporting_fn)( |
||||||
|
const grpc_load_reporting_call_data *call_data, void *user_data); |
||||||
|
|
||||||
|
/** Register \a fn as the function to be invoked by the load reporting filter.
|
||||||
|
* \a fn will be invoked at the beginning and at the end of the call. |
||||||
|
* |
||||||
|
* For the first invocation, \a fn's first argument |
||||||
|
* (grpc_load_reporting_call_data*) will be NULL. \a user_data is always passed |
||||||
|
* as-is. */ |
||||||
|
grpc_load_reporting_config *grpc_load_reporting_config_create( |
||||||
|
grpc_load_reporting_fn fn, void *user_data); |
||||||
|
|
||||||
|
grpc_load_reporting_config *grpc_load_reporting_config_copy( |
||||||
|
grpc_load_reporting_config *src); |
||||||
|
|
||||||
|
void grpc_load_reporting_config_destroy(grpc_load_reporting_config *lrc); |
||||||
|
|
||||||
|
/** Invoke the function registered by \a grpc_load_reporting_init. */ |
||||||
|
void grpc_load_reporting_config_call( |
||||||
|
grpc_load_reporting_config *lrc, |
||||||
|
const grpc_load_reporting_call_data *call_data); |
||||||
|
|
||||||
|
/** Return a \a grpc_arg enabling load reporting */ |
||||||
|
grpc_arg grpc_load_reporting_config_create_arg(grpc_load_reporting_config *lrc); |
||||||
|
|
||||||
|
#endif /* GRPC_CORE_EXT_LOAD_REPORTING_LOAD_REPORTING_H */ |
@ -0,0 +1,151 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2016, 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 <grpc/support/log.h> |
||||||
|
#include <grpc/support/string_util.h> |
||||||
|
#include <grpc/support/sync.h> |
||||||
|
#include <string.h> |
||||||
|
|
||||||
|
#include "src/core/ext/load_reporting/load_reporting.h" |
||||||
|
#include "src/core/ext/load_reporting/load_reporting_filter.h" |
||||||
|
#include "src/core/lib/channel/channel_args.h" |
||||||
|
#include "src/core/lib/profiling/timers.h" |
||||||
|
#include "src/core/lib/transport/static_metadata.h" |
||||||
|
|
||||||
|
typedef struct call_data { const char *trailing_md_string; } call_data; |
||||||
|
typedef struct channel_data { |
||||||
|
gpr_mu mu; |
||||||
|
grpc_load_reporting_config *lrc; |
||||||
|
} channel_data; |
||||||
|
|
||||||
|
static void invoke_lr_fn_locked(grpc_load_reporting_config *lrc, |
||||||
|
grpc_load_reporting_call_data *lr_call_data) { |
||||||
|
GPR_TIMER_BEGIN("load_reporting_config_fn", 0); |
||||||
|
grpc_load_reporting_config_call(lrc, lr_call_data); |
||||||
|
GPR_TIMER_END("load_reporting_config_fn", 0); |
||||||
|
} |
||||||
|
|
||||||
|
/* Constructor for call_data */ |
||||||
|
static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, |
||||||
|
grpc_call_element_args *args) { |
||||||
|
call_data *calld = elem->call_data; |
||||||
|
memset(calld, 0, sizeof(call_data)); |
||||||
|
} |
||||||
|
|
||||||
|
/* Destructor for call_data */ |
||||||
|
static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, |
||||||
|
const grpc_call_stats *stats, void *ignored) { |
||||||
|
channel_data *chand = elem->channel_data; |
||||||
|
call_data *calld = elem->call_data; |
||||||
|
|
||||||
|
grpc_load_reporting_call_data lr_call_data = {stats, |
||||||
|
calld->trailing_md_string}; |
||||||
|
|
||||||
|
gpr_mu_lock(&chand->mu); |
||||||
|
invoke_lr_fn_locked(chand->lrc, &lr_call_data); |
||||||
|
gpr_mu_unlock(&chand->mu); |
||||||
|
} |
||||||
|
|
||||||
|
/* Constructor for channel_data */ |
||||||
|
static void init_channel_elem(grpc_exec_ctx *exec_ctx, |
||||||
|
grpc_channel_element *elem, |
||||||
|
grpc_channel_element_args *args) { |
||||||
|
GPR_ASSERT(!args->is_last); |
||||||
|
|
||||||
|
channel_data *chand = elem->channel_data; |
||||||
|
memset(chand, 0, sizeof(channel_data)); |
||||||
|
|
||||||
|
gpr_mu_init(&chand->mu); |
||||||
|
for (size_t i = 0; i < args->channel_args->num_args; i++) { |
||||||
|
if (0 == strcmp(args->channel_args->args[i].key, |
||||||
|
GRPC_ARG_ENABLE_LOAD_REPORTING)) { |
||||||
|
grpc_load_reporting_config *arg_lrc = |
||||||
|
args->channel_args->args[i].value.pointer.p; |
||||||
|
chand->lrc = grpc_load_reporting_config_copy(arg_lrc); |
||||||
|
GPR_ASSERT(chand->lrc != NULL); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
GPR_ASSERT(chand->lrc != NULL); /* arg actually found */ |
||||||
|
|
||||||
|
gpr_mu_lock(&chand->mu); |
||||||
|
invoke_lr_fn_locked(chand->lrc, NULL); |
||||||
|
gpr_mu_unlock(&chand->mu); |
||||||
|
} |
||||||
|
|
||||||
|
/* Destructor for channel data */ |
||||||
|
static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, |
||||||
|
grpc_channel_element *elem) { |
||||||
|
channel_data *chand = elem->channel_data; |
||||||
|
gpr_mu_destroy(&chand->mu); |
||||||
|
grpc_load_reporting_config_destroy(chand->lrc); |
||||||
|
} |
||||||
|
|
||||||
|
static grpc_mdelem *lr_trailing_md_filter(void *user_data, grpc_mdelem *md) { |
||||||
|
grpc_call_element *elem = user_data; |
||||||
|
call_data *calld = elem->call_data; |
||||||
|
|
||||||
|
if (md->key == GRPC_MDSTR_LOAD_REPORTING) { |
||||||
|
calld->trailing_md_string = gpr_strdup(grpc_mdstr_as_c_string(md->value)); |
||||||
|
return NULL; |
||||||
|
} |
||||||
|
|
||||||
|
return md; |
||||||
|
} |
||||||
|
|
||||||
|
static void lr_start_transport_stream_op(grpc_exec_ctx *exec_ctx, |
||||||
|
grpc_call_element *elem, |
||||||
|
grpc_transport_stream_op *op) { |
||||||
|
GPR_TIMER_BEGIN("lr_start_transport_stream_op", 0); |
||||||
|
|
||||||
|
if (op->send_trailing_metadata) { |
||||||
|
grpc_metadata_batch_filter(op->send_trailing_metadata, |
||||||
|
lr_trailing_md_filter, elem); |
||||||
|
} |
||||||
|
grpc_call_next_op(exec_ctx, elem, op); |
||||||
|
|
||||||
|
GPR_TIMER_END("lr_start_transport_stream_op", 0); |
||||||
|
} |
||||||
|
|
||||||
|
const grpc_channel_filter grpc_load_reporting_filter = { |
||||||
|
lr_start_transport_stream_op, |
||||||
|
grpc_channel_next_op, |
||||||
|
sizeof(call_data), |
||||||
|
init_call_elem, |
||||||
|
grpc_call_stack_ignore_set_pollset, |
||||||
|
destroy_call_elem, |
||||||
|
sizeof(channel_data), |
||||||
|
init_channel_elem, |
||||||
|
destroy_channel_elem, |
||||||
|
grpc_call_next_get_peer, |
||||||
|
"load_reporting"}; |
@ -0,0 +1,41 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2016, 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. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef GRPC_CORE_EXT_LOAD_REPORTING_LOAD_REPORTING_FILTER_H |
||||||
|
#define GRPC_CORE_EXT_LOAD_REPORTING_LOAD_REPORTING_FILTER_H |
||||||
|
|
||||||
|
#include "src/core/lib/channel/channel_stack.h" |
||||||
|
|
||||||
|
extern const grpc_channel_filter grpc_load_reporting_filter; |
||||||
|
|
||||||
|
#endif /* GRPC_CORE_EXT_LOAD_REPORTING_LOAD_REPORTING_FILTER_H */ |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,41 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* 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. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef GRPC_CORE_LIB_IOMGR_EV_POLL_AND_EPOLL_POSIX_H |
||||||
|
#define GRPC_CORE_LIB_IOMGR_EV_POLL_AND_EPOLL_POSIX_H |
||||||
|
|
||||||
|
#include "src/core/lib/iomgr/ev_posix.h" |
||||||
|
|
||||||
|
const grpc_event_engine_vtable *grpc_init_poll_and_epoll_posix(void); |
||||||
|
|
||||||
|
#endif /* GRPC_CORE_LIB_IOMGR_EV_POLL_AND_EPOLL_POSIX_H */ |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue