aboutsummaryrefslogtreecommitdiff
path: root/build.gradle
diff options
context:
space:
mode:
authorsebright <sebright@google.com>2018-08-27 09:49:05 -0700
committerGitHub <noreply@github.com>2018-08-27 09:49:05 -0700
commit0bbfec84cbf898ae7327880c43f9b5c60c49d4cd (patch)
treebfa669feb6c2d26d4eb644d38e4d1272fc13af92 /build.gradle
parentb8e6dcc312c9655a1d5709c15a2e408903314cbe (diff)
downloadopencensus-java-0bbfec84cbf898ae7327880c43f9b5c60c49d4cd.tar.gz
Start adding log correlation for Log4j. (#1371)
This commit takes the approach of implementing Log4j's ContextDataInjector. It inserts three keys into each log event: "`openCensusTraceId`", "`openCensusSpanId`", and "`openCensusTraceSampled`". The tracing data can be accessed with LogEvent.getContextData() or included in a layout. See https://logging.apache.org/log4j/2.x/log4j-core/apidocs/org/apache/logging/log4j/core/ContextDataInjector.html. Here is an example of a pattern layout that includes all three tracing fields and a log entry that could be produced by the layout: Pattern layout: "`%d{HH:mm:ss.SSS} [%t] traceId=%X{openCensusTraceId} spanId=%X{openCensusSpanId} sampled=%X{openCensusTraceSampled} %-5level %logger{36} - %msg%n`" Log entry: "`20:45:52.929 [main] traceId=0af7a7bef890695f1c5e85a8e7290164 spanId=d3f07c467ec2fbb2 sampled=true WARN io.opencensus.contrib.logcorrelation.log4j.demo.OpenCensusLog4jLogCorrelationDemo - my log message`" The ContextDataInjector implementation must be specified with a system property, i.e., "`-Dlog4j2.contextDataInjector=io.opencensus.contrib.logcorrelation.log4j.OpenCensusTraceContextDataInjector`". The system property "`io.opencensus.contrib.logcorrelation.log4j.OpenCensusTraceContextDataInjector.spanSelection`" controls whether tracing data is added to all spans, no spans, or only sampled spans.
Diffstat (limited to 'build.gradle')
-rw-r--r--build.gradle6
1 files changed, 6 insertions, 0 deletions
diff --git a/build.gradle b/build.gradle
index 30865c3a..0e08ed37 100644
--- a/build.gradle
+++ b/build.gradle
@@ -154,6 +154,7 @@ subprojects {
googleAuthVersion = '0.10.0'
googleCloudBetaVersion = '0.58.0-beta'
googleCloudGaVersion = '1.40.0'
+ log4jVersion = '2.11.1'
signalfxVersion = '0.0.39'
springVersion = '4.3.12.RELEASE'
prometheusVersion = '0.4.0'
@@ -174,6 +175,7 @@ subprojects {
google_auth: "com.google.auth:google-auth-library-credentials:${googleAuthVersion}",
google_cloud_logging: "com.google.cloud:google-cloud-logging:${googleCloudGaVersion}",
google_cloud_trace: "com.google.cloud:google-cloud-trace:${googleCloudBetaVersion}",
+ log4j: "org.apache.logging.log4j:log4j-core:${log4jVersion}",
zipkin_reporter: "io.zipkin.reporter2:zipkin-reporter:${zipkinReporterVersion}",
zipkin_urlconnection: "io.zipkin.reporter2:zipkin-sender-urlconnection:${zipkinReporterVersion}",
jaeger_reporter: "com.uber.jaeger:jaeger-core:${jaegerReporterVersion}",
@@ -371,6 +373,10 @@ subprojects {
'opencensus-contrib-grpc-metrics',
'opencensus-contrib-grpc-util',
'opencensus-contrib-http-util',
+
+ // TODO(sebright): Uncomment opencensus-contrib-log-correlation-log4j when it is complete.
+ // 'opencensus-contrib-log-correlation-log4j',
+
'opencensus-contrib-log-correlation-stackdriver',
'opencensus-contrib-monitored-resource-util',
'opencensus-contrib-spring',