build.gradle.kts 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. java {
  25. setSrcDirs(listOf("src/test/java"))
  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. dependencies {
  43. implementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing"))
  44. }
  45. targets {
  46. all {
  47. testTask.configure {
  48. jvmArgs("-Dotel.instrumentation.log4j-context-data.add-baggage=true")
  49. jvmArgs("-Dlog4j2.is.webapp=false")
  50. jvmArgs("-Dlog4j2.enable.threadlocals=true")
  51. }
  52. }
  53. }
  54. }
  55. val testLoggingKeys by registering(JvmTestSuite::class) {
  56. dependencies {
  57. implementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing"))
  58. }
  59. targets {
  60. all {
  61. testTask.configure {
  62. jvmArgs("-Dotel.instrumentation.common.logging.trace-id=trace_id_test")
  63. jvmArgs("-Dotel.instrumentation.common.logging.span-id=span_id_test")
  64. jvmArgs("-Dotel.instrumentation.common.logging.trace-flags=trace_flags_test")
  65. jvmArgs("-Dlog4j2.is.webapp=false")
  66. jvmArgs("-Dlog4j2.enable.threadlocals=true")
  67. }
  68. }
  69. }
  70. }
  71. }
  72. }
  73. tasks {
  74. // Threadlocals are always false if is.webapp is true, so we make sure to override it because as of
  75. // now testing-common includes jetty / servlet.
  76. test {
  77. jvmArgs("-Dlog4j2.is.webapp=false")
  78. jvmArgs("-Dlog4j2.enable.threadlocals=true")
  79. jvmArgs("-Dotel.instrumentation.common.mdc.resource-attributes=service.name,telemetry.sdk.language")
  80. }
  81. named("check") {
  82. dependsOn(testing.suites)
  83. }
  84. }