11import com.google.common.util.concurrent.MoreExecutors
22import datadog.trace.agent.test.naming.VersionedNamingTestBase
3- import datadog.trace.api.DDSpanTypes
43import datadog.trace.bootstrap.debugger.DebuggerContext
5- import datadog.trace.bootstrap.instrumentation.api.Tags
64import example.GreeterGrpc
75import example.Helloworld
86import io.grpc.BindableService
@@ -17,6 +15,8 @@ import java.util.concurrent.Executors
1715import java.util.concurrent.TimeUnit
1816import java.util.concurrent.atomic.AtomicReference
1917
18+ import static datadog.trace.agent.test.asserts.TagsAssert.assertTags
19+
2020
2121abstract class GrpcCodeOriginTest extends VersionedNamingTestBase {
2222 @Override
@@ -51,7 +51,7 @@ abstract class GrpcCodeOriginTest extends VersionedNamingTestBase {
5151 codeOriginSetup()
5252 }
5353
54- def " test conversation #name" () {
54+ def " code origin test #name" () {
5555 setup :
5656
5757 def msgCount = serverMessageCount
@@ -151,75 +151,12 @@ abstract class GrpcCodeOriginTest extends VersionedNamingTestBase {
151151 }. flatten(). sort()
152152
153153 assert DebuggerContext . codeOriginRecorder != null
154- assertTraces(2 ) {
155- trace((hasClientMessageSpans() ? clientMessageCount * serverMessageCount : 0 ) + 1 ) {
156- span {
157- operationName clientOperation()
158- resourceName " example.Greeter/Conversation"
159- spanType DDSpanTypes . RPC
160- parent()
161- errored false
162- tags {
163- " $Tags . COMPONENT " " grpc-client"
164- " $Tags . SPAN_KIND " Tags . SPAN_KIND_CLIENT
165- " $Tags . RPC_SERVICE " " example.Greeter"
166- " status.code" " OK"
167- " request.type" " example.Helloworld\$ Response"
168- " response.type" " example.Helloworld\$ Response"
169- peerServiceFrom(Tags . RPC_SERVICE )
170- defaultTags()
171- }
172- }
173- if (hasClientMessageSpans()) {
174- (1 .. (clientMessageCount * serverMessageCount)). each {
175- span {
176- operationName " grpc.message"
177- resourceName " grpc.message"
178- spanType DDSpanTypes . RPC
179- childOf span(0 )
180- errored false
181- tags {
182- " $Tags . COMPONENT " " grpc-client"
183- " $Tags . SPAN_KIND " Tags . SPAN_KIND_CLIENT
184- " message.type" " example.Helloworld\$ Response"
185- defaultTagsNoPeerService()
186- }
187- }
188- }
189- }
190- }
191- trace(clientMessageCount + 1 ) {
192- span {
193- operationName serverOperation()
194- resourceName " example.Greeter/Conversation"
195- spanType DDSpanTypes . RPC
196- childOf trace(0 ). get(0 )
197- errored false
198- tags {
199- " $Tags . COMPONENT " " grpc-server"
200- " $Tags . SPAN_KIND " Tags . SPAN_KIND_SERVER
201- " status.code" " OK"
202-
203- defaultTags(true )
204- }
205- }
206- clientRange. each {
207- span {
208- operationName " grpc.message"
209- resourceName " grpc.message"
210- spanType DDSpanTypes . RPC
211- childOf span(0 )
212- errored false
213- tags {
214- " $Tags . COMPONENT " " grpc-server"
215- " $Tags . SPAN_KIND " Tags . SPAN_KIND_SERVER
216- " message.type" " example.Helloworld\$ Response"
217- defaultTags()
218- }
219- }
220- }
221- }
154+ def span = TEST_WRITER . flatten(). find {
155+ it. operationName. toString() == " grpc.server.request"
222156 }
157+ assertTags(span, {
158+ it. codeOriginTags()
159+ }, false )
223160
224161 cleanup :
225162 channel?. shutdownNow()?. awaitTermination(10 , TimeUnit . SECONDS )
0 commit comments