build.gradle.kts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. plugins {
  2. id("otel.javaagent-instrumentation")
  3. }
  4. muzzle {
  5. pass {
  6. group.set("org.apache.logging.log4j")
  7. module.set("log4j-core")
  8. versions.set("[2.17.0,)")
  9. assertInverse.set(true)
  10. }
  11. }
  12. dependencies {
  13. library("org.apache.logging.log4j:log4j-core:2.17.0")
  14. implementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-2.17:library-autoconfigure"))
  15. testInstrumentation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-2.7:javaagent"))
  16. testImplementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing"))
  17. }
  18. testing {
  19. suites {
  20. // Very different codepaths when threadlocals are enabled or not so we check both.
  21. // Regression test for https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/2403
  22. val testDisableThreadLocals by registering(JvmTestSuite::class) {
  23. sources {
  24. groovy {
  25. setSrcDirs(listOf("src/test/groovy"))
  26. }
  27. }
  28. dependencies {
  29. implementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing"))
  30. }
  31. targets {
  32. all {
  33. testTask.configure {
  34. jvmArgs("-Dlog4j2.is.webapp=false")
  35. jvmArgs("-Dlog4j2.enable.threadlocals=false")
  36. jvmArgs("-Dotel.instrumentation.common.mdc.resource-attributes=service.name,telemetry.sdk.language")
  37. }
  38. }
  39. }
  40. }
  41. val testAddBaggage by registering(JvmTestSuite::class) {
  42. sources {
  43. groovy {
  44. setSrcDirs(listOf("src/testAddBaggage/groovy"))
  45. }
  46. }
  47. dependencies {
  48. implementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing"))
  49. }
  50. targets {
  51. all {
  52. testTask.configure {
  53. jvmArgs("-Dotel.instrumentation.log4j-context-data.add-baggage=true")
  54. jvmArgs("-Dlog4j2.is.webapp=false")
  55. jvmArgs("-Dlog4j2.enable.threadlocals=true")
  56. }
  57. }
  58. }
  59. }
  60. }
  61. }
  62. tasks {
  63. // Threadlocals are always false if is.webapp is true, so we make sure to override it because as of
  64. // now testing-common includes jetty / servlet.
  65. test {
  66. jvmArgs("-Dlog4j2.is.webapp=false")
  67. jvmArgs("-Dlog4j2.enable.threadlocals=true")
  68. jvmArgs("-Dotel.instrumentation.common.mdc.resource-attributes=service.name,telemetry.sdk.language")
  69. }
  70. named("check") {
  71. dependsOn(testing.suites)
  72. }
  73. }