1/* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14==============================================================================*/
15
16#ifndef TENSORFLOW_CORE_PLATFORM_ERROR_PAYLOADS_H_
17#define TENSORFLOW_CORE_PLATFORM_ERROR_PAYLOADS_H_
18
19#include "tensorflow/core/lib/core/status.h"
20#include "tensorflow/core/protobuf/core_platform_payloads.pb.h"
21// This file contains macros and payload keys for the error counter in
22// EagerClient.
23
24namespace tsl {
25
26// Proto: tensorflow::core::platform::ErrorSourceProto
27// Location: tensorflow/core/protobuf/core_platform_payloads.proto
28// Usage: Payload key for recording the error raised source. Payload value is
29// retrieved to update counter in
30// tensorflow/core/distributed_runtime/rpc/eager/grpc_eager_client.cc.
31constexpr char kErrorSource[] =
32 "type.googleapis.com/tensorflow.core.platform.ErrorSourceProto";
33
34// Set payload when status is not ok and ErrorSource payload hasn't been set.
35// The code below will be used at every place where we would like to catch
36// the error for the error counter in EagerClient.
37
38void OkOrSetErrorCounterPayload(
39 const tensorflow::core::platform::ErrorSourceProto::ErrorSource&
40 error_source,
41 tensorflow::Status& status);
42} // namespace tsl
43
44namespace tensorflow {
45using tsl::kErrorSource; // NOLINT
46using tsl::OkOrSetErrorCounterPayload; // NOLINT
47} // namespace tensorflow
48
49#endif // TENSORFLOW_CORE_PLATFORM_ERROR_PAYLOADS_H_
50