Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update Apollo Protobuf #5032

Merged
merged 2 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ expression: aggregated_metrics
"client_name": "client_1",
"client_version": "version_1",
"operation_type": "",
"operation_subtype": ""
"operation_subtype": "",
"result": ""
},
{
"context": {
"client_name": "client_1",
"client_version": "version_1",
"operation_type": "",
"operation_subtype": ""
"operation_subtype": "",
"result": ""
},
"query_latency_stats": {
"request_latencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ impl From<ContextualizedStats>
.collect(),
query_latency_stats: Some(stats.query_latency_stats.into()),
context: Some(stats.context),
limits_stats: None,
local_per_type_stat: HashMap::new(),
operation_count: 0,
}
}
}
Expand Down Expand Up @@ -329,6 +332,7 @@ mod test {
SingleStats {
stats_with_context: SingleContextualizedStats {
context: StatsContext {
result: "".to_string(),
client_name: client_name.to_string(),
client_version: client_version.to_string(),
operation_type: String::new(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ expression: results
"client_name": "test_client",
"client_version": "1.0-test",
"operation_type": "subscription",
"operation_subtype": "subscription-request"
"operation_subtype": "subscription-request",
"result": ""
},
"query_latency_stats": {
"latency": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ expression: results
"client_name": "test_client",
"client_version": "1.0-test",
"operation_type": "subscription",
"operation_subtype": "subscription-request"
"operation_subtype": "subscription-request",
"result": ""
},
"query_latency_stats": {
"latency": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ expression: results
"client_name": "test_client",
"client_version": "1.0-test",
"operation_type": "query",
"operation_subtype": ""
"operation_subtype": "",
"result": ""
},
"query_latency_stats": {
"latency": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ expression: results
"client_name": "test_client",
"client_version": "1.0-test",
"operation_type": "query",
"operation_subtype": ""
"operation_subtype": "",
"result": ""
},
"query_latency_stats": {
"latency": {
Expand Down
1 change: 1 addition & 0 deletions apollo-router/src/plugins/telemetry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,7 @@ impl Telemetry {
SingleStats {
stats_with_context: SingleContextualizedStats {
context: StatsContext {
result: "".to_string(),
client_name: context
.get(CLIENT_NAME)
.unwrap_or_default()
Expand Down
78 changes: 78 additions & 0 deletions apollo-router/src/plugins/telemetry/proto/reports.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ syntax = "proto3";

import "google/protobuf/timestamp.proto";



message Trace {
message CachePolicy {
enum Scope {
Expand Down Expand Up @@ -196,6 +198,26 @@ message Trace {
}
}

// The cost of the operation
message Limits {
// The result of the operation.
string result = 1;
// The strategy used in cost calculations.
string strategy = 2;
// The estimated cost as calculated via the strategy specified in strategy
uint64 cost_estimated = 3;
// The actual cost using the strategy specified in strategy
uint64 cost_actual = 4;
// The depth of the query
uint64 depth = 5;
// The height of the query
uint64 height = 6;
// The number of aliases in the query
uint64 alias_count = 7;
// The number of root fields in the query
uint64 root_field_count = 8;
}

// Wallclock time when the trace began.
google.protobuf.Timestamp start_time = 4; // required
// Wallclock time when the trace ended.
Expand Down Expand Up @@ -283,6 +305,9 @@ message Trace {
// 0 is treated as 1 for backwards compatibility.
double field_execution_weight = 31;

// The limits information of the query.
Limits limits = 32;


// removed: Node parse = 12; Node validate = 13;
// Id128 server_id = 1; Id128 client_id = 2;
Expand Down Expand Up @@ -369,6 +394,29 @@ message QueryLatencyStats {
reserved 1, 6, 9, 10;
}

// Stats on the query that can be populated by the gateway or router.
message LimitsStats {
// The strategy used in cost calculations.
string strategy = 1;
// The estimated cost as calculated via the strategy specified in stats context
// The reason that this is a histogram rather than fixed cost is that it can be affected by paging variables.
repeated sint64 cost_estimated = 2 [(js_use_toArray) = true];
// The maximum estimated cost of the query
uint64 max_cost_estimated = 3;
// The actual cost using the strategy specified in stats context
repeated sint64 cost_actual = 4 [(js_use_toArray) = true];
// The maximum estimated cost of the query
uint64 max_cost_actual = 5;
// The total depth of the query
uint64 depth = 6;
// The height of the query
uint64 height = 7;
// The number of aliases in the query
uint64 alias_count = 8;
// The number of root fields in the query
uint64 root_field_count = 9;
}

// The context around a block of stats and traces indicating from which client the operation was executed and its
// operation type. Operation type and subtype are only used by Apollo Router.
message StatsContext {
Expand All @@ -377,6 +425,9 @@ message StatsContext {
string client_version = 3;
string operation_type = 4;
string operation_subtype = 5;
// The result of the operation. Either OK or the error code that caused the operation to fail.
// This will not contain all errors from a query, only the primary reason the operation failed. e.g. a limits failure or an auth failure.
string result = 6;
}

message ContextualizedQueryLatencyStats {
Expand Down Expand Up @@ -424,12 +475,27 @@ message FieldStat {
reserved 1, 2, 7, 8;
}

// As FieldStat only gets returned for FTV1 payloads this is a separate message that can be used to collect stats in the router or gateway obtained directly from the request schema and response.
message LocalFieldStat {
string return_type = 1; // required; eg "String!" for User.email:String!
// Histogram of returned array sizes
repeated sint64 array_size = 2 [(js_use_toArray) = true];
}

message TypeStat {
// Key is (eg) "email" for User.email:String!
map<string, FieldStat> per_field_stat = 3;

reserved 1, 2;
}

message LocalTypeStat {
// Key is (eg) "email" for User.email:String!
// Unlike FieldStat, this is populated outside of FTV1 requests.
map<string, LocalFieldStat> local_per_field_stat = 1;
}


message ReferencedFieldsForType {
// Contains (eg) "email" for User.email:String!
repeated string field_names = 1;
Expand Down Expand Up @@ -482,13 +548,24 @@ message Report {
bool traces_pre_aggregated = 7;
}


message ContextualizedStats {
StatsContext context = 1;
QueryLatencyStats query_latency_stats = 2;
// Key is type name. This structure provides data for the count and latency of individual
// field executions and thus only reflects operations for which field-level tracing occurred.
map<string, TypeStat> per_type_stat = 3;

// Per type stats that are obtained directly by the router or gateway rather than FTV1.
map<string, LocalTypeStat> local_per_type_stat = 7;

// Stats that contain limits information for the query.
LimitsStats limits_stats = 8;

// Total number of operations processed during this period for this context. This includes all operations, even if they are sampled
// and not included in the query latency stats.
uint64 operation_count = 9;

reserved 4, 5;
}

Expand Down Expand Up @@ -523,3 +600,4 @@ message TracesAndStats {

reserved 3;
}

Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ traces_per_query:
registered_operation: false
forbidden_operation: false
field_execution_weight: 1
limits: ~
sent_time_offset: "[sent_time_offset]"
sent_time:
seconds: "[seconds]"
Expand Down Expand Up @@ -429,6 +430,7 @@ traces_per_query:
registered_operation: false
forbidden_operation: false
field_execution_weight: 1
limits: ~
sent_time_offset: "[sent_time_offset]"
sent_time:
seconds: "[seconds]"
Expand Down Expand Up @@ -536,6 +538,7 @@ traces_per_query:
registered_operation: false
forbidden_operation: false
field_execution_weight: 1
limits: ~
sent_time_offset: "[sent_time_offset]"
sent_time:
seconds: "[seconds]"
Expand All @@ -549,6 +552,7 @@ traces_per_query:
registered_operation: false
forbidden_operation: false
field_execution_weight: 1
limits: ~
- start_time:
seconds: "[seconds]"
nanos: "[nanos]"
Expand Down Expand Up @@ -722,6 +726,7 @@ traces_per_query:
registered_operation: false
forbidden_operation: false
field_execution_weight: 1
limits: ~
sent_time_offset: "[sent_time_offset]"
sent_time:
seconds: "[seconds]"
Expand Down Expand Up @@ -965,6 +970,7 @@ traces_per_query:
registered_operation: false
forbidden_operation: false
field_execution_weight: 1
limits: ~
sent_time_offset: "[sent_time_offset]"
sent_time:
seconds: "[seconds]"
Expand Down Expand Up @@ -1072,6 +1078,7 @@ traces_per_query:
registered_operation: false
forbidden_operation: false
field_execution_weight: 1
limits: ~
sent_time_offset: "[sent_time_offset]"
sent_time:
seconds: "[seconds]"
Expand All @@ -1085,6 +1092,7 @@ traces_per_query:
registered_operation: false
forbidden_operation: false
field_execution_weight: 1
limits: ~
stats_with_context: []
referenced_fields_by_type: {}
query_metadata: ~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ traces_per_query:
registered_operation: false
forbidden_operation: false
field_execution_weight: 1
limits: ~
sent_time_offset: "[sent_time_offset]"
sent_time:
seconds: "[seconds]"
Expand Down Expand Up @@ -429,6 +430,7 @@ traces_per_query:
registered_operation: false
forbidden_operation: false
field_execution_weight: 1
limits: ~
sent_time_offset: "[sent_time_offset]"
sent_time:
seconds: "[seconds]"
Expand Down Expand Up @@ -536,6 +538,7 @@ traces_per_query:
registered_operation: false
forbidden_operation: false
field_execution_weight: 1
limits: ~
sent_time_offset: "[sent_time_offset]"
sent_time:
seconds: "[seconds]"
Expand All @@ -549,6 +552,7 @@ traces_per_query:
registered_operation: false
forbidden_operation: false
field_execution_weight: 1
limits: ~
- start_time:
seconds: "[seconds]"
nanos: "[nanos]"
Expand Down Expand Up @@ -722,6 +726,7 @@ traces_per_query:
registered_operation: false
forbidden_operation: false
field_execution_weight: 1
limits: ~
sent_time_offset: "[sent_time_offset]"
sent_time:
seconds: "[seconds]"
Expand Down Expand Up @@ -965,6 +970,7 @@ traces_per_query:
registered_operation: false
forbidden_operation: false
field_execution_weight: 1
limits: ~
sent_time_offset: "[sent_time_offset]"
sent_time:
seconds: "[seconds]"
Expand Down Expand Up @@ -1072,6 +1078,7 @@ traces_per_query:
registered_operation: false
forbidden_operation: false
field_execution_weight: 1
limits: ~
sent_time_offset: "[sent_time_offset]"
sent_time:
seconds: "[seconds]"
Expand All @@ -1085,6 +1092,7 @@ traces_per_query:
registered_operation: false
forbidden_operation: false
field_execution_weight: 1
limits: ~
stats_with_context: []
referenced_fields_by_type: {}
query_metadata: ~
Expand Down