Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds log4j configuration for telemetry-otel plugin #8393

Merged
merged 3 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,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