Skip to content

Commit ae954de

Browse files
authored
Merge pull request #334 from NREL/simplify-logging
Simplify analytics logging code
2 parents a83fd74 + 92a2c4b commit ae954de

File tree

27 files changed

+571
-901
lines changed

27 files changed

+571
-901
lines changed

config/default.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ https_port: 443
1414
nginx:
1515
workers: auto
1616
worker_connections: 8192
17-
access_log_filename: access.log.gz
18-
access_log_options: buffer=256k gzip=4 flush=10s
17+
access_log_filename: access.log
18+
access_log_options: buffer=256k flush=10s
1919
proxy_connect_timeout: 60
2020
proxy_read_timeout: 60
2121
proxy_send_timeout: 60
@@ -44,8 +44,6 @@ nginx:
4444
size: 20k
4545
locks:
4646
size: 20k
47-
logs:
48-
size: 5m
4947
resolved_hosts:
5048
size: 100k
5149
stats:

config/elasticsearch_templates.json

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,4 @@
11
[
2-
{
3-
"id": "api-umbrella-template",
4-
"template": {
5-
"template": "api-umbrella",
6-
"mappings": {
7-
"city": {
8-
"_all": {
9-
"enabled": false
10-
},
11-
"properties": {
12-
"updated_at": {
13-
"type": "date"
14-
},
15-
"country": {
16-
"type": "string",
17-
"index": "not_analyzed"
18-
},
19-
"region": {
20-
"type": "string",
21-
"index": "not_analyzed"
22-
},
23-
"city": {
24-
"type": "string",
25-
"index": "not_analyzed"
26-
},
27-
"location": {
28-
"type": "geo_point",
29-
"lat_lon": true
30-
}
31-
}
32-
}
33-
}
34-
}
35-
},
362
{
373
"id": "api-umbrella-log-v1-template",
384
"template": {
@@ -47,11 +13,6 @@
4713
"type": "custom",
4814
"tokenizer": "keyword",
4915
"filter": ["lowercase"]
50-
},
51-
"path_hierarchy_lowercase": {
52-
"type": "custom",
53-
"tokenizer": "path_hierarchy",
54-
"filter": ["lowercase"]
5516
}
5617
}
5718
}
@@ -160,10 +121,6 @@
160121
"type": "string",
161122
"analyzer": "keyword_lowercase"
162123
},
163-
"request_path_hierarchy": {
164-
"type": "string",
165-
"analyzer": "path_hierarchy_lowercase"
166-
},
167124
"request_referer": {
168125
"type": "string",
169126
"analyzer": "keyword_lowercase"
@@ -179,6 +136,10 @@
179136
"type": "string",
180137
"analyzer": "keyword_lowercase"
181138
},
139+
"request_url_query": {
140+
"type": "string",
141+
"analyzer": "keyword_lowercase"
142+
},
182143
"request_user_agent": {
183144
"type": "string",
184145
"analyzer": "keyword_lowercase"

config/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ nginx:
1212
# hard-coded for test purposes so we have a more stable baseline and ensure
1313
# our tests always run with multiple workers.
1414
workers: 2
15-
access_log_options: gzip=4
15+
access_log_options:
1616
proxy_connect_timeout: 10
1717
proxy_read_timeout: 10
1818
proxy_send_timeout: 10

src/api-umbrella/proxy/hooks/access.lua

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
local start_time = ngx.now()
2-
31
-- Try to find the matching API backend first, since it dictates further
42
-- settings and requirements.
53
local api = ngx.ctx.matched_api
@@ -17,7 +15,6 @@ local referer_validator = require "api-umbrella.proxy.middleware.referer_validat
1715
local rewrite_request = require "api-umbrella.proxy.middleware.rewrite_request"
1816
local role_validator = require "api-umbrella.proxy.middleware.role_validator"
1917
local user_settings = require "api-umbrella.proxy.middleware.user_settings"
20-
local utils = require "api-umbrella.proxy.utils"
2118

2219
local err
2320
local err_data
@@ -83,7 +80,3 @@ end
8380

8481
-- Store the settings for use by the header_filter.
8582
ngx.ctx.settings = settings
86-
87-
-- Compute how much time we spent in Lua processing during this phase of the
88-
-- request.
89-
utils.overhead_timer(start_time)
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
local wait_for_setup = require "api-umbrella.proxy.wait_for_setup"
22
wait_for_setup()
3-
4-
local log_timing_id = ngx.var.x_api_umbrella_request_id .. "_upstream_response_time"
5-
ngx.shared.logs:set(log_timing_id, "pending", 300)
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
local start_time = ngx.now()
2-
31
local error_handler = require "api-umbrella.proxy.error_handler"
42
local rewrite_response = require "api-umbrella.proxy.middleware.rewrite_response"
5-
local utils = require "api-umbrella.proxy.utils"
63

74
local settings = ngx.ctx.settings
85

@@ -11,7 +8,3 @@ local err = rewrite_response(settings)
118
if err then
129
return error_handler(err, settings)
1310
end
14-
15-
-- Compute how much time we spent in Lua processing during this phase of the
16-
-- request.
17-
utils.overhead_timer(start_time)

src/api-umbrella/proxy/hooks/log_api_backend_proxy.lua

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)