1/* Copyright 2021 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// APIs for accessing SavedModel and checkpoint metric objects.
16//
17// In order to collect the data from these metrics, please add the metrics to
18// the provided monitoring platform. Unless configured with a user-specified
19// monitoring platform, the data is not collected in OSS.
20
21#ifndef TENSORFLOW_CC_SAVED_MODEL_METRICS_H_
22#define TENSORFLOW_CC_SAVED_MODEL_METRICS_H_
23#include <string>
24
25#include "tensorflow/core/lib/monitoring/counter.h"
26#include "tensorflow/core/lib/monitoring/sampler.h"
27
28namespace tensorflow {
29namespace metrics {
30
31// Returns "/tensorflow/core/saved_model/write/count" cell. This metric
32// has 1 field "write_version", which is equal to the
33// `tensorflow::libexport::GetWriteVersion` of the protobuf and should be
34// incremented when a SavedModel has been successfully written.
35monitoring::CounterCell& SavedModelWrite(absl::string_view write_version);
36
37// Returns "/tensorflow/core/saved_model/read/count" cell. This metric
38// has 1 field "write_version", which is equal to the
39// `tensorflow::libexport::GetWriteVersion` of the protobuf, and should be
40// incremented when a SavedModel has been successfully read.
41monitoring::CounterCell& SavedModelRead(absl::string_view write_version);
42
43// Returns "/tensorflow/core/saved_model/write/api" cell. This metric has 1
44// field "api_label" which corresponds to a SavedModel write API. The cell for
45// `foo` should be incremented when the write API `foo` is called.
46monitoring::CounterCell& SavedModelWriteApi(absl::string_view api_label);
47
48// Returns "/tensorflow/core/saved_model/read/api" cell. This metric has 1
49// field "api_label" which corresponds to a SavedModel read API. The cell for
50// `foo` should be incremented when the read API `foo` is called.
51monitoring::CounterCell& SavedModelReadApi(absl::string_view api_label);
52
53// Returns "/tensorflow/core/checkpoint/read/read_durations" cell belonging to
54// field `api_label`.
55monitoring::SamplerCell& CheckpointReadDuration(absl::string_view api_label);
56
57// Returns "/tensorflow/core/checkpoint/write/write_durations" cell belonging to
58// field `api_label`.
59monitoring::SamplerCell& CheckpointWriteDuration(absl::string_view api_label);
60
61// Returns "/tensorflow/core/checkpoint/write/async_write_durations" cell
62// belonging to field `api_label`.
63monitoring::SamplerCell& AsyncCheckpointWriteDuration(
64 absl::string_view api_label);
65
66// Returns "/tensorflow/core/checkpoint/write/training_time_saved" cell
67// belonging to field `api_label`.
68monitoring::CounterCell& TrainingTimeSaved(absl::string_view api_label);
69
70// Returns "/tensorflow/core/checkpoint/write/checkpoint_size" cell
71// belonging to field (`api_label`, `filesize`).
72monitoring::CounterCell& CheckpointSize(absl::string_view api_label,
73 int64_t filesize);
74
75} // namespace metrics
76} // namespace tensorflow
77
78#endif // TENSORFLOW_CC_SAVED_MODEL_METRICS_H_
79