Skip to content

Commit

Permalink
CLIENT-2699 Support client metrics.
Browse files Browse the repository at this point in the history
Co-authored-by: Brian Nichols <[email protected]>
  • Loading branch information
shannonklaus and BrianNichols committed Feb 28, 2024
1 parent f1db63f commit 8657f31
Show file tree
Hide file tree
Showing 33 changed files with 1,995 additions and 136 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,12 @@ AEROSPIKE += as_host.o
AEROSPIKE += as_info.o
AEROSPIKE += as_job.o
AEROSPIKE += as_key.o
AEROSPIKE += as_latency.o
AEROSPIKE += as_list_operations.o
AEROSPIKE += as_lookup.o
AEROSPIKE += as_map_operations.o
AEROSPIKE += as_metrics.o
AEROSPIKE += as_metrics_writer.o
AEROSPIKE += as_node.o
AEROSPIKE += as_operations.o
AEROSPIKE += as_partition.o
Expand Down
30 changes: 27 additions & 3 deletions src/include/aerospike/aerospike_stats.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2021 Aerospike, Inc.
* Copyright 2008-2024 Aerospike, Inc.
*
* Portions may be licensed to Aerospike, Inc. under one or more contributor
* license agreements.
Expand Down Expand Up @@ -88,9 +88,16 @@ typedef struct as_node_stats_s {
as_conn_stats pipeline;

/**
* Node error count within current window.
* Transaction error count since node was initialized. If the error is retryable, multiple errors per
* transaction may occur.
*/
uint32_t error_count;
uint64_t error_count;

/**
* Transaction timeout count since node was initialized. If the timeout is retryable (ie socket timeout),
* multiple timeouts per transaction may occur.
*/
uint64_t timeout_count;

} as_node_stats;

Expand Down Expand Up @@ -128,6 +135,11 @@ typedef struct as_cluster_stats_s {
*/
as_event_loop_stats* event_loops;

/**
* Count of transaction retries since cluster was started.
*/
uint64_t retry_count;

/**
* Node count.
*/
Expand Down Expand Up @@ -242,6 +254,18 @@ aerospike_event_loop_stats(as_event_loop* event_loop, as_event_loop_stats* stats
AS_EXTERN char*
aerospike_stats_to_string(as_cluster_stats* stats);

static inline void
as_conn_stats_init(as_conn_stats* stats)
{
stats->in_pool = 0;
stats->in_use = 0;
stats->opened = 0;
stats->closed = 0;
}

void
as_conn_stats_sum(as_conn_stats* stats, as_async_conn_pool* pool);

#ifdef __cplusplus
} // end extern "C"
#endif
13 changes: 11 additions & 2 deletions src/include/aerospike/as_async.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2023 Aerospike, Inc.
* Copyright 2008-2024 Aerospike, Inc.
*
* Portions may be licensed to Aerospike, Inc. under one or more contributor
* license agreements.
Expand Down Expand Up @@ -110,7 +110,9 @@ as_async_write_command_create(
cmd->flags = 0;
cmd->replica_size = pi->replica_size;
cmd->replica_index = 0;
cmd->latency_type = AS_LATENCY_TYPE_WRITE;
wcmd->listener = listener;
as_cluster_add_tran(cluster);
return cmd;
}

Expand All @@ -119,7 +121,8 @@ as_async_record_command_create(
as_cluster* cluster, const as_policy_base* policy, as_partition_info* pi,
as_policy_replica replica, uint8_t replica_index, bool deserialize, bool heap_rec,
uint8_t flags, as_async_record_listener listener, void* udata, as_event_loop* event_loop,
as_pipe_listener pipe_listener, size_t size, as_event_parse_results_fn parse_results
as_pipe_listener pipe_listener, size_t size, as_event_parse_results_fn parse_results,
as_latency_type latency_type
)
{
// Allocate enough memory to cover: struct size + write buffer size + auth max buffer size
Expand Down Expand Up @@ -158,7 +161,9 @@ as_async_record_command_create(

cmd->replica_size = pi->replica_size;
cmd->replica_index = replica_index;
cmd->latency_type = latency_type;
rcmd->listener = listener;
as_cluster_add_tran(cluster);
return cmd;
}

Expand Down Expand Up @@ -197,7 +202,9 @@ as_async_value_command_create(
cmd->flags = 0;
cmd->replica_size = pi->replica_size;
cmd->replica_index = 0;
cmd->latency_type = AS_LATENCY_TYPE_WRITE;
vcmd->listener = listener;
as_cluster_add_tran(cluster);
return cmd;
}

Expand Down Expand Up @@ -233,7 +240,9 @@ as_async_info_command_create(
cmd->flags = 0;
cmd->replica_size = 1;
cmd->replica_index = 0;
cmd->latency_type = AS_LATENCY_TYPE_NONE;
icmd->listener = listener;
as_cluster_add_tran(node->cluster);
return cmd;
}

Expand Down
2 changes: 1 addition & 1 deletion src/include/aerospike/as_cdt_ctx.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ as_cdt_ctx_add_list_value(as_cdt_ctx* ctx, as_val* val)

/**
* Lookup map by index offset.
* <p>
*
* If the index is negative, the resolved index starts backwards from end of list.
* If an index is out of bounds, a parameter error will be returned. Examples:
* <ul>
Expand Down
Loading

0 comments on commit 8657f31

Please sign in to comment.