Skip to content

Commit 780b9a8

Browse files
committed
Make scenario results to include start and end time for a test scenario.
This commit update the scenario results to include the start_timestamp and end_timstamp. These two fields are used in prometheus range queries to indicate the period we are pulling data for. Previously the timestamp was generated from GetCurrentTime() function defined in google/protobuf/util/time_util.h, however, google/protobuf/util/time_util.h has caused the import issue within google3. This commit solve the problem by directly seting the timestamp fields, avoiding using additional utility function.
1 parent 33f6664 commit 780b9a8

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/proto/grpc/testing/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ grpc_proto_library(
4242
name = "control_proto",
4343
srcs = ["control.proto"],
4444
has_services = False,
45+
well_known_protos = True,
4546
deps = [
4647
"payloads_proto",
4748
"stats_proto",
@@ -277,6 +278,7 @@ proto_library(
277278
deps = [
278279
":payloads_descriptor",
279280
":stats_descriptor",
281+
"@com_google_protobuf//:timestamp_proto",
280282
],
281283
)
282284

src/proto/grpc/testing/control.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ syntax = "proto3";
1616

1717
import "src/proto/grpc/testing/payloads.proto";
1818
import "src/proto/grpc/testing/stats.proto";
19+
import "google/protobuf/timestamp.proto";
1920

2021
package grpc.testing;
2122

@@ -265,6 +266,11 @@ message ScenarioResultSummary
265266
// Queries per CPU-sec over all servers or clients
266267
double server_queries_per_cpu_sec = 17;
267268
double client_queries_per_cpu_sec = 18;
269+
270+
271+
// Start and end time for the test scenario
272+
google.protobuf.Timestamp start_time = 19;
273+
google.protobuf.Timestamp end_time =20;
268274
}
269275

270276
// Results of a single benchmark scenario.

test/cpp/qps/driver.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include <unordered_map>
2626
#include <vector>
2727

28+
#include <google/protobuf/timestamp.pb.h>
29+
2830
#include <grpc/support/alloc.h>
2931
#include <grpc/support/log.h>
3032
#include <grpc/support/string_util.h>
@@ -573,6 +575,11 @@ std::unique_ptr<ScenarioResult> RunScenario(
573575

574576
// Start a run
575577
gpr_log(GPR_INFO, "Starting");
578+
579+
google::protobuf::Timestamp start_timestamp;
580+
start_timestamp.set_seconds(time(NULL));
581+
start_timestamp.set_nanos(0);
582+
576583
for (size_t i = 0; i < num_servers; i++) {
577584
auto server = &servers[i];
578585
if (!server->stream->Write(server_mark)) {
@@ -624,6 +631,10 @@ std::unique_ptr<ScenarioResult> RunScenario(
624631
bool client_finish_first =
625632
(client_config.rpc_type() != STREAMING_FROM_SERVER);
626633

634+
google::protobuf::Timestamp end_timestamp;
635+
end_timestamp.set_seconds(time(NULL));
636+
end_timestamp.set_nanos(0);
637+
627638
FinishClients(clients, client_mark);
628639

629640
if (!client_finish_first) {
@@ -650,6 +661,11 @@ std::unique_ptr<ScenarioResult> RunScenario(
650661
rrc->set_status_code(it->first);
651662
rrc->set_count(it->second);
652663
}
664+
665+
// Fill in start and end time for the test scenario
666+
result->mutable_summary()->mutable_start_time()->CopyFrom(start_timestamp);
667+
result->mutable_summary()->mutable_end_time()->CopyFrom(end_timestamp);
668+
653669
postprocess_scenario_result(result.get());
654670
return result;
655671
}

0 commit comments

Comments
 (0)