Add automatic X-Opaque-Id headers to datastore msearch requests#1135
Add automatic X-Opaque-Id headers to datastore msearch requests#1135
Conversation
myronmarston
left a comment
There was a problem hiding this comment.
Left some mild feedback. I'm also curious if you can describe how you plan to use these ids (as I've not seen them before)? During an incident will you list the tasks on nodes having problems (which would include the opaque ids, I guess?) and then use those opaque ids to cancel requests? Are the properties that matter uniqueness and ability to correlate it to a client of your application so that you can understand the consequences of cancelling a task?
2fcc7a8 to
ac08f3c
Compare
f6eaa34 to
6b3c83f
Compare
There was a problem hiding this comment.
Would it be useful to set OPAQUE_ID from the bulk calls as well?
There was a problem hiding this comment.
Would it be useful to set
OPAQUE_IDfrom thebulkcalls as well?
I think this is still worth considering in a followup PR if you have any ideas for what to use.
There was a problem hiding this comment.
Yep, I want to think through adding this, but haven't decided what is best to include yet. Will do this as a followup
| OPAQUE_ID_HEADER => Support::OpaqueID.build_header([ | ||
| "elasticgraph-indexer", | ||
| "purpose=source_event_versions", | ||
| "cluster=#{client_name}" |
There was a problem hiding this comment.
It's not clear to me why cluster is useful here. At the point you're seeing these opaque ids (e.g. in an OpenSearch task list) you'll know what cluster you're hitting, right? Or are you expecting these opaque ids to wind up in a centralized logging system that contains opaque ids data from multiple clusters?
In terms of other potential useful bits of data to include...maybe include the count of operations per type? e.g. widget_ops=7;team_ops=12
That would indicate at a glance how large of request it was and which types the request is for.
|
|
||
| def datastore_msearch(queries) | ||
| @datastore_search_router.msearch(queries) | ||
| @datastore_search_router.msearch(queries, opaque_id_parts: ["elasticgraph-health_check"]) |
There was a problem hiding this comment.
Is it worth including of types being queried here? You could change the caller from datastore_msearch(recency_queries_by_type_name.values) to datastore_msearch(recency_queries_by_type_name) and then you'd have the queried types as keys and the queries themselves as values. The types could nicely go in the opaque id.
b8a3704 to
0160824
Compare
There was a problem hiding this comment.
Would it be useful to set
OPAQUE_IDfrom thebulkcalls as well?
I think this is still worth considering in a followup PR if you have any ideas for what to use.
0160824 to
bd799e2
Compare
Elasticsearch and OpenSearch propagate the
X-Opaque-IdHTTP header into the tasks API, slow logs, and deprecation logs. This PR now makes ElasticGraph set useful opaque ids itself for datastore_msearchtraffic instead of offering an opt-in Faraday middleware that applications wire manually.What changed
ElasticGraph::Support::FaradayMiddleware::OpaqueIdmiddleware and its opt-indatastore_client_customization_blockdesign.ElasticGraph::GraphQL::Client#extra_opaque_id_partsas the GraphQL customization hook.elasticgraph-graphqlnow automatically includesX-Opaque-Idon datastore_msearchrequests using stable EG-owned parts:elasticgraph-graphqlclient=<client.name>client.extra_opaque_id_partsquery=<fingerprint>QueryExecutor->QuerySource->DatastoreSearchRouterrather than relying on Faraday env customization._msearchcall sites:elasticgraph-health_check->elasticgraph-health_checkelasticgraph-apollo;resolver=productelasticgraph-indexer#source_event_versions_in_index->elasticgraph-indexer;purpose=source_event_versions;cluster=<cluster>Why this shape
_bulkfor now. Indexer write traffic still needs a better request-identity model before we choose default opaque-id semantics there.Notes
ElasticGraph::Support::OpaqueIDformatter remains for assembling and sanitizing header values.X-Opaque-Idheader name now lives inelastic_graph/constants.Verification
GraphQL::Clientnormalization, health-check_msearch, and indexer source-event-version lookups.ruby -cpassed on the touched Ruby files.git diff --checkis clean.aws_lambda_ric,faker,httpx, andnokogiri.