Skip to content

Commit

Permalink
Adds log4j configuration for telemetry-otel plugin (opensearch-projec…
Browse files Browse the repository at this point in the history
…t#8393)

* Adds log4j configuration for telemetry-otel plugin

Signed-off-by: Gagan Juneja <gjjuneja@amazon.com>

* Updates changelog

Signed-off-by: Gagan Juneja <gjjuneja@amazon.com>

* Fixes spotless

Signed-off-by: Gagan Juneja <gjjuneja@amazon.com>

---------

Signed-off-by: Gagan Juneja <gjjuneja@amazon.com>
Co-authored-by: Gagan Juneja <gjjuneja@amazon.com>
  • Loading branch information
Gaganjuneja and Gagan Juneja committed Jul 6, 2023
1 parent 58f4ce6 commit 07434cf
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fix mapping char_filter when mapping a hashtag ([#7591](https://github.com/opensearch-project/OpenSearch/pull/7591))
- Fix NPE in multiterms aggregations involving empty buckets ([#7318](https://github.com/opensearch-project/OpenSearch/pull/7318))
- Precise system clock time in MasterService debug logs ([#7902](https://github.com/opensearch-project/OpenSearch/pull/7902))
- Adds log4j configuration for telemetry LogSpanExporter ([#8393](https://github.com/opensearch-project/OpenSearch/pull/8393))

### Security

Expand Down
22 changes: 22 additions & 0 deletions plugins/telemetry-otel/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,25 @@ 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 07434cf

Please sign in to comment.