You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by mj...@apache.org on 2023/11/02 04:53:31 UTC
(kafka) branch trunk updated: KAFKA-15668: Adding Opentelmetry shadowed library (KIP-714) (#14618)
This is an automated email from the ASF dual-hosted git repository.
mjsax pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new b850b46cf99 KAFKA-15668: Adding Opentelmetry shadowed library (KIP-714) (#14618)
b850b46cf99 is described below
commit b850b46cf9963d1d5c707a397bf2171c648ecab8
Author: Apoorv Mittal <am...@confluent.io>
AuthorDate: Thu Nov 2 04:53:24 2023 +0000
KAFKA-15668: Adding Opentelmetry shadowed library (KIP-714) (#14618)
Part of KIP-714.
The PR comprises of changes to include opentlemetry library as defined in KIP-714. The libraries are shadowed to prevent conflicts.
Co-authored-by: Xavier Léauté <xl...@xvrl.net>
Reviewers: Andrew Schofield <as...@confluent.io>, Xavier Léauté <xa...@confluent.io>, Walker Carlson <wc...@confluent.io>, Matthias J. Sax <ma...@confluent.io>
---
build.gradle | 48 +++++++++++++++++++++++++++++++++++++++++++---
gradle/dependencies.gradle | 2 ++
2 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/build.gradle b/build.gradle
index fbda13d5a79..065388199cb 100644
--- a/build.gradle
+++ b/build.gradle
@@ -232,6 +232,7 @@ subprojects {
// We use the shadow plugin for the jmh-benchmarks module and the `-all` jar can get pretty large, so
// don't publish it
def shouldPublish = !project.name.equals('jmh-benchmarks')
+ def shouldPublishWithShadow = (['clients'].contains(project.name))
if (shouldPublish) {
apply plugin: 'maven-publish'
@@ -295,7 +296,12 @@ subprojects {
}
publications {
mavenJava(MavenPublication) {
- from components.java
+ if (!shouldPublishWithShadow) {
+ from components.java
+ } else {
+ apply plugin: 'com.github.johnrengelman.shadow'
+ project.shadow.component(mavenJava)
+ }
afterEvaluate {
["srcJar", "javadocJar", "scaladocJar", "testJar", "testSrcJar"].forEach { taskName ->
@@ -1342,6 +1348,13 @@ project(':clients') {
implementation libs.lz4
implementation libs.snappy
implementation libs.slf4jApi
+ implementation libs.opentelemetryProto
+
+ // libraries which should be added as runtime dependencies in generated pom.xml should be defined here:
+ shadow libs.zstd
+ shadow libs.lz4
+ shadow libs.snappy
+ shadow libs.slf4jApi
compileOnly libs.jacksonDatabind // for SASL/OAUTHBEARER bearer token parsing
compileOnly libs.jacksonJDK8Datatypes
@@ -1379,11 +1392,40 @@ project(':clients') {
}
}
- jar {
+ shadowJar {
dependsOn createVersionFile
+ // archiveClassifier defines the classifier for the shadow jar, the default is 'all'.
+ // We don't want to use the default classifier because it will cause the shadow jar to
+ // overwrite the original jar. We also don't want to use the 'shadow' classifier because
+ // it will cause the shadow jar to be named kafka-clients-shadow.jar. We want to use the
+ // same name as the original jar, kafka-clients.jar.
+ archiveClassifier = null
+ // KIP-714: move shaded dependencies to a shaded location
+ relocate('io.opentelemetry.proto', 'org.apache.kafka.shaded.io.opentelemetry.proto')
+ relocate('com.google.protobuf', 'org.apache.kafka.shaded.com.google.protobuf')
+
+ // dependencies excluded from the final jar, since they are declared as runtime dependencies
+ dependencies {
+ exclude(dependency(libs.snappy))
+ exclude(dependency(libs.zstd))
+ exclude(dependency(libs.lz4))
+ exclude(dependency(libs.slf4jApi))
+ // exclude proto files from the jar
+ exclude "**/opentelemetry/proto/**/*.proto"
+ exclude "**/google/protobuf/*.proto"
+ }
+
from("$buildDir") {
- include "kafka/$buildVersionFileName"
+ include "kafka/$buildVersionFileName"
}
+
+ from "$rootDir/LICENSE"
+ from "$rootDir/NOTICE"
+ }
+
+ jar {
+ enabled false
+ dependsOn 'shadowJar'
}
clean.doFirst {
diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle
index 22d073341ac..5bd39cc9cf5 100644
--- a/gradle/dependencies.gradle
+++ b/gradle/dependencies.gradle
@@ -147,6 +147,7 @@ versions += [
mavenArtifact: "3.8.8",
metrics: "2.2.0",
netty: "4.1.100.Final",
+ opentelemetryProto: "1.0.0-alpha",
pcollections: "4.0.1",
powermock: "2.0.9",
reflections: "0.10.2",
@@ -242,6 +243,7 @@ libs += [
nettyHandler: "io.netty:netty-handler:$versions.netty",
nettyTransportNativeEpoll: "io.netty:netty-transport-native-epoll:$versions.netty",
pcollections: "org.pcollections:pcollections:$versions.pcollections",
+ opentelemetryProto: "io.opentelemetry.proto:opentelemetry-proto:$versions.opentelemetryProto",
powermockJunit4: "org.powermock:powermock-module-junit4:$versions.powermock",
powermockEasymock: "org.powermock:powermock-api-easymock:$versions.powermock",
reflections: "org.reflections:reflections:$versions.reflections",