1# Copyright 2021 Google LLC 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15load("//fcp:config.bzl", "FCP_COPTS") 16 17package( 18 default_visibility = [ 19 "//fcp:internal", 20 ], 21 licenses = ["notice"], # Apache 2.0 22) 23 24cc_library( 25 name = "opstats_db", 26 hdrs = ["opstats_db.h"], 27 deps = [ 28 "//fcp/protos:opstats_cc_proto", 29 "@com_google_absl//absl/status", 30 "@com_google_absl//absl/status:statusor", 31 ], 32) 33 34cc_library( 35 name = "opstats_logger", 36 hdrs = ["opstats_logger.h"], 37 deps = [ 38 ":opstats_db", 39 "//fcp/client:interfaces", 40 "//fcp/protos:federated_api_cc_proto", 41 "//fcp/protos:opstats_cc_proto", 42 ], 43) 44 45cc_library( 46 name = "opstats_logger_impl", 47 srcs = ["opstats_logger_impl.cc"], 48 hdrs = ["opstats_logger_impl.h"], 49 copts = FCP_COPTS, 50 deps = [ 51 ":opstats_db", 52 ":opstats_logger", 53 "//fcp/base:time_util", 54 "//fcp/client:interfaces", 55 "//fcp/protos:federated_api_cc_proto", 56 "//fcp/protos:opstats_cc_proto", 57 "@com_google_absl//absl/synchronization", 58 "@com_google_protobuf//:protobuf", 59 ], 60) 61 62cc_test( 63 name = "opstats_logger_impl_test", 64 srcs = ["opstats_logger_impl_test.cc"], 65 deps = [ 66 ":opstats_logger_impl", 67 ":pds_backed_opstats_db", 68 "//fcp/base", 69 "//fcp/client:diag_codes_cc_proto", 70 "//fcp/client:histogram_counters_cc_proto", 71 "//fcp/client:test_helpers", 72 "//fcp/protos:opstats_cc_proto", 73 "//fcp/testing", 74 "@com_google_googletest//:gtest_main", 75 "@com_google_protobuf//:protobuf", 76 ], 77) 78 79cc_library( 80 name = "opstats_example_store", 81 srcs = ["opstats_example_store.cc"], 82 hdrs = ["opstats_example_store.h"], 83 deps = [ 84 ":opstats_db", 85 ":opstats_logger", 86 ":opstats_utils", 87 "//fcp/client:diag_codes_cc_proto", 88 "//fcp/client:interfaces", 89 "//fcp/client:simple_task_environment", 90 "//fcp/client/engine:example_iterator_factory", 91 "//fcp/protos:federated_api_cc_proto", 92 "//fcp/protos:opstats_cc_proto", 93 "//fcp/protos:plan_cc_proto", 94 "@com_google_absl//absl/status", 95 "@com_google_absl//absl/strings", 96 "@com_google_protobuf//:protobuf", 97 "@org_tensorflow//tensorflow/core:protos_all_cc", 98 ], 99) 100 101cc_test( 102 name = "opstats_example_store_test", 103 srcs = ["opstats_example_store_test.cc"], 104 deps = [ 105 ":opstats_example_store", 106 "//fcp/client:test_helpers", 107 "//fcp/protos:federated_api_cc_proto", 108 "//fcp/protos:plan_cc_proto", 109 "//fcp/testing", 110 "@com_google_googletest//:gtest_main", 111 "@com_google_protobuf//:protobuf", 112 "@org_tensorflow//tensorflow/core:protos_all_cc", 113 ], 114) 115 116cc_library( 117 name = "opstats_utils", 118 srcs = ["opstats_utils.cc"], 119 hdrs = ["opstats_utils.h"], 120 deps = [ 121 ":opstats_db", 122 "//fcp/base", 123 "//fcp/protos:opstats_cc_proto", 124 "@com_google_protobuf//:protobuf", 125 ], 126) 127 128cc_test( 129 name = "opstats_utils_test", 130 srcs = ["opstats_utils_test.cc"], 131 deps = [ 132 ":opstats_utils", 133 "//fcp/client:test_helpers", 134 "@com_google_googletest//:gtest_main", 135 ], 136) 137 138cc_library( 139 name = "pds_backed_opstats_db", 140 srcs = ["pds_backed_opstats_db.cc"], 141 hdrs = ["pds_backed_opstats_db.h"], 142 deps = [ 143 ":opstats_db", 144 "//fcp/base", 145 "//fcp/client:diag_codes_cc_proto", 146 "//fcp/client:interfaces", 147 "//fcp/protos:opstats_cc_proto", 148 "@com_google_absl//absl/container:flat_hash_set", 149 "@com_google_absl//absl/status", 150 "@com_google_absl//absl/status:statusor", 151 "@com_google_absl//absl/strings", 152 "@com_google_absl//absl/time", 153 "@com_google_protobuf//:protobuf", 154 "@protodatastore_cpp//protostore:file-storage", 155 "@protodatastore_cpp//protostore:proto-data-store", 156 ], 157) 158 159cc_test( 160 name = "pds_backed_opstats_db_test", 161 srcs = ["pds_backed_opstats_db_test.cc"], 162 deps = [ 163 ":pds_backed_opstats_db", 164 "//fcp/client:test_helpers", 165 "//fcp/protos:opstats_cc_proto", 166 "//fcp/testing", 167 "@com_google_absl//absl/status:statusor", 168 "@com_google_googletest//:gtest_main", 169 "@com_google_protobuf//:protobuf", 170 ], 171) 172