Skip to content

Commit d5a2503

Browse files
authored
Use OpenTelemetry with HTTP/gRPC exporters in apm-integration (#80762)
This pull request adds support for HTPP/gRPC with the OpenTelemetry SDK in the `apm-integration` plugin. It adds the required security permissions to the plugin to make it work - we should try to reduce this list one day. The plumbing to pass Elastic's Cloud APM server credentials is not fully there yet but the current `ApmIT` test can be executed with `-Dtests.apm.endpoint=https://... -Dtests.apm.token=ABC` and traces should be sent to Elastic APM. _Works on my machine™_
1 parent 13eddb9 commit d5a2503

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+512
-210
lines changed

x-pack/plugin/apm-integration/build.gradle

Lines changed: 150 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,34 @@ dependencies {
2525
implementation "io.opentelemetry:opentelemetry-sdk-metrics:${versions.opentelemetry}-alpha"
2626
implementation "io.opentelemetry:opentelemetry-semconv:${versions.opentelemetry}-alpha"
2727
implementation "io.opentelemetry:opentelemetry-exporter-logging:${versions.opentelemetry}"
28+
// required to use OTLP (to get OtlpGrpcSpanExporter)
29+
implementation "io.opentelemetry:opentelemetry-exporter-otlp-trace:${versions.opentelemetry}"
30+
// required by OTLP (to get GrpcExporter, Marshaller etc)
31+
implementation "io.opentelemetry:opentelemetry-exporter-otlp-common:${versions.opentelemetry}"
32+
// required by OTLP common & trace
33+
implementation "io.grpc:grpc-api:1.42.1"
34+
implementation "io.grpc:grpc-stub:1.42.1"
35+
implementation "io.grpc:grpc-core:1.42.1"
36+
implementation "io.grpc:grpc-context:1.42.1"
37+
// netty HTTP client is used for gRPC calls to Elastic's APM server
38+
implementation "io.grpc:grpc-netty:1.42.1"
39+
// okio and okhttp are required by GrpcExporter as the default implementation, but we don't use it
40+
implementation "com.squareup.okhttp3:okhttp:3.14.9"
41+
implementation "com.squareup.okio:okio:1.17.2"
42+
// required by io.grpc
43+
implementation 'io.perfmark:perfmark-api:0.24.0'
44+
implementation 'io.perfmark:perfmark-impl:0.24.0'
45+
implementation 'com.google.guava:failureaccess:1.0.1'
46+
// required by grpc-netty
47+
api "io.netty:netty-buffer:${versions.netty}"
48+
api "io.netty:netty-transport:${versions.netty}"
49+
api "io.netty:netty-common:${versions.netty}"
50+
api "io.netty:netty-codec:${versions.netty}"
51+
api "io.netty:netty-codec-http:${versions.netty}"
52+
api "io.netty:netty-codec-http2:${versions.netty}"
53+
api "io.netty:netty-handler:${versions.netty}"
54+
api "io.netty:netty-resolver:${versions.netty}"
55+
runtimeOnly 'com.google.guava:guava:31.0.1-jre'
2856

2957
compileOnly project(path: xpackModule('core'))
3058
internalClusterTestImplementation(testArtifact(project(xpackModule('core'))))
@@ -33,17 +61,137 @@ dependencies {
3361
// no unit-test for now
3462
tasks.named("test").configure { enabled = false }
3563

64+
tasks.named("dependencyLicenses").configure {
65+
mapping from: /opentelemetry-.*/, to: 'opentelemetry'
66+
mapping from: /grpc-.*/, to: 'grpc'
67+
mapping from: /netty-.*/, to: 'netty'
68+
mapping from: /perfmark-.*/, to: 'perfmark'
69+
}
70+
3671
tasks.named("thirdPartyAudit").configure {
3772
ignoreViolations(
3873
'io.opentelemetry.internal.shaded.jctools.queues.MpscArrayQueueConsumerIndexField',
3974
'io.opentelemetry.internal.shaded.jctools.queues.MpscArrayQueueProducerIndexField',
4075
'io.opentelemetry.internal.shaded.jctools.queues.MpscArrayQueueProducerLimitField',
4176
'io.opentelemetry.internal.shaded.jctools.util.UnsafeAccess',
42-
'io.opentelemetry.internal.shaded.jctools.util.UnsafeRefArrayAccess'
77+
'io.opentelemetry.internal.shaded.jctools.util.UnsafeRefArrayAccess',
78+
'com.google.common.cache.Striped64',
79+
'com.google.common.cache.Striped64$1',
80+
'com.google.common.cache.Striped64$Cell',
81+
'com.google.common.hash.LittleEndianByteArray$UnsafeByteArray',
82+
'com.google.common.hash.LittleEndianByteArray$UnsafeByteArray$1',
83+
'com.google.common.hash.LittleEndianByteArray$UnsafeByteArray$2',
84+
'com.google.common.hash.LittleEndianByteArray$UnsafeByteArray$3',
85+
'com.google.common.hash.Striped64',
86+
'com.google.common.hash.Striped64$1',
87+
'com.google.common.hash.Striped64$Cell',
88+
'com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator',
89+
'com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator$1',
90+
'com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper',
91+
'com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper$1',
92+
'io.netty.handler.ssl.util.OpenJdkSelfSignedCertGenerator',
93+
'io.netty.util.internal.PlatformDependent0',
94+
'io.netty.util.internal.PlatformDependent0$1',
95+
'io.netty.util.internal.PlatformDependent0$2',
96+
'io.netty.util.internal.PlatformDependent0$3',
97+
'io.netty.util.internal.PlatformDependent0$5',
98+
'io.netty.util.internal.shaded.org.jctools.queues.BaseLinkedQueueConsumerNodeRef',
99+
'io.netty.util.internal.shaded.org.jctools.queues.BaseLinkedQueueProducerNodeRef',
100+
'io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueColdProducerFields',
101+
'io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueConsumerFields',
102+
'io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueProducerFields',
103+
'io.netty.util.internal.shaded.org.jctools.queues.LinkedQueueNode',
104+
'io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueueConsumerIndexField',
105+
'io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueueProducerIndexField',
106+
'io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueueProducerLimitField',
107+
'io.netty.util.internal.shaded.org.jctools.util.UnsafeAccess',
108+
'io.netty.util.internal.shaded.org.jctools.util.UnsafeRefArrayAccess'
43109
)
44110
ignoreMissingClasses(
45111
'io.opentelemetry.sdk.logs.data.Body',
46112
'io.opentelemetry.sdk.logs.data.LogData',
47-
'io.opentelemetry.sdk.logs.export.LogExporter'
113+
'io.opentelemetry.sdk.logs.export.LogExporter',
114+
'android.net.ssl.SSLSockets',
115+
'android.os.Build$VERSION',
116+
'android.util.Log',
117+
'com.aayushatharva.brotli4j.Brotli4jLoader',
118+
'com.aayushatharva.brotli4j.decoder.DecoderJNI$Status',
119+
'com.aayushatharva.brotli4j.decoder.DecoderJNI$Wrapper',
120+
'com.aayushatharva.brotli4j.encoder.Encoder',
121+
'com.aayushatharva.brotli4j.encoder.Encoder$Mode',
122+
'com.aayushatharva.brotli4j.encoder.Encoder$Parameters',
123+
'com.github.luben.zstd.Zstd',
124+
'com.google.gson.stream.JsonReader',
125+
'com.google.gson.stream.JsonToken',
126+
'com.google.protobuf.ExtensionRegistry',
127+
'com.google.protobuf.ExtensionRegistryLite',
128+
'com.google.protobuf.MessageLite',
129+
'com.google.protobuf.MessageLite$Builder',
130+
'com.google.protobuf.MessageLiteOrBuilder',
131+
'com.google.protobuf.Parser',
132+
'com.google.protobuf.nano.CodedOutputByteBufferNano',
133+
'com.google.protobuf.nano.MessageNano',
134+
'com.jcraft.jzlib.Deflater',
135+
'com.jcraft.jzlib.Inflater',
136+
'com.jcraft.jzlib.JZlib',
137+
'com.jcraft.jzlib.JZlib$WrapperType',
138+
'com.ning.compress.BufferRecycler',
139+
'com.ning.compress.lzf.ChunkDecoder',
140+
'com.ning.compress.lzf.ChunkEncoder',
141+
'com.ning.compress.lzf.LZFChunk',
142+
'com.ning.compress.lzf.LZFEncoder',
143+
'com.ning.compress.lzf.util.ChunkDecoderFactory',
144+
'com.ning.compress.lzf.util.ChunkEncoderFactory',
145+
'io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts',
146+
'io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder',
147+
'io.grpc.netty.shaded.io.netty.handler.ssl.SslContextBuilder',
148+
'io.grpc.okhttp.OkHttpChannelBuilder',
149+
'io.netty.handler.proxy.HttpProxyHandler',
150+
'io.netty.internal.tcnative.AsyncSSLPrivateKeyMethod',
151+
'io.netty.internal.tcnative.AsyncTask',
152+
'io.netty.internal.tcnative.Buffer',
153+
'io.netty.internal.tcnative.CertificateCallback',
154+
'io.netty.internal.tcnative.CertificateVerifier',
155+
'io.netty.internal.tcnative.Library',
156+
'io.netty.internal.tcnative.ResultCallback',
157+
'io.netty.internal.tcnative.SSL',
158+
'io.netty.internal.tcnative.SSLContext',
159+
'io.netty.internal.tcnative.SSLPrivateKeyMethod',
160+
'io.netty.internal.tcnative.SSLSession',
161+
'io.netty.internal.tcnative.SSLSessionCache',
162+
'io.netty.internal.tcnative.SessionTicketKey',
163+
'io.netty.internal.tcnative.SniHostNameMatcher',
164+
'io.opentelemetry.sdk.logs.data.Severity',
165+
'lzma.sdk.lzma.Encoder',
166+
'org.bouncycastle.asn1.x500.X500Name',
167+
'org.bouncycastle.cert.X509v3CertificateBuilder',
168+
'org.bouncycastle.cert.jcajce.JcaX509CertificateConverter',
169+
'org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder',
170+
'org.bouncycastle.jce.provider.BouncyCastleProvider',
171+
'org.bouncycastle.operator.jcajce.JcaContentSignerBuilder',
172+
'org.conscrypt.AllocatedBuffer',
173+
'org.conscrypt.BufferAllocator',
174+
'org.conscrypt.Conscrypt',
175+
'org.conscrypt.Conscrypt$ProviderBuilder',
176+
'org.conscrypt.HandshakeListener',
177+
'org.eclipse.jetty.alpn.ALPN',
178+
'org.eclipse.jetty.alpn.ALPN$ClientProvider',
179+
'org.eclipse.jetty.alpn.ALPN$ServerProvider',
180+
'org.eclipse.jetty.npn.NextProtoNego',
181+
'org.eclipse.jetty.npn.NextProtoNego$ClientProvider',
182+
'org.eclipse.jetty.npn.NextProtoNego$ServerProvider',
183+
'org.jboss.marshalling.ByteInput',
184+
'org.jboss.marshalling.ByteOutput',
185+
'org.jboss.marshalling.Marshaller',
186+
'org.jboss.marshalling.MarshallerFactory',
187+
'org.jboss.marshalling.MarshallingConfiguration',
188+
'org.jboss.marshalling.Unmarshaller',
189+
'org.slf4j.Logger',
190+
'org.slf4j.LoggerFactory',
191+
'org.slf4j.helpers.FormattingTuple',
192+
'org.slf4j.helpers.MessageFormatter',
193+
'org.slf4j.spi.LocationAwareLogger',
194+
'reactor.blockhound.BlockHound$Builder',
195+
'reactor.blockhound.integration.BlockHoundIntegration'
48196
)
49197
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1dcf1de382a0bf95a3d8b0849546c88bac1292c9

x-pack/plugin/apm-integration/licenses/opentelemetry-sdk-common-LICENSE.txt renamed to x-pack/plugin/apm-integration/licenses/grpc-LICENSE.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
Apache License
23
Version 2.0, January 2004
34
http://www.apache.org/licenses/
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
Copyright 2014 The gRPC Authors
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
15+
-----------------------------------------------------------------------
16+
17+
This product contains a modified portion of 'OkHttp', an open source
18+
HTTP & SPDY client for Android and Java applications, which can be obtained
19+
at:
20+
21+
* LICENSE:
22+
* okhttp/third_party/okhttp/LICENSE (Apache License 2.0)
23+
* HOMEPAGE:
24+
* https://github.com/square/okhttp
25+
* LOCATION_IN_GRPC:
26+
* okhttp/third_party/okhttp
27+
28+
This product contains a modified portion of 'Envoy', an open source
29+
cloud-native high-performance edge/middle/service proxy, which can be
30+
obtained at:
31+
32+
* LICENSE:
33+
* xds/third_party/envoy/LICENSE (Apache License 2.0)
34+
* NOTICE:
35+
* xds/third_party/envoy/NOTICE
36+
* HOMEPAGE:
37+
* https://www.envoyproxy.io
38+
* LOCATION_IN_GRPC:
39+
* xds/third_party/envoy
40+
41+
This product contains a modified portion of 'protoc-gen-validate (PGV)',
42+
an open source protoc plugin to generate polyglot message validators,
43+
which can be obtained at:
44+
45+
* LICENSE:
46+
* xds/third_party/protoc-gen-validate/LICENSE (Apache License 2.0)
47+
* NOTICE:
48+
* xds/third_party/protoc-gen-validate/NOTICE
49+
* HOMEPAGE:
50+
* https://github.com/envoyproxy/protoc-gen-validate
51+
* LOCATION_IN_GRPC:
52+
* xds/third_party/protoc-gen-validate
53+
54+
This product contains a modified portion of 'udpa',
55+
an open source universal data plane API, which can be obtained at:
56+
57+
* LICENSE:
58+
* xds/third_party/udpa/LICENSE (Apache License 2.0)
59+
* HOMEPAGE:
60+
* https://github.com/cncf/udpa
61+
* LOCATION_IN_GRPC:
62+
* xds/third_party/udpa
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4a7f734f57ad5b68e4ac591481eb562cdb3d2a94
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
c0cc9e5e08ced39792908aeda77e694bff39cea1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2d142647452a700189908baa488dc928233e8be9
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
f2bdcaf11b237122efbd8a30e4177250fde5b458

0 commit comments

Comments
 (0)