Skip to content

Commit dc0d4e5

Browse files
JPERF-838: Add Log4j2SplunkForwarder SplunkForwarder decorator to handle log4j2 config files.
1 parent a4477a8 commit dc0d4e5

3 files changed

Lines changed: 21 additions & 10 deletions

File tree

src/main/kotlin/com/atlassian/performance/tools/infrastructure/api/jira/JiraNodeConfig.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.atlassian.performance.tools.infrastructure.api.jvm.jmx.DisabledRemote
99
import com.atlassian.performance.tools.infrastructure.api.jvm.jmx.RemoteJmx
1010
import com.atlassian.performance.tools.infrastructure.api.profiler.Profiler
1111
import com.atlassian.performance.tools.infrastructure.api.splunk.DisabledSplunkForwarder
12+
import com.atlassian.performance.tools.infrastructure.api.splunk.Log4j2SplunkForwarder
1213
import com.atlassian.performance.tools.infrastructure.api.splunk.SplunkForwarder
1314
import com.atlassian.performance.tools.infrastructure.profiler.DisabledProfiler
1415
import java.net.URI
@@ -40,7 +41,7 @@ class JiraNodeConfig private constructor(
4041
remoteJmx = remoteJmx,
4142
jvmArgs = jvmArgs,
4243
collectdConfigs = collectdConfigs,
43-
splunkForwarder = splunkForwarder,
44+
splunkForwarder = Log4j2SplunkForwarder("log4j2.xml", splunkForwarder),
4445
launchTimeouts = launchTimeouts,
4546
jdk = OracleJDK(),
4647
profiler = DisabledProfiler()
@@ -77,7 +78,7 @@ class JiraNodeConfig private constructor(
7778
remoteJmx = remoteJmx,
7879
jvmArgs = jvmArgs,
7980
collectdConfigs = DEFAULT_COLLECTD_CONFIGS,
80-
splunkForwarder = splunkForwarder,
81+
splunkForwarder = Log4j2SplunkForwarder("log4j2.xml", splunkForwarder),
8182
launchTimeouts = launchTimeouts,
8283
jdk = OracleJDK(),
8384
profiler = DisabledProfiler()
@@ -143,7 +144,7 @@ class JiraNodeConfig private constructor(
143144
debug = debug,
144145
remoteJmx = remoteJmx,
145146
jvmArgs = jvmArgs,
146-
splunkForwarder = splunkForwarder,
147+
splunkForwarder = Log4j2SplunkForwarder("log4j2.xml", splunkForwarder),
147148
collectdConfigs = collectdConfigs,
148149
launchTimeouts = launchTimeouts,
149150
jdk = if (versionedJdk != null) versionedJdk as JavaDevelopmentKit else jdk,
@@ -157,4 +158,4 @@ class JiraNodeConfig private constructor(
157158
JiraNodeConfig::class.java.getResource("/collectd/conf/jira-default.conf").toURI()
158159
)
159160
}
160-
}
161+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.atlassian.performance.tools.infrastructure.api.splunk
2+
3+
import com.atlassian.performance.tools.infrastructure.splunk.Log4jJsonifier
4+
import com.atlassian.performance.tools.ssh.api.SshConnection
5+
import java.nio.file.Paths
6+
7+
class Log4j2SplunkForwarder(log4j2ConfigFileName: String, splunkForwarder: SplunkForwarder) :
8+
SplunkForwarder by splunkForwarder {
9+
10+
private val log4jConfigFileName = log4j2ConfigFileName
11+
12+
override fun jsonifyLog4j(sshConnection: SshConnection, log4jPropertiesPath: String) {
13+
val log4j2ConfigPath = Paths.get(log4jPropertiesPath).resolveSibling(log4jConfigFileName).toString()
14+
Log4jJsonifier().jsonifyLog4j1AndLog4j2(sshConnection, log4jPropertiesPath, log4j2ConfigPath)
15+
}
16+
}
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
package com.atlassian.performance.tools.infrastructure.api.splunk
22

3-
import com.atlassian.performance.tools.infrastructure.splunk.Log4jJsonifier
43
import com.atlassian.performance.tools.ssh.api.SshConnection
54

65
interface SplunkForwarder {
76
fun run(sshConnection: SshConnection, name: String, logsPath: String)
87
fun jsonifyLog4j(sshConnection: SshConnection, log4jPropertiesPath: String)
98
fun getRequiredPorts(): List<Int>
109
}
11-
12-
// Extension method to avoid breaking changes
13-
fun SplunkForwarder.jsonifyLog4j1AndLog4j2(sshConnection: SshConnection, log4jPropertiesPath: String, log4j2ConfigPath: String) {
14-
Log4jJsonifier().jsonifyLog4j1AndLog4j2(sshConnection, log4jPropertiesPath, log4j2ConfigPath)
15-
}

0 commit comments

Comments
 (0)