Skip to content

Commit

Permalink
Bump log4j version for library instrumentation to 2.17 (open-telemetr…
Browse files Browse the repository at this point in the history
…y#5849)

* Bump log4j library version to 2.17

* muzzle
  • Loading branch information
trask committed Apr 19, 2022
1 parent c7f6eab commit 8506169
Show file tree
Hide file tree
Showing 26 changed files with 37 additions and 40 deletions.
4 changes: 2 additions & 2 deletions docs/standalone-library-instrumentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ that can be used if you prefer that over using the Java agent:
* [Ktor 1.0](../instrumentation/ktor/ktor-1.0/library)
* [Ktor 2.0](../instrumentation/ktor/ktor-2.0/library)
* [Lettuce](../instrumentation/lettuce/lettuce-5.1/library)
* [Log4j appender](../instrumentation/log4j/log4j-appender-2.16/library)
* [Log4j thread context](../instrumentation/log4j/log4j-context-data/log4j-context-data-2.16/library-autoconfigure)
* [Log4j appender](../instrumentation/log4j/log4j-appender-2.17/library)
* [Log4j thread context](../instrumentation/log4j/log4j-context-data/log4j-context-data-2.17/library-autoconfigure)
* [Logback](../instrumentation/logback/logback-appender-1.0/library)
* [MongoDB Driver](../instrumentation/mongo/mongo-3.1/library)
* [OkHttp](../instrumentation/okhttp/okhttp-3.0/library)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ muzzle {
}

dependencies {
library("org.apache.logging.log4j:log4j-core:2.16.0")
library("org.apache.logging.log4j:log4j-core:2.17.0")

compileOnly(project(":instrumentation-appender-api-internal"))
compileOnly(project(":javaagent-bootstrap"))

implementation(project(":instrumentation:log4j:log4j-appender-2.16:library"))
implementation(project(":instrumentation:log4j:log4j-appender-2.17:library"))

testImplementation("org.awaitility:awaitility")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public class Log4jAppenderInstrumentationModule extends InstrumentationModule {

public Log4jAppenderInstrumentationModule() {
super("log4j-appender", "log4j-appender-2.16");
super("log4j-appender", "log4j-appender-2.17");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ stable [release](https://search.maven.org/search?q=g:io.opentelemetry.instrument
<dependencies>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-log4j-appender-2.16</artifactId>
<artifactId>opentelemetry-log4j-appender-2.17</artifactId>
<version>OPENTELEMETRY_VERSION</version>
</dependency>
</dependencies>
Expand All @@ -26,7 +26,7 @@ stable [release](https://search.maven.org/search?q=g:io.opentelemetry.instrument

```kotlin
dependencies {
runtimeOnly("io.opentelemetry.instrumentation:opentelemetry-log4j-appender-2.16:OPENTELEMETRY_VERSION")
runtimeOnly("io.opentelemetry.instrumentation:opentelemetry-log4j-appender-2.17:OPENTELEMETRY_VERSION")
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies {
implementation(project(":instrumentation-appender-api-internal"))
implementation(project(":instrumentation-appender-sdk-internal"))

library("org.apache.logging.log4j:log4j-core:2.16.0")
library("org.apache.logging.log4j:log4j-core:2.17.0")

testImplementation(project(":instrumentation-appender-sdk-internal"))
testImplementation("io.opentelemetry:opentelemetry-sdk-logs")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ muzzle {
pass {
group.set("org.apache.logging.log4j")
module.set("log4j-core")
versions.set("[2.16.0,)")
versions.set("[2.17.0,)")
assertInverse.set(true)
}
}
Expand All @@ -21,9 +21,9 @@ testSets {
}

dependencies {
library("org.apache.logging.log4j:log4j-core:2.16.0")
library("org.apache.logging.log4j:log4j-core:2.17.0")

implementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-2.16:library-autoconfigure"))
implementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-2.17:library-autoconfigure"))

testInstrumentation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-2.7:javaagent"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
import static java.util.Collections.singletonList;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.not;

import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.HelperResourceBuilder;
Expand All @@ -22,7 +21,7 @@
@AutoService(InstrumentationModule.class)
public class Log4j2InstrumentationModule extends InstrumentationModule {
public Log4j2InstrumentationModule() {
super("log4j-context-data", "log4j-context-data-2.16");
super("log4j-context-data", "log4j-context-data-2.17");
}

@Override
Expand All @@ -33,14 +32,11 @@ public void registerHelperResources(HelperResourceBuilder helperResourceBuilder)

@Override
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
// want to cover 2.16.0+
// - DefaultArbiter introduced in 2.15.0
// - LookupMessagePatternConverter introduced in 2.15.0, removed in 2.16.0
return hasClassesNamed("org.apache.logging.log4j.core.config.arbiters.DefaultArbiter")
.and(
not(
hasClassesNamed(
"org.apache.logging.log4j.core.pattern.MessagePatternConverter$LookupMessagePatternConverter")));
return hasClassesNamed(
// class added in 2.17.0 and backported to 2.12.3
"org.apache.logging.log4j.core.lookup.ConfigurationStrSubstitutor",
// class added in 2.15.0
"org.apache.logging.log4j.core.config.arbiters.DefaultArbiter");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ stable [release](https://search.maven.org/search?q=g:io.opentelemetry.instrument
<dependencies>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-log4j-context-data-2.16-autoconfigure</artifactId>
<artifactId>opentelemetry-log4j-context-data-2.17-autoconfigure</artifactId>
<version>OPENTELEMETRY_VERSION</version>
</dependency>
</dependencies>
Expand All @@ -25,7 +25,7 @@ stable [release](https://search.maven.org/search?q=g:io.opentelemetry.instrument

```kotlin
dependencies {
runtimeOnly("io.opentelemetry.instrumentation:opentelemetry-log4j-context-data-2.16-autoconfigure:OPENTELEMETRY_VERSION")
runtimeOnly("io.opentelemetry.instrumentation:opentelemetry-log4j-context-data-2.17-autoconfigure:OPENTELEMETRY_VERSION")
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
base.archivesName.set("${base.archivesName.get()}-autoconfigure")

dependencies {
library("org.apache.logging.log4j:log4j-core:2.16.0")
library("org.apache.logging.log4j:log4j-core:2.17.0")

testImplementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-2-common:testing"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ muzzle {
pass {
group.set("org.apache.logging.log4j")
module.set("log4j-core")
versions.set("[2.7,2.16.0)")
versions.set("[2.7,2.17.0)")
assertInverse.set(true)
}
}

dependencies {
library("org.apache.logging.log4j:log4j-core:2.7")

testInstrumentation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-2.16:javaagent"))
testInstrumentation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-2.17:javaagent"))

testImplementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-2-common:testing"))

latestDepTestLibrary("org.apache.logging.log4j:log4j-core:2.15.+") // see log4j-context-data-2.16
latestDepTestLibrary("org.apache.logging.log4j:log4j-core:2.16.+") // see log4j-context-data-2.17
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@ public Log4j27InstrumentationModule() {

@Override
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
// want to cover 2.7 through (and including) 2.15.0 (but not including 2.16.0+)
// - ContextDataInjectorFactory introduced in 2.7
// - DefaultArbiter introduced in 2.15.0
// - LookupMessagePatternConverter introduced in 2.15.0, removed in 2.16.0
return hasClassesNamed("org.apache.logging.log4j.core.impl.ContextDataInjectorFactory")
// want to cover 2.7 up to (but not including) 2.17.0
return hasClassesNamed(
// class added in 2.7
"org.apache.logging.log4j.core.impl.ContextDataInjectorFactory")
.and(
not(hasClassesNamed("org.apache.logging.log4j.core.config.arbiters.DefaultArbiter"))
.or(
hasClassesNamed(
"org.apache.logging.log4j.core.pattern.MessagePatternConverter$LookupMessagePatternConverter")));
not(
hasClassesNamed(
// class added in 2.17.0 and backported to 2.12.3
"org.apache.logging.log4j.core.lookup.ConfigurationStrSubstitutor",
// class added in 2.15.0
"org.apache.logging.log4j.core.config.arbiters.DefaultArbiter")));
}

@Override
Expand Down
8 changes: 4 additions & 4 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ include(":instrumentation:liberty:liberty-dispatcher:javaagent")
include(":instrumentation:log4j:log4j-appender-1.2:javaagent")
include(":instrumentation:log4j:log4j-mdc-1.2:javaagent")
include(":instrumentation:log4j:log4j-context-data:log4j-context-data-2.7:javaagent")
include(":instrumentation:log4j:log4j-context-data:log4j-context-data-2.16:javaagent")
include(":instrumentation:log4j:log4j-context-data:log4j-context-data-2.16:library-autoconfigure")
include(":instrumentation:log4j:log4j-context-data:log4j-context-data-2.17:javaagent")
include(":instrumentation:log4j:log4j-context-data:log4j-context-data-2.17:library-autoconfigure")
include(":instrumentation:log4j:log4j-context-data:log4j-context-data-2-common:testing")
include(":instrumentation:log4j:log4j-appender-2.16:javaagent")
include(":instrumentation:log4j:log4j-appender-2.16:library")
include(":instrumentation:log4j:log4j-appender-2.17:javaagent")
include(":instrumentation:log4j:log4j-appender-2.17:library")
include(":instrumentation:logback:logback-appender-1.0:javaagent")
include(":instrumentation:logback:logback-appender-1.0:library")
include(":instrumentation:logback:logback-mdc-1.0:javaagent")
Expand Down

0 comments on commit 8506169

Please sign in to comment.