1/* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17syntax = "proto2"; 18 19package perfetto.protos; 20 21import "protos/perfetto/trace_processor/trace_processor.proto"; 22import "protos/perfetto/cloud_trace_processor/common.proto"; 23 24// Interface for a CloudTraceProcessor "Worker". 25// 26// Workers are are owned by a |Orchestrator| who assigns groups of traces to 27// them (known as a PoolShards) and forwards any requests from end users. 28// Workers are reponsible for loading assigned traces with TraceProcessor and 29// executing the requests. 30service CloudTraceProcessorWorker { 31 // Creates a TracePoolShard which will be owned by this worker and returns 32 // whether it was successfully created. 33 // 34 // Orchestrators are responsible for handling groups of traces which the user 35 // has requested to be loaded: these are known as TracePools. The orchestrator 36 // then breaks these pools into pieces and shards them out to workers, each of 37 // which is known as a TracePoolShard. 38 // 39 // Thus, a TracePoolShard is unique identified by the tuple (worker, pool id). 40 rpc TracePoolShardCreate(TracePoolShardCreateArgs) 41 returns (TracePoolShardCreateResponse); 42 43 // Associates the provided list of traces to this TracePoolShard and returns 44 // a stream with each element indicating the successful load of one trace 45 // (which allows monitoring the progress of loads) or a terminal error if the 46 // assignment of any trace failed. 47 // 48 // If this operation completes successfully, any future requests to this pool 49 // shard will refer to this set of traces. 50 rpc TracePoolShardSetTraces(TracePoolShardSetTracesArgs) 51 returns (stream TracePoolShardSetTracesResponse); 52 53 // Executes a SQL query on the specified TracePoolShard and returns a stream 54 // with each element being the response for executing the query on the 55 // associated trace. 56 // 57 // Note that each trace can return >1 result due to chunking of protos at the 58 // TraceProcessor::QueryResult level. 59 rpc TracePoolShardQuery(TracePoolShardQueryArgs) 60 returns (stream TracePoolShardQueryResponse); 61 62 // Destroys the TracePoolShard with the specified id. 63 // 64 // Any future requests to this shard id will return an error. However, the 65 // same pool id can be used to create a new shard. 66 rpc TracePoolShardDestroy(TracePoolShardDestroyArgs) 67 returns (TracePoolShardDestroyResponse); 68} 69 70// Request/Response for Worker::TracePoolShardCreate. 71message TracePoolShardCreateArgs { 72 optional string pool_id = 1; 73 optional TracePoolType pool_type = 2; 74} 75message TracePoolShardCreateResponse {} 76 77// Request/Response for Worker::TracePoolShardSetTraces. 78message TracePoolShardSetTracesArgs { 79 optional string pool_id = 1; 80 81 // The list of traces which should be associated with this shard. The existing 82 // loaded trace list will be diffed against this list. Traces not present in 83 // this list and loaded will be unloaded while traces present in this list 84 // and unloaded will be loaded. 85 repeated string traces = 2; 86} 87message TracePoolShardSetTracesResponse { 88 optional string trace = 1; 89} 90 91// Request/Response for Worker::TracePoolShardQuery. 92message TracePoolShardQueryArgs { 93 optional string pool_id = 1; 94 optional string sql_query = 2; 95} 96message TracePoolShardQueryResponse { 97 optional string trace = 1; 98 optional QueryResult result = 2; 99} 100 101// Request/Response for Worker::TracePoolShardDestroy. 102message TracePoolShardDestroyArgs { 103 optional string pool_id = 1; 104} 105message TracePoolShardDestroyResponse {} 106