@@ -14,6 +14,7 @@ limitations under the License.
1414==============================================================================*/
1515
1616#include " tensorflow_serving/model_servers/server.h"
17+ #include " tensorflow_serving/util/tracer.h"
1718
1819#include < unistd.h>
1920
@@ -179,6 +180,35 @@ void Server::PollFilesystemAndReloadConfig(const string& config_file_path) {
179180}
180181
181182namespace {
183+ void ParseTimelineConfig (const Server::Options& options) {
184+ auto start_step = options.timeline_start_step ;
185+ auto interval_step = options.timeline_interval_step ;
186+ auto trace_count = options.timeline_trace_count ;
187+ auto path = options.timeline_path ;
188+ if (start_step >= 0 && interval_step > 0
189+ && trace_count > 0 && !path.empty ()) {
190+ // save timeline to local
191+ if (path[0 ] == ' /' ) {
192+ Tracer::GetTracer ()->SetParams (start_step, interval_step, trace_count, path);
193+ } else if (path.find (" oss://" ) != std::string::npos) {
194+ // save timeline to oss
195+ if (options.oss_endpoint == " " ||
196+ options.oss_access_id == " " ||
197+ options.oss_access_key == " " ) {
198+ LOG (ERROR) << " ERROR: Timeline require oss_endpoint, oss_access_id, and oss_access_key."
199+ << " We will not collect timeline." ;
200+ return ;
201+ }
202+ Tracer::GetTracer ()->SetParams (start_step,
203+ interval_step, trace_count, options.oss_endpoint ,
204+ options.oss_access_id , options.oss_access_key , path);
205+ } else {
206+ LOG (ERROR) << " ERROR: Only support to save timeline to local or oss now."
207+ << " We will not collect timeline." ;
208+ }
209+ }
210+ }
211+
182212Status CreatePlatformConfigMap (const Server::Options& server_options,
183213 ServerCore::Options& options) {
184214 const bool use_saved_model = true ;
@@ -201,6 +231,8 @@ Status CreatePlatformConfigMap(const Server::Options& server_options,
201231 " server_options.enable_batching to true." );
202232 }
203233
234+ ParseTimelineConfig (server_options);
235+
204236 session_bundle_config.mutable_session_config ()
205237 ->mutable_gpu_options ()
206238 ->set_per_process_gpu_memory_fraction (
@@ -260,6 +292,8 @@ Status CreatePlatformConfigMapV2(const Server::Options& server_options,
260292 auto model_session_config =
261293 session_bundle_config.add_model_session_config ();
262294
295+ ParseTimelineConfig (server_options);
296+
263297 // session num
264298 model_session_config->set_session_num (
265299 server_options.session_num_per_group );
0 commit comments