diff --git a/build-tools-internal/src/main/resources/checkstyle_suppressions.xml b/build-tools-internal/src/main/resources/checkstyle_suppressions.xml
index 98ded638773ce..cb4a58ee453a7 100644
--- a/build-tools-internal/src/main/resources/checkstyle_suppressions.xml
+++ b/build-tools-internal/src/main/resources/checkstyle_suppressions.xml
@@ -13,6 +13,7 @@
+
diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml
index d161da5d92236..374db938143cb 100644
--- a/gradle/verification-metadata.xml
+++ b/gradle/verification-metadata.xml
@@ -707,6 +707,11 @@
+
+
+
+
+
@@ -867,6 +872,11 @@
+
+
+
+
+
@@ -877,11 +887,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1869,6 +1916,11 @@
+
+
+
+
+
@@ -2002,6 +2054,11 @@
+
+
+
+
+
diff --git a/x-pack/plugin/otel-data/build.gradle b/x-pack/plugin/otel-data/build.gradle
index 0ae8022bff617..af0592bca1703 100644
--- a/x-pack/plugin/otel-data/build.gradle
+++ b/x-pack/plugin/otel-data/build.gradle
@@ -4,9 +4,14 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
-apply plugin: 'elasticsearch.internal-es-plugin'
-apply plugin: 'elasticsearch.internal-yaml-rest-test'
-apply plugin: 'elasticsearch.internal-cluster-test'
+import org.elasticsearch.gradle.transform.UnzipTransform
+import com.google.protobuf.gradle.GenerateProtoTask
+plugins {
+ id 'elasticsearch.internal-es-plugin'
+ id 'elasticsearch.internal-yaml-rest-test'
+ id 'elasticsearch.internal-cluster-test'
+ id('com.google.protobuf') version '0.9.5'
+}
esplugin {
name = 'x-pack-otel-data'
@@ -15,7 +20,33 @@ esplugin {
extendedPlugins = ['x-pack-core']
}
+repositories {
+ ivy {
+ url = uri("https://github.com/open-telemetry/opentelemetry-proto/archive/")
+ patternLayout { artifact("v[revision].[ext]") }
+ metadataSources { artifact() }
+ content {
+ includeModule("open-telemetry", "opentelemetry-proto") // only this GAV comes from here
+ }
+ }
+}
+
+configurations {
+ opentelemetryProtobuf {
+ attributes.attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.DIRECTORY_TYPE)
+ canBeConsumed = false
+ }
+}
+
+def protobufVersion = "4.32.0"
+
dependencies {
+ registerTransform(UnzipTransform, transformSpec -> {
+ transformSpec.getFrom().attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.ZIP_TYPE);
+ transformSpec.getTo().attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.DIRECTORY_TYPE);
+ });
+ opentelemetryProtobuf "open-telemetry:opentelemetry-proto:1.7.0@zip"
+
compileOnly project(path: xpackModule('core'))
testImplementation project(path: ':x-pack:plugin:stack')
testImplementation(testArtifact(project(xpackModule('core'))))
@@ -34,4 +65,88 @@ dependencies {
clusterModules project(xpackModule('stack'))
clusterModules project(xpackModule('wildcard'))
clusterModules project(xpackModule('mapper-version'))
+
+ implementation "com.google.protobuf:protobuf-java:${protobufVersion}"
+ // The protobuf plugin only adds a dependency for the variant relevant for the current platform.
+ // Without explicitly adding all classifiers, the --write-verification-metadata task would only add the one for the current platform.
+ // Therefore, the verification check would fail on other platforms, like on CI or for contributors that work on another platform.
+ testRuntimeOnly "com.google.protobuf:protoc:${protobufVersion}:linux-aarch_64@exe"
+ testRuntimeOnly "com.google.protobuf:protoc:${protobufVersion}:linux-ppcle_64@exe"
+ testRuntimeOnly "com.google.protobuf:protoc:${protobufVersion}:linux-s390_64@exe"
+ testRuntimeOnly "com.google.protobuf:protoc:${protobufVersion}:linux-x86_32@exe"
+ testRuntimeOnly "com.google.protobuf:protoc:${protobufVersion}:linux-x86_64@exe"
+ testRuntimeOnly "com.google.protobuf:protoc:${protobufVersion}:osx-aarch_64@exe"
+ testRuntimeOnly "com.google.protobuf:protoc:${protobufVersion}:osx-universal_binary@exe"
+ testRuntimeOnly "com.google.protobuf:protoc:${protobufVersion}:osx-x86_64@exe"
+ testRuntimeOnly "com.google.protobuf:protoc:${protobufVersion}:windows-x86_32@exe"
+ testRuntimeOnly "com.google.protobuf:protoc:${protobufVersion}:windows-x86_64@exe"
+}
+
+protobuf {
+ protoc {
+ // The artifact spec for the Protobuf Compiler
+ artifact = "com.google.protobuf:protoc:${protobufVersion}"
+ }
+}
+
+def extractOtelProtos = tasks.register("extractOtelProtos", Copy) {
+ from(configurations.opentelemetryProtobuf) {
+ include "**/*.proto"
+ eachFile { fileCopyDetails ->
+ // strip the leading directory (opentelemetry-proto-)
+ def segments = fileCopyDetails.path.split('/')
+ fileCopyDetails.path = segments.length > 1 ? segments[1..-1].join('/') : fileCopyDetails.name
+ }
+ includeEmptyDirs = false
+ }
+ into(layout.buildDirectory.dir("protos/otel"))
+}
+
+
+sourceSets {
+ main {
+ proto {
+ srcDir(extractOtelProtos)
+ }
+ }
+}
+
+tasks.withType(GenerateProtoTask.class).matching { it.name == "generateProto" }.configureEach {
+ // Avoid unnecessary String allocations in the generated AnyValue class
+ // We always need the ByteString (UTF-8) representation of string attributes
+ doLast {
+ ant.replace(
+ file: 'build/generated/sources/proto/main/java/io/opentelemetry/proto/common/v1/AnyValue.java',
+ token: 'java.lang.String s = input.readStringRequireUtf8();',
+ value: 'com.google.protobuf.ByteString s = input.readBytes();',
+ encoding: 'UTF-8'
+ )
+ }
+}
+
+idea {
+ module {
+ sourceDirs += layout.buildDirectory.dir("generated/sources/proto/main/java").get().asFile
+ }
+}
+
+tasks.named("dependencyLicenses").configure {
+ mapping from: /protobuf.*/, to: 'protobuf'
+}
+
+tasks.named("thirdPartyAudit").configure {
+ ignoreViolations(
+ // uses internal java api: sun.misc.Unsafe
+ 'com.google.protobuf.MessageSchema',
+ 'com.google.protobuf.UnsafeUtil',
+ 'com.google.protobuf.UnsafeUtil$1',
+ 'com.google.protobuf.UnsafeUtil$Android32MemoryAccessor',
+ 'com.google.protobuf.UnsafeUtil$Android64MemoryAccessor',
+ 'com.google.protobuf.UnsafeUtil$JvmMemoryAccessor',
+ 'com.google.protobuf.UnsafeUtil$MemoryAccessor'
+ )
+}
+
+tasks.named("licenseHeaders").configure {
+ excludes << 'io/opentelemetry/proto/**/*'
}
diff --git a/x-pack/plugin/otel-data/licenses/protobuf-LICENSE.txt b/x-pack/plugin/otel-data/licenses/protobuf-LICENSE.txt
new file mode 100644
index 0000000000000..19b305b00060a
--- /dev/null
+++ b/x-pack/plugin/otel-data/licenses/protobuf-LICENSE.txt
@@ -0,0 +1,32 @@
+Copyright 2008 Google Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Code generated by the Protocol Buffer compiler is owned by the owner
+of the input file used when generating it. This code is not
+standalone and requires a support library to be linked with it. This
+support library is itself covered by the above license.
diff --git a/x-pack/plugin/otel-data/licenses/protobuf-NOTICE.txt b/x-pack/plugin/otel-data/licenses/protobuf-NOTICE.txt
new file mode 100644
index 0000000000000..19b305b00060a
--- /dev/null
+++ b/x-pack/plugin/otel-data/licenses/protobuf-NOTICE.txt
@@ -0,0 +1,32 @@
+Copyright 2008 Google Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Code generated by the Protocol Buffer compiler is owned by the owner
+of the input file used when generating it. This code is not
+standalone and requires a support library to be linked with it. This
+support library is itself covered by the above license.