mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
PERF: avoid shelling to get hostname aggressively
Previously we had many places in the app that called `hostname` to get hostname of a server. This commit replaces the pattern in 2 ways 1. We cache the result in `Discourse.os_hostname` so it is only ever called once 2. We prefer to use Socket.gethostname which avoids making a shell command This improves performance as we are not spawning hostname processes throughout the app lifetime
This commit is contained in:
@ -8,7 +8,7 @@ class DiscourseLogstashLogger
|
||||
uri: uri,
|
||||
sync: true,
|
||||
customize_event: ->(event) {
|
||||
event['hostname'] = `hostname`.chomp
|
||||
event['hostname'] = Discourse.os_hostname
|
||||
event['severity_name'] = event['severity']
|
||||
event['severity'] = Object.const_get("Logger::Severity::#{event['severity']}")
|
||||
event['type'] = type
|
||||
|
Reference in New Issue
Block a user