-
Notifications
You must be signed in to change notification settings - Fork 169
Stat #526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Stat #526
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
d6938cc
WIP
891f6e8
WIP
1266e17
WIP
bretambrose b4c1dd3
Bug fix
9b8f86a
newline
20124d9
Documentation
9c7760b
More documentation
c0f017b
CR Updates
bretambrose 718d656
tidy
bretambrose 4a3f4ae
more tidy
bretambrose bedff7c
Merge branch 'master' into Stat
bretambrose 2f7b8f8
PR Feedback
ded52cc
oops
0391be4
Merge branch 'master' into Stat
JonathanHenson 2d05fe6
Add context param to process_statistics
f18e2f6
Updates for http monitor impl
9117120
Merge branch 'master' into Stat
4887628
Improve documentation
c5071f9
PR feedback
d0478e9
Merge branch 'master' into Stat
26315d0
Merge branch 'master' into Stat
JonathanHenson f8ffe04
Merge branch 'master' into Stat
bretambrose 97c5553
Merge messup
f3a82a1
Merge branch 'master' into Stat
bretambrose 6c2bfb4
Merge branch 'master' into Stat
bretambrose 8d2c91f
Merge branch 'master' into Stat
bretambrose File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #ifndef AWS_COMMON_PACKAGE_H | ||
| #define AWS_COMMON_PACKAGE_H | ||
|
|
||
| /* | ||
| * Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"). | ||
| * You may not use this file except in compliance with the License. | ||
| * A copy of the License is located at | ||
| * | ||
| * http://aws.amazon.com/apache2.0 | ||
| * | ||
| * or in the "license" file accompanying this file. This file is distributed | ||
| * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
| * express or implied. See the License for the specific language governing | ||
| * permissions and limitations under the License. | ||
| */ | ||
|
|
||
| /* | ||
| * Preliminary cap on the number of possible aws-c-libraries participating in shared enum ranges for | ||
| * errors, log subjects, and other cross-library enums. Expandable as needed | ||
| */ | ||
| #define AWS_PACKAGE_SLOTS 16 | ||
bretambrose marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /* | ||
| * Each aws-c-* and aws-crt-* library has a unique package id starting from zero. These are used to macro-calculate | ||
| * correct ranges for the cross-library enumerations. | ||
| */ | ||
| #define AWS_C_COMMON_PACKAGE_ID 0 | ||
|
|
||
| #endif /* AWS_COMMON_PACKAGE_H */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| #ifndef AWS_COMMON_STATISTICS_H | ||
| #define AWS_COMMON_STATISTICS_H | ||
|
|
||
| /* | ||
| * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"). | ||
| * You may not use this file except in compliance with the License. | ||
| * A copy of the License is located at | ||
| * | ||
| * http://aws.amazon.com/apache2.0 | ||
| * | ||
| * or in the "license" file accompanying this file. This file is distributed | ||
| * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
| * expressaws_crt_statistics_base or implied. See the License for the specific language governing | ||
| * permissions and limitations under the License. | ||
| */ | ||
|
|
||
| #include <aws/common/common.h> | ||
| #include <aws/common/package.h> | ||
|
|
||
| #include <aws/common/stdint.h> | ||
|
|
||
| struct aws_array_list; | ||
|
|
||
| typedef uint32_t aws_crt_statistics_category_t; | ||
|
|
||
| /* Each library gets space for 2^^8 category entries */ | ||
| #define AWS_CRT_STATISTICS_CATEGORY_STRIDE_BITS 8 | ||
bretambrose marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #define AWS_CRT_STATISTICS_CATEGORY_STRIDE (1U << AWS_CRT_STATISTICS_CATEGORY_STRIDE_BITS) | ||
| #define AWS_CRT_STATISTICS_CATEGORY_BEGIN_RANGE(x) ((x)*AWS_CRT_STATISTICS_CATEGORY_STRIDE) | ||
| #define AWS_CRT_STATISTICS_CATEGORY_END_RANGE(x) (((x) + 1) * AWS_CRT_STATISTICS_CATEGORY_STRIDE - 1) | ||
|
|
||
| /** | ||
| * The common-specific range of the aws_crt_statistics_category cross-library enum. | ||
| * | ||
| * This enum functions as an RTTI value that lets statistics handler's interpret (via cast) a | ||
| * specific statistics structure if the RTTI value is understood. | ||
| * | ||
| * Common doesn't have any statistics structures presently, so its range is essentially empty. | ||
| * | ||
| */ | ||
| enum aws_crt_common_statistics_category { | ||
| AWSCRT_STAT_CAT_INVALID = AWS_CRT_STATISTICS_CATEGORY_BEGIN_RANGE(AWS_C_COMMON_PACKAGE_ID) | ||
| }; | ||
|
|
||
| /** | ||
| * Pattern-struct that functions as a base "class" for all statistics structures. To conform | ||
| * to the pattern, a statistics structure must have its first member be the category. In that | ||
| * case it becomes "safe" to cast from aws_crt_statistics_base to the specific statistics structure | ||
| * based on the category value. | ||
| */ | ||
| struct aws_crt_statistics_base { | ||
| aws_crt_statistics_category_t category; | ||
| }; | ||
|
|
||
| /** | ||
| * The start and end time, in milliseconds-since-epoch, that a set of statistics was gathered over. | ||
| */ | ||
| struct aws_crt_statistics_sample_interval { | ||
| uint64_t begin_time_ms; | ||
| uint64_t end_time_ms; | ||
| }; | ||
|
|
||
| struct aws_crt_statistics_handler; | ||
|
|
||
| /* | ||
| * Statistics intake function. The array_list is a list of pointers to aws_crt_statistics_base "derived" (via | ||
| * pattern) objects. The handler should iterate the list and downcast elements whose RTTI category it understands, | ||
| * while skipping those it does not understand. | ||
| */ | ||
| typedef void(aws_crt_statistics_handler_process_statistics_fn)( | ||
| struct aws_crt_statistics_handler *handler, | ||
| struct aws_crt_statistics_sample_interval *interval, | ||
| struct aws_array_list *stats, | ||
| void *context); | ||
|
|
||
| /* | ||
| * Destroys a statistics handler implementation | ||
| */ | ||
| typedef void(aws_crt_statistics_handler_destroy_fn)(struct aws_crt_statistics_handler *handler); | ||
|
|
||
| /* | ||
| * The period, in milliseconds, that the handler would like to be informed of statistics. Statistics generators are | ||
| * not required to honor this value, but should if able. | ||
| */ | ||
| typedef uint64_t(aws_crt_statistics_handler_get_report_interval_ms_fn)(struct aws_crt_statistics_handler *); | ||
|
|
||
| /** | ||
| * Vtable for functions that all statistics handlers must implement | ||
| */ | ||
| struct aws_crt_statistics_handler_vtable { | ||
| aws_crt_statistics_handler_process_statistics_fn *process_statistics; | ||
| aws_crt_statistics_handler_destroy_fn *destroy; | ||
| aws_crt_statistics_handler_get_report_interval_ms_fn *get_report_interval_ms; | ||
| }; | ||
|
|
||
| /** | ||
| * Base structure for all statistics handler implementations. | ||
| * | ||
| * A statistics handler is an object that listens to a stream of polymorphic (via the category RTTI enum) statistics | ||
| * structures emitted from some arbitrary source. In the initial implementation, statistics handlers are primarily | ||
| * attached to channels, where they monitor IO throughput and state data (from channel handlers) to determine a | ||
| * connection's health. | ||
| * | ||
| * Statistics handlers are a generalization of the timeout and bandwidth filters that are often associated with | ||
| * SDK network connections. Configurable, default implementations are defined at the protocol level (http, etc...) | ||
| * where they can be attached at connection (channel) creation time. | ||
| */ | ||
| struct aws_crt_statistics_handler { | ||
| struct aws_crt_statistics_handler_vtable *vtable; | ||
| struct aws_allocator *allocator; | ||
| void *impl; | ||
| }; | ||
|
|
||
| AWS_EXTERN_C_BEGIN | ||
|
|
||
| /** | ||
| * Submits a list of statistics objects to a statistics handler for processing | ||
| * | ||
| * handler - the statistics handler that will process the statistics objects | ||
| * interval - time period over which the statistics were gathered | ||
| * stats - list of pointers to structures that can be case to aws_crt_statistics_base (i.e. have category as a first | ||
| * member) | ||
| * context - (optional) additional context specific to where the statistics handler has been attached | ||
| */ | ||
| AWS_COMMON_API | ||
| void aws_crt_statistics_handler_process_statistics( | ||
| struct aws_crt_statistics_handler *handler, | ||
| struct aws_crt_statistics_sample_interval *interval, | ||
| struct aws_array_list *stats, | ||
| void *context); | ||
|
|
||
| /** | ||
| * Queries the frequency (via an interval in milliseconds) which a statistics handler would like to be informed | ||
| * of statistics. | ||
| */ | ||
| AWS_COMMON_API | ||
| uint64_t aws_crt_statistics_handler_get_report_interval_ms(struct aws_crt_statistics_handler *handler); | ||
|
|
||
| /** | ||
| * completely destroys a statistics handler. The handler's cleanup function must clean up the impl portion completely | ||
| * (including its allocation, if done separately). | ||
| */ | ||
| AWS_COMMON_API | ||
| void aws_crt_statistics_handler_destroy(struct aws_crt_statistics_handler *handler); | ||
|
|
||
| AWS_EXTERN_C_END | ||
|
|
||
| #endif /* AWS_COMMON_STATISTICS_H */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* | ||
| * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"). | ||
| * You may not use this file except in compliance with the License. | ||
| * A copy of the License is located at | ||
| * | ||
| * http://aws.amazon.com/apache2.0 | ||
| * | ||
| * or in the "license" file accompanying this file. This file is distributed | ||
| * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
| * express or implied. See the License for the specific language governing | ||
| * permissions and limitations under the License. | ||
| */ | ||
|
|
||
| #include <aws/common/statistics.h> | ||
|
|
||
| void aws_crt_statistics_handler_process_statistics( | ||
| struct aws_crt_statistics_handler *handler, | ||
| struct aws_crt_statistics_sample_interval *interval, | ||
| struct aws_array_list *stats, | ||
| void *context) { | ||
| handler->vtable->process_statistics(handler, interval, stats, context); | ||
| } | ||
|
|
||
| uint64_t aws_crt_statistics_handler_get_report_interval_ms(struct aws_crt_statistics_handler *handler) { | ||
| return handler->vtable->get_report_interval_ms(handler); | ||
| } | ||
|
|
||
| void aws_crt_statistics_handler_destroy(struct aws_crt_statistics_handler *handler) { | ||
| if (handler == NULL) { | ||
| return; | ||
| } | ||
|
|
||
| handler->vtable->destroy(handler); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.