Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Commit

Permalink
Updating grpc plugin with OrphanablePtr. (#104)
Browse files Browse the repository at this point in the history
* Updating grpc byte stream based on changes to grpc repo.
  • Loading branch information
Vizerai authored Mar 13, 2018
1 parent c8398fa commit fc6f888
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
8 changes: 4 additions & 4 deletions opencensus/plugins/grpc/internal/client_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ void CensusClientCallData::OnDoneRecvMessageCb(void *user_data,
// Stream messages are no longer valid after receiving trailing metadata.
if ((*calld->recv_message_) != nullptr) {
calld->context_.Span().AddReceivedMessageEvent(
calld->recv_message_count_++, (*calld->recv_message_)->length,
(*calld->recv_message_)->length);
calld->recv_message_count_++, (*calld->recv_message_)->length(),
(*calld->recv_message_)->length());
}
GRPC_CLOSURE_RUN(calld->initial_on_done_recv_message_, GRPC_ERROR_REF(error));
}
Expand Down Expand Up @@ -117,8 +117,8 @@ void CensusClientCallData::StartTransportStreamOpBatch(
if (op->send_message() != nullptr) {
context_.Span().AddSentMessageEvent(
sent_message_count_++,
op->op()->payload->send_message.send_message->length,
op->op()->payload->send_message.send_message->length);
op->op()->payload->send_message.send_message->length(),
op->op()->payload->send_message.send_message->length());
}
if (op->recv_message() != nullptr) {
recv_message_ = op->op()->payload->recv_message.recv_message;
Expand Down
3 changes: 2 additions & 1 deletion opencensus/plugins/grpc/internal/client_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "absl/time/time.h"
#include "opencensus/plugins/grpc/internal/channel_filter.h"
#include "opencensus/plugins/grpc/internal/filter.h"
#include "src/core/lib/gprpp/orphanable.h"

namespace opencensus {

Expand Down Expand Up @@ -80,7 +81,7 @@ class CensusClientCallData : public grpc::CallData {
// Server elapsed time in nanoseconds.
uint64_t elapsed_time_;
// The received message--may be null.
grpc_byte_stream **recv_message_; // Not owned.
grpc_core::OrphanablePtr<grpc_core::ByteStream> *recv_message_; // Not owned.
// Number of messages in this RPC.
uint32_t recv_message_count_;
uint32_t sent_message_count_;
Expand Down
8 changes: 4 additions & 4 deletions opencensus/plugins/grpc/internal/server_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ void CensusServerCallData::OnDoneRecvMessageCb(void *user_data,
// Stream messages are no longer valid after receiving trailing metadata.
if ((*calld->recv_message_) != nullptr) {
calld->context_.Span().AddReceivedMessageEvent(
calld->recv_message_count_++, (*calld->recv_message_)->length,
(*calld->recv_message_)->length);
calld->recv_message_count_++, (*calld->recv_message_)->length(),
(*calld->recv_message_)->length());
}
GRPC_CLOSURE_RUN(calld->initial_on_done_recv_message_, GRPC_ERROR_REF(error));
}
Expand Down Expand Up @@ -139,8 +139,8 @@ void CensusServerCallData::StartTransportStreamOpBatch(
if (op->send_message() != nullptr) {
context_.Span().AddSentMessageEvent(
sent_message_count_++,
op->op()->payload->send_message.send_message->length,
op->op()->payload->send_message.send_message->length);
op->op()->payload->send_message.send_message->length(),
op->op()->payload->send_message.send_message->length());
}
if (op->recv_message() != nullptr) {
recv_message_ = op->op()->payload->recv_message.recv_message;
Expand Down
6 changes: 4 additions & 2 deletions opencensus/plugins/grpc/internal/server_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "include/grpc/grpc_security.h"
#include "opencensus/plugins/grpc/internal/channel_filter.h"
#include "opencensus/plugins/grpc/internal/filter.h"
#include "src/core/lib/gprpp/orphanable.h"

namespace opencensus {

Expand Down Expand Up @@ -78,9 +79,10 @@ class CensusServerCallData : public grpc::CallData {
// recv message
grpc_closure *initial_on_done_recv_message_;
grpc_closure on_done_recv_message_;
absl::Time start_time_; // For measuring elapsed time.
absl::Time start_time_;
absl::Duration elapsed_time_;
grpc_byte_stream **recv_message_;
// The received message--may be null.
grpc_core::OrphanablePtr<grpc_core::ByteStream> *recv_message_; // Not owned.
uint32_t recv_message_count_;
uint32_t sent_message_count_;
};
Expand Down

0 comments on commit fc6f888

Please sign in to comment.