Skip to content

Commit

Permalink
Adds log4j configuration for telemetry-otel plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Gagan Juneja <gjjuneja@amazon.com>
  • Loading branch information
Gagan Juneja committed Jul 2, 2023
1 parent 544b1ca commit ec492e1
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
23 changes: 23 additions & 0 deletions plugins/telemetry-otel/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,26 @@ thirdPartyAudit {
'io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider'
)
}

tasks.named("bundlePlugin").configure {
from('config/telemetry-otel') {
into 'config'
}
}

tasks.register("writeTestJavaPolicy") {
doLast {
final File tmp = file("${buildDir}/tmp")
if (tmp.exists() == false && tmp.mkdirs() == false) {
throw new GradleException("failed to create temporary directory [${tmp}]")
}
final File javaPolicy = file("${tmp}/java.policy")
javaPolicy.write(
[
"grant {",
" permission java.io.FilePermission \"config\", \"read\";",
"};"
].join("\n"))
}
}

27 changes: 27 additions & 0 deletions plugins/telemetry-otel/config/telemetry-otel/log4j2.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
#


appender.tracing.type = RollingFile
appender.tracing.name = tracing
appender.tracing.fileName = ${sys:opensearch.logs.base_path}${sys:file.separator}${sys:opensearch.logs.cluster_name}_otel_traces.log
appender.tracing.filePermissions = rw-r-----
appender.tracing.layout.type = PatternLayout
appender.tracing.layout.pattern = %m%n
appender.tracing.filePattern = ${sys:opensearch.logs.base_path}${sys:file.separator}${sys:opensearch.logs.cluster_name}_otel_traces-%i.log.gz
appender.tracing.policies.type = Policies
appender.tracing.policies.size.type = SizeBasedTriggeringPolicy
appender.tracing.policies.size.size = 1GB
appender.tracing.strategy.type = DefaultRolloverStrategy
appender.tracing.strategy.max = 4


logger.exporter.name = io.opentelemetry.exporter.logging.LoggingSpanExporter
logger.exporter.level = INFO
logger.exporter.appenderRef.tracing.ref = tracing
logger.exporter.additivity = false
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private OTelResourceProvider() {}
public static OpenTelemetry get(Settings settings) {
return get(
settings,
new LoggingSpanExporter(),
LoggingSpanExporter.create(),
ContextPropagators.create(W3CTraceContextPropagator.getInstance()),
Sampler.alwaysOn()
);
Expand Down

0 comments on commit ec492e1

Please sign in to comment.