mirror of https://github.com/grpc/grpc.git
[call-v3] Move `grpc_call_final_info` into its own target (#35504)
We probably want to reconsider this types role in the system, but for now removing it would be a large job. Move it to somewhere isolated for now.
Closes #35504
COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35504 from ctiller:move-it-stats 9ee755db79
PiperOrigin-RevId: 597382258
pull/35508/head
parent
a446df61f4
commit
3020a68b86
21 changed files with 141 additions and 47 deletions
@ -0,0 +1,38 @@ |
|||||||
|
// Copyright 2024 gRPC authors.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License 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 <grpc/support/port_platform.h> |
||||||
|
|
||||||
|
#include "src/core/lib/transport/call_final_info.h" |
||||||
|
|
||||||
|
#include <utility> |
||||||
|
|
||||||
|
static void move64bits(uint64_t* from, uint64_t* to) { |
||||||
|
*to += *from; |
||||||
|
*from = 0; |
||||||
|
} |
||||||
|
|
||||||
|
void grpc_transport_move_one_way_stats(grpc_transport_one_way_stats* from, |
||||||
|
grpc_transport_one_way_stats* to) { |
||||||
|
move64bits(&from->framing_bytes, &to->framing_bytes); |
||||||
|
move64bits(&from->data_bytes, &to->data_bytes); |
||||||
|
move64bits(&from->header_bytes, &to->header_bytes); |
||||||
|
} |
||||||
|
|
||||||
|
void grpc_transport_move_stats(grpc_transport_stream_stats* from, |
||||||
|
grpc_transport_stream_stats* to) { |
||||||
|
grpc_transport_move_one_way_stats(&from->incoming, &to->incoming); |
||||||
|
grpc_transport_move_one_way_stats(&from->outgoing, &to->outgoing); |
||||||
|
to->latency = std::exchange(from->latency, gpr_inf_future(GPR_TIMESPAN)); |
||||||
|
} |
@ -0,0 +1,54 @@ |
|||||||
|
// Copyright 2024 gRPC authors.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License 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.
|
||||||
|
|
||||||
|
#ifndef GRPC_SRC_CORE_LIB_TRANSPORT_CALL_FINAL_INFO_H |
||||||
|
#define GRPC_SRC_CORE_LIB_TRANSPORT_CALL_FINAL_INFO_H |
||||||
|
|
||||||
|
#include <grpc/support/port_platform.h> |
||||||
|
|
||||||
|
#include <cstdint> |
||||||
|
|
||||||
|
#include <grpc/status.h> |
||||||
|
#include <grpc/support/time.h> |
||||||
|
|
||||||
|
struct grpc_transport_one_way_stats { |
||||||
|
uint64_t framing_bytes = 0; |
||||||
|
uint64_t data_bytes = 0; |
||||||
|
uint64_t header_bytes = 0; |
||||||
|
}; |
||||||
|
|
||||||
|
struct grpc_transport_stream_stats { |
||||||
|
grpc_transport_one_way_stats incoming; |
||||||
|
grpc_transport_one_way_stats outgoing; |
||||||
|
gpr_timespec latency = gpr_inf_future(GPR_TIMESPAN); |
||||||
|
}; |
||||||
|
|
||||||
|
void grpc_transport_move_one_way_stats(grpc_transport_one_way_stats* from, |
||||||
|
grpc_transport_one_way_stats* to); |
||||||
|
|
||||||
|
void grpc_transport_move_stats(grpc_transport_stream_stats* from, |
||||||
|
grpc_transport_stream_stats* to); |
||||||
|
|
||||||
|
struct grpc_call_stats { |
||||||
|
grpc_transport_stream_stats transport_stream_stats; |
||||||
|
gpr_timespec latency; // From call creating to enqueing of received status
|
||||||
|
}; |
||||||
|
/// Information about the call upon completion.
|
||||||
|
struct grpc_call_final_info { |
||||||
|
grpc_call_stats stats; |
||||||
|
grpc_status_code final_status = GRPC_STATUS_OK; |
||||||
|
const char* error_string = nullptr; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // GRPC_SRC_CORE_LIB_TRANSPORT_CALL_FINAL_INFO_H
|
Loading…
Reference in new issue