Introduce stream stats type

pull/5699/head
Craig Tiller 9 years ago
parent d68ee7e262
commit e2d6a61e35
  1. 12
      src/core/transport/transport.c
  2. 17
      src/core/transport/transport.h

@ -35,6 +35,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/atm.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include "src/core/transport/transport_impl.h"
#ifdef GRPC_STREAM_REFCOUNT_DEBUG
@ -76,6 +77,17 @@ void grpc_stream_ref_init(grpc_stream_refcount *refcount, int initial_refs,
grpc_closure_init(&refcount->destroy, cb, cb_arg);
}
static void one_way_stats_init(grpc_transport_one_way_stats *stats) {
gpr_stats_init(&stats->framing_bytes, 0);
gpr_stats_init(&stats->data_bytes, 0);
gpr_stats_init(&stats->header_bytes, 0);
}
void grpc_transport_stream_stats_init(grpc_transport_stream_stats *stats) {
one_way_stats_init(&stats->incoming);
one_way_stats_init(&stats->outgoing);
}
size_t grpc_transport_stream_size(grpc_transport *transport) {
return transport->vtable->sizeof_stream;
}

@ -36,11 +36,11 @@
#include <stddef.h>
#include "src/core/channel/context.h"
#include "src/core/iomgr/pollset.h"
#include "src/core/iomgr/pollset_set.h"
#include "src/core/transport/metadata_batch.h"
#include "src/core/transport/byte_stream.h"
#include "src/core/channel/context.h"
#include "src/core/transport/metadata_batch.h"
/* forward declarations */
typedef struct grpc_transport grpc_transport;
@ -154,6 +154,19 @@ typedef struct grpc_transport_op {
grpc_closure *send_ping;
} grpc_transport_op;
typedef struct {
gpr_stats_counter framing_bytes;
gpr_stats_counter data_bytes;
gpr_stats_counter header_bytes;
} grpc_transport_one_way_stats;
typedef struct grpc_transport_stream_stats {
grpc_transport_one_way_stats incoming;
grpc_transport_one_way_stats outgoing;
} grpc_transport_stream_stats;
void grpc_transport_stream_stats_init(grpc_transport_stream_stats *stats);
/* Returns the amount of memory required to store a grpc_stream for this
transport */
size_t grpc_transport_stream_size(grpc_transport *transport);

Loading…
Cancel
Save