Skip to content

Commit

Permalink
added tracking to which es host the search was sent
Browse files Browse the repository at this point in the history
  • Loading branch information
itayw committed Dec 29, 2019
1 parent 21d73bc commit 615b1e2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The proxy intercepts search requests and record them into Elasticsearch for furt
"x-opaque-id": "123",
"content-type": "application/json",
"x-query-tracker-id": "1234",
"x-query-tracker-tags": "itay, or"
"x-query-tracker-tags": "auth, login"
},
"tags": [
"itay",
Expand Down
2 changes: 2 additions & 0 deletions lib/finish_tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ function sign_request(context, res) {
context.times.end = new Date();
context.times.req_took_ms = context.times.end - context.times.start;
const body = JSON.parse(res.payload.body);
const target = res.payload.target;
context.times.elastic_took_ms = body.took;
//context.query.times = context.times;

context.response = {
es_host: target,
took: body.took,
timed_out: body.timed_out,
shards: body._shards,
Expand Down
4 changes: 3 additions & 1 deletion lib/proxy_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ const wreck = Wreck.defaults({

function proxy_request(req, res) {

const target = fetch_host(process.env.ELASTIC_HOST || 'http://localhost:9200');
// all attributes are optional
const options = {
baseUrl: fetch_host(process.env.ELASTIC_HOST || 'http://localhost:9200'),
baseUrl: target,
//payload: readableStream || 'foo=bar' || new Buffer('foo=bar'),
headers: { /* http headers */ },
redirects: 3,
Expand Down Expand Up @@ -52,6 +53,7 @@ function proxy_request(req, res) {
res.payload = {
statusCode: response.statusCode,
headers: response.headers,
target,
body
};
return resolve();
Expand Down

0 comments on commit 615b1e2

Please sign in to comment.