Skip to content

Commit

Permalink
Merge pull request #334 from NREL/simplify-logging
Browse files Browse the repository at this point in the history
Simplify analytics logging code
  • Loading branch information
GUI authored Feb 5, 2017
2 parents a83fd74 + 92a2c4b commit ae954de
Show file tree
Hide file tree
Showing 27 changed files with 571 additions and 901 deletions.
6 changes: 2 additions & 4 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ https_port: 443
nginx:
workers: auto
worker_connections: 8192
access_log_filename: access.log.gz
access_log_options: buffer=256k gzip=4 flush=10s
access_log_filename: access.log
access_log_options: buffer=256k flush=10s
proxy_connect_timeout: 60
proxy_read_timeout: 60
proxy_send_timeout: 60
Expand Down Expand Up @@ -44,8 +44,6 @@ nginx:
size: 20k
locks:
size: 20k
logs:
size: 5m
resolved_hosts:
size: 100k
stats:
Expand Down
47 changes: 4 additions & 43 deletions config/elasticsearch_templates.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,4 @@
[
{
"id": "api-umbrella-template",
"template": {
"template": "api-umbrella",
"mappings": {
"city": {
"_all": {
"enabled": false
},
"properties": {
"updated_at": {
"type": "date"
},
"country": {
"type": "string",
"index": "not_analyzed"
},
"region": {
"type": "string",
"index": "not_analyzed"
},
"city": {
"type": "string",
"index": "not_analyzed"
},
"location": {
"type": "geo_point",
"lat_lon": true
}
}
}
}
}
},
{
"id": "api-umbrella-log-v1-template",
"template": {
Expand All @@ -47,11 +13,6 @@
"type": "custom",
"tokenizer": "keyword",
"filter": ["lowercase"]
},
"path_hierarchy_lowercase": {
"type": "custom",
"tokenizer": "path_hierarchy",
"filter": ["lowercase"]
}
}
}
Expand Down Expand Up @@ -160,10 +121,6 @@
"type": "string",
"analyzer": "keyword_lowercase"
},
"request_path_hierarchy": {
"type": "string",
"analyzer": "path_hierarchy_lowercase"
},
"request_referer": {
"type": "string",
"analyzer": "keyword_lowercase"
Expand All @@ -179,6 +136,10 @@
"type": "string",
"analyzer": "keyword_lowercase"
},
"request_url_query": {
"type": "string",
"analyzer": "keyword_lowercase"
},
"request_user_agent": {
"type": "string",
"analyzer": "keyword_lowercase"
Expand Down
2 changes: 1 addition & 1 deletion config/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ nginx:
# hard-coded for test purposes so we have a more stable baseline and ensure
# our tests always run with multiple workers.
workers: 2
access_log_options: gzip=4
access_log_options:
proxy_connect_timeout: 10
proxy_read_timeout: 10
proxy_send_timeout: 10
Expand Down
7 changes: 0 additions & 7 deletions src/api-umbrella/proxy/hooks/access.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local start_time = ngx.now()

-- Try to find the matching API backend first, since it dictates further
-- settings and requirements.
local api = ngx.ctx.matched_api
Expand All @@ -17,7 +15,6 @@ local referer_validator = require "api-umbrella.proxy.middleware.referer_validat
local rewrite_request = require "api-umbrella.proxy.middleware.rewrite_request"
local role_validator = require "api-umbrella.proxy.middleware.role_validator"
local user_settings = require "api-umbrella.proxy.middleware.user_settings"
local utils = require "api-umbrella.proxy.utils"

local err
local err_data
Expand Down Expand Up @@ -83,7 +80,3 @@ end

-- Store the settings for use by the header_filter.
ngx.ctx.settings = settings

-- Compute how much time we spent in Lua processing during this phase of the
-- request.
utils.overhead_timer(start_time)
3 changes: 0 additions & 3 deletions src/api-umbrella/proxy/hooks/api_backends_access.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
local wait_for_setup = require "api-umbrella.proxy.wait_for_setup"
wait_for_setup()

local log_timing_id = ngx.var.x_api_umbrella_request_id .. "_upstream_response_time"
ngx.shared.logs:set(log_timing_id, "pending", 300)
7 changes: 0 additions & 7 deletions src/api-umbrella/proxy/hooks/header_filter.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
local start_time = ngx.now()

local error_handler = require "api-umbrella.proxy.error_handler"
local rewrite_response = require "api-umbrella.proxy.middleware.rewrite_response"
local utils = require "api-umbrella.proxy.utils"

local settings = ngx.ctx.settings

Expand All @@ -11,7 +8,3 @@ local err = rewrite_response(settings)
if err then
return error_handler(err, settings)
end

-- Compute how much time we spent in Lua processing during this phase of the
-- request.
utils.overhead_timer(start_time)
28 changes: 0 additions & 28 deletions src/api-umbrella/proxy/hooks/log_api_backend_proxy.lua

This file was deleted.

Loading

0 comments on commit ae954de

Please sign in to comment.