CDI SDK
SDK for transporting chunks of data reliably and with low latency using a polled mode network driver.
|
This file contains internal definitions and implementation used with the SDK that is not part of the API. More...
#include "statistics.h"
#include "cdi_logger_api.h"
#include "cdi_os_api.h"
#include "cloudwatch.h"
#include "endpoint_manager.h"
#include "internal_log.h"
#include "t_digest.h"
#include <assert.h>
#include <inttypes.h>
Data Structures | |
struct | StatsThreadArgs |
struct | MetricsDestinationInfo |
Structure that holds the parts of StatisticsState structure required per statistics gathering path. More... | |
struct | StatisticsState |
Structure used to hold state data for statistics. More... | |
Typedefs | |
typedef void(* | SendStatsMessage) (StatisticsState *stats_state_ptr, int stats_path_number) |
Enumerations | |
enum | MetricsDestinations { kMetricsDestinationCloudWatch , kMetricsDestinationGatheringService , kMetricsDestinationsCount } |
Functions | |
static void | GetStats (CdiEndpointState *endpoint_ptr, CdiTransferStats *ret_stats_ptr, int destination_idx) |
static void | SendUserStatsMessage (StatisticsState *stats_state_ptr, int destination_idx) |
static void | SendToCdiMetricsService (StatisticsState *stats_state_ptr, int destination_idx) |
static CDI_THREAD | StatsThread (void *ptr) |
static void | StatsThreadDestroy (MetricsDestinationInfo *destination_info_ptr) |
static CdiReturnStatus | CreateStatsThread (StatisticsState *stats_state_ptr, SendStatsMessage message_api_ptr, MetricsDestinations dest_index) |
Allocate statistics thread instance data and create the thread. | |
CdiReturnStatus | StatsCreate (CdiConnectionState *con_state_ptr, CdiCoreStatsCallback stats_cb_ptr, CdiUserCbParameter stats_user_cb_param, CloudWatchSdkMetricsHandle cw_sdk_handle, CloudWatchSdkMetricsHandle metrics_gatherer_sdk_handle, StatisticsHandle *return_handle_ptr) |
CdiReturnStatus | StatsDestroy (StatisticsHandle handle) |
CdiReturnStatus | StatsConfigure (StatisticsHandle handle, const CdiStatsConfigData *stats_config_ptr) |
void | StatsGatherPayloadStatsFromConnection (CdiEndpointState *endpoint_ptr, bool payload_ok, uint64_t start_time, uint64_t max_latency_microsecs, uint64_t bytes_transferred) |
Variables | |
static const int | metrics_gathering_period_ms = 60000 |
Metrics are sent to the gathering service once per minute. | |
This file contains internal definitions and implementation used with the SDK that is not part of the API.
typedef void(* SendStatsMessage) (StatisticsState *stats_state_ptr, int stats_path_number) |
Function pointer used for sending metrics from the StatsThread().
enum MetricsDestinations |
|
static |
Allocate statistics thread instance data and create the thread.
stats_state_ptr | Pointer to statistics state data. |
message_api_ptr | Pointer to API to call with statistics messages. |
dest_index | Destination index. |
|
static |
Get current transfer statistics data for the specified connection and write to the provided address.
endpoint_ptr | Pointer to endpoint state data. |
ret_stats_ptr | Address where to write returned statistics data. |
destination_idx | The index into the destination info array within the statistics state. |
|
static |
Get latest transfer statistics data and provide to users by invoking all registered callbacks.
stats_state_ptr | Pointer to stats state data. |
destination_idx | The index into the destination info array within the statistics state. |
|
static |
Get latest transfer statistics data and provide to users by invoking all registered callbacks.
stats_state_ptr | Pointer to stats state data. |
destination_idx | The index into the destination info array within the statistics state. |
CdiReturnStatus StatsConfigure | ( | StatisticsHandle | handle, |
const CdiStatsConfigData * | stats_config_ptr ) |
Configure transfer statistics.
handle | The handle of the connection to set statistics configuration. |
stats_config_ptr | Pointer to statistics configuration data. |
CdiReturnStatus StatsCreate | ( | CdiConnectionState * | con_state_ptr, |
CdiCoreStatsCallback | stats_cb_ptr, | ||
CdiUserCbParameter | stats_user_cb_param, | ||
CloudWatchSdkMetricsHandle | cw_sdk_handle, | ||
CloudWatchSdkMetricsHandle | metrics_gatherer_sdk_handle, | ||
StatisticsHandle * | return_handle_ptr ) |
Create an instance of the statistics component for the specified connection.
con_state_ptr | Pointer to connection state data. |
stats_cb_ptr | Address of user-defined callback function. |
stats_user_cb_param | Parameter used in structure passed to stats_cb_ptr. |
cw_sdk_handle | Handle to CloudWatch Metrics instance. |
metrics_gatherer_sdk_handle | Handle to CDI metrics gatherer instance. |
return_handle_ptr | Address where to write returned statistics handle. |
CdiReturnStatus StatsDestroy | ( | StatisticsHandle | handle | ) |
Free all resources related to the specified statistics component.
handle | Handle of statistics component. |
void StatsGatherPayloadStatsFromConnection | ( | CdiEndpointState * | endpoint_ptr, |
bool | payload_ok, | ||
uint64_t | start_time, | ||
uint64_t | max_latency_microsecs, | ||
uint64_t | bytes_transferred ) |
Gather transfer time statistics for a single payload from a connection.
endpoint_ptr | Pointer to endpoint state data. |
payload_ok | Use true if payload was successfully transferred, otherwise false. |
start_time | Time when transfer for the payload started in microseconds. |
max_latency_microsecs | The specified maximum latency in microseconds of the payload. |
bytes_transferred | The number of bytes transferred for this connection. |
|
static |
Statistic gathering thread used to invoke registered callback functions when new statistics are available.
ptr | Pointer to thread specific data. In this case, a pointer to StatisticsState. |
|
static |
Destroy stats thread. Used for both dynamic and shutdown destruction.
destination_info_ptr | Pointer to the information applicable to the metrics destination managed by the thread. |