Skip to content

Commit

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

Signed-off-by: Gagan Juneja <[email protected]>

* Updates changelog

Signed-off-by: Gagan Juneja <[email protected]>

* Fixes spotless

Signed-off-by: Gagan Juneja <[email protected]>

---------

Signed-off-by: Gagan Juneja <[email protected]>
Co-authored-by: Gagan Juneja <[email protected]>
  • Loading branch information
Gaganjuneja and Gagan Juneja authored Jul 4, 2023
1 parent 64c0871 commit 7a5c810
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 @@ -76,6 +76,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Support OpenSSL Provider with default Netty allocator ([#5460](https://github.com/opensearch-project/OpenSearch/pull/5460))
- Replaces ZipInputStream with ZipFile to fix Zip Slip vulnerability ([#7230](https://github.com/opensearch-project/OpenSearch/pull/7230))
- Add missing validation/parsing of SearchBackpressureMode of SearchBackpressureSettings ([#7541](https://github.com/opensearch-project/OpenSearch/pull/7541))
- 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 7a5c810

Please sign in to comment.