Read Heka openstack_log config only once

This is an optimization avoiding to read the
heka_service_pattern configuration parameter on each call to
process_message.

Change-Id: I1d6299b263706661017920f28b4ebbc6a4cb30c3
This commit is contained in:
Éric Lemoine 2016-09-01 15:31:30 +02:00
parent c727f9c3fc
commit 43c4bf8839
1 changed files with 4 additions and 3 deletions

View File

@ -19,6 +19,9 @@ l.locale(l)
local patt = require 'os_patterns'
local utils = require 'os_utils'
local service_pattern = read_config("heka_service_pattern") or
error('heka_service_pattern must be specified')
local msg = {
Timestamp = nil,
Type = 'log',
@ -57,10 +60,8 @@ end
function process_message ()
local pattern = read_config("heka_service_pattern")
local cont_name = read_message("Fields[ContainerName]")
local program = string.match(cont_name, pattern)
local program = string.match(cont_name, service_pattern)
local service = nil
if program == nil then