Skip to content

Commit f7c7ed6

Browse files
authored
repo-sync-2024-05-13T14:58:14+0800 (#61)
1 parent 90a1e52 commit f7c7ed6

File tree

8 files changed

+47
-16
lines changed

8 files changed

+47
-16
lines changed

examples/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ filegroup(
2020
"alice/glm-test.tar.gz",
2121
"alice/logging.config",
2222
"alice/serving.config",
23+
"alice/trace.config",
2324
"bob/glm-test.tar.gz",
2425
"bob/logging.config",
2526
"bob/serving.config",
27+
"bob/trace.config",
2628
],
2729
)

secretflow_serving/feature_adapter/http_adapter.cc

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,24 +118,29 @@ void HttpFeatureAdapter::OnFetchFeature(const Request& request,
118118
channel_->CallMethod(NULL, &cntl, NULL, NULL, NULL);
119119
if (cntl.Failed()) {
120120
span_option.code = errors::ErrorCode::NETWORK_ERROR;
121-
span_option.msg =
122-
fmt::format("http request failed, endpoint:{}, detail:{}",
123-
spec_.http_opts().endpoint(), cntl.ErrorText());
121+
span_option.msg = fmt::format(
122+
"http request failed, endpoint:{}, request: {}, error info detail:{}",
123+
spec_.http_opts().endpoint(), spi_request, cntl.ErrorText());
124124
} else {
125125
auto status = ::google::protobuf::util::JsonStringToMessage(
126126
cntl.response_attachment().to_string(), &spi_response);
127127
if (!status.ok()) {
128128
span_option.code = errors::ErrorCode::DESERIALIZE_FAILED;
129-
span_option.msg = fmt::format("deserialize response context failed: {}",
130-
status.ToString());
129+
span_option.msg = fmt::format(
130+
"deserialize response context failed: request: {}, error: {}",
131+
spi_request, status.ToString());
132+
131133
} else if (spi_response.status().code() != spis::ErrorCode::OK) {
132134
span_option.code = MappingErrorCode(spi_response.status().code());
133135
span_option.msg = fmt::format(
134-
"fetch features response error, msg: {}, code: {}",
135-
spi_response.status().msg(), spi_response.status().code());
136+
"fetch features response error, request: {}, msg: {}, code: {}",
137+
spi_request, spi_response.status().msg(),
138+
spi_response.status().code());
139+
136140
} else if (spi_response.features().empty()) {
137141
span_option.code = errors::ErrorCode::IO_ERROR;
138-
span_option.msg = "get empty features.";
142+
span_option.msg =
143+
fmt::format("get empty features, request: {}", spi_request);
139144
}
140145
}
141146

secretflow_serving/framework/model_info_collector.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ ModelInfoCollector::ModelInfoCollector(Options opts) : opts_(std::move(opts)) {
9696
node_view, std::set<std::string>(node_view.parents().begin(),
9797
node_view.parents().end()));
9898
}
99+
100+
SPDLOG_INFO("local model info: party: {} : {}", opts_.self_party_id,
101+
PbToJson(&model_info_));
99102
}
100103

101104
void ModelInfoCollector::DoCollect() {
@@ -107,6 +110,10 @@ void ModelInfoCollector::DoCollect() {
107110
"GetModelInfo from {} failed.", remote_party_id);
108111
}
109112

113+
for (const auto& [remote_party_id, model_info] : model_info_map_) {
114+
SPDLOG_INFO("model info: party: {} : {}", remote_party_id,
115+
PbToJson(&model_info));
116+
}
110117
CheckAndSetSpecificMap();
111118
}
112119

secretflow_serving/server/execution_core.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "secretflow_serving/feature_adapter/feature_adapter_factory.h"
2121
#include "secretflow_serving/util/arrow_helper.h"
2222
#include "secretflow_serving/util/thread_pool.h"
23+
#include "secretflow_serving/util/utils.h"
2324

2425
namespace secretflow::serving {
2526

@@ -134,12 +135,14 @@ void ExecutionCore::Execute(const apis::ExecuteRequest* request,
134135
}
135136
response->mutable_status()->set_code(errors::ErrorCode::OK);
136137
} catch (const Exception& e) {
137-
SPDLOG_ERROR("execute failed, code:{}, msg:{}, stack:{}", e.code(),
138-
e.what(), e.stack_trace());
138+
SPDLOG_ERROR("execute failed, request: {}, code:{}, msg:{}, stack:{}",
139+
PbToJsonNoExcept(request), e.code(), e.what(),
140+
e.stack_trace());
139141
response->mutable_status()->set_code(e.code());
140142
response->mutable_status()->set_msg(e.what());
141143
} catch (const std::exception& e) {
142-
SPDLOG_ERROR("execute failed, msg:{}", e.what());
144+
SPDLOG_ERROR("execute failed, request: {}, msg:{}",
145+
PbToJsonNoExcept(request), e.what());
143146
response->mutable_status()->set_code(errors::ErrorCode::UNEXPECTED_ERROR);
144147
response->mutable_status()->set_msg(e.what());
145148
}

secretflow_serving/server/prediction_core.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@ void PredictionCore::Predict(const apis::PredictRequest* request,
5252
opts_.predictor->Predict(request, response);
5353
status->set_code(errors::ErrorCode::OK);
5454
} catch (const Exception& e) {
55-
SPDLOG_ERROR("Predict failed, code:{}, msg:{}, stack:{}", e.code(),
56-
e.what(), e.stack_trace());
55+
SPDLOG_ERROR("Predict failed, request: {}, code:{}, msg:{}, stack:{}",
56+
PbToJsonNoExcept(request), e.code(), e.what(),
57+
e.stack_trace());
5758
response->mutable_status()->set_code(e.code());
5859
response->mutable_status()->set_msg(e.what());
5960
} catch (const std::exception& e) {
60-
SPDLOG_ERROR("Predict failed, msg:{}", e.what());
61+
SPDLOG_ERROR("Predict failed, request: {}, msg:{}",
62+
PbToJsonNoExcept(request), e.what());
6163
response->mutable_status()->set_code(errors::ErrorCode::UNEXPECTED_ERROR);
6264
response->mutable_status()->set_msg(e.what());
6365
}

secretflow_serving/util/thread_safe_queue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ThreadSafeQueue {
4242
buffer_[i] = std::move(buffer[i]);
4343
}
4444
SERVING_ENFORCE(wait_ms_ > 0, errors::ErrorCode::INVALID_ARGUMENT,
45-
"wait_ms should not be zero", wait_ms_);
45+
"wait_ms({}) should not be zero", wait_ms_);
4646
}
4747

4848
ThreadSafeQueue(const ThreadSafeQueue&) = delete;

secretflow_serving/util/utils.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,13 @@ std::string PbToJson(const ::google::protobuf::Message* message) {
6767
return json;
6868
}
6969

70+
std::string PbToJsonNoExcept(
71+
const ::google::protobuf::Message* message) noexcept {
72+
try {
73+
return PbToJson(message);
74+
} catch (...) {
75+
return "ill_format_message";
76+
}
77+
}
78+
7079
} // namespace secretflow::serving

secretflow_serving/util/utils.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ void JsonToPb(const std::string& json, ::google::protobuf::Message* message);
4242

4343
std::string PbToJson(const ::google::protobuf::Message* message);
4444

45+
std::string PbToJsonNoExcept(
46+
const ::google::protobuf::Message* message) noexcept;
47+
4548
template <typename Func>
4649
void FeatureVisit(Func&& visitor, const Feature& f) {
4750
switch (f.field().type()) {
@@ -70,7 +73,7 @@ void FeatureVisit(Func&& visitor, const Feature& f) {
7073
break;
7174
}
7275
default:
73-
SERVING_THROW(errors::ErrorCode::UNEXPECTED_ERROR, "unkown field type",
76+
SERVING_THROW(errors::ErrorCode::UNEXPECTED_ERROR, "unkown field type {}",
7477
FieldType_Name(f.field().type()));
7578
}
7679
}

0 commit comments

Comments
 (0)