-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1783 from newrelic/bug-grpc-duplicate-headers
Prevent duplicate DT headers for grpc
- Loading branch information
Showing
14 changed files
with
323 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
instrumentation/grpc-1.22.0/src/test/java/GrpcDistributedTracingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import app.TestClient; | ||
import app.TestServer; | ||
import com.newrelic.agent.introspec.InstrumentationTestConfig; | ||
import com.newrelic.agent.introspec.InstrumentationTestRunner; | ||
import com.newrelic.agent.introspec.Introspector; | ||
import com.newrelic.agent.introspec.TransactionEvent; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.util.Collection; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
@RunWith(InstrumentationTestRunner.class) | ||
@InstrumentationTestConfig(includePrefixes = { "io.grpc", "com.nr.agent.instrumentation.grpc" }, configName="enable_dist_tracing.yml") | ||
public class GrpcDistributedTracingTest { | ||
|
||
private static TestServer server; | ||
private static TestClient client; | ||
|
||
@BeforeClass | ||
public static void before() throws Exception { | ||
server = new TestServer(); | ||
server.start(); | ||
client = new TestClient("localhost", server.getPort()); | ||
} | ||
|
||
@AfterClass | ||
public static void after() throws InterruptedException { | ||
if (client != null) { | ||
client.shutdown(); | ||
} | ||
if (server != null) { | ||
server.stop(); | ||
} | ||
} | ||
|
||
@Test | ||
public void testDTAsyncRequest() { | ||
client.helloAsync("Async"); | ||
|
||
String clientTxName = "OtherTransaction/Custom/app.TestClient/helloAsync"; | ||
String serverTxName = "WebTransaction/gRPC/helloworld.Greeter/SayHello"; | ||
|
||
Introspector introspector = InstrumentationTestRunner.getIntrospector(); | ||
|
||
assertEquals(2, introspector.getFinishedTransactionCount(30000)); | ||
|
||
Collection<TransactionEvent> clientTxns = introspector.getTransactionEvents(clientTxName); | ||
assertEquals(1, clientTxns.size()); | ||
String clientGuid = ""; | ||
String clientTripId = ""; | ||
for (TransactionEvent txn: clientTxns) { | ||
//make other assertions? | ||
clientGuid = txn.getMyGuid(); | ||
clientTripId = txn.getTripId(); | ||
} | ||
|
||
Collection<TransactionEvent> serverTxns = introspector.getTransactionEvents(serverTxName); | ||
assertEquals(1, serverTxns.size()); | ||
for (TransactionEvent txn: serverTxns) { | ||
assertEquals(clientGuid, txn.getParentId()); | ||
assertEquals(clientTripId, txn.getTripId()); | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
instrumentation/grpc-1.22.0/src/test/resources/enable_dist_tracing.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
common: &default_settings | ||
distributed_tracing: | ||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
instrumentation/grpc-1.30.0/src/test/java/GrpcDistributedTracingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import app.TestClient; | ||
import app.TestServer; | ||
import com.newrelic.agent.introspec.InstrumentationTestConfig; | ||
import com.newrelic.agent.introspec.InstrumentationTestRunner; | ||
import com.newrelic.agent.introspec.Introspector; | ||
import com.newrelic.agent.introspec.TransactionEvent; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.util.Collection; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
@RunWith(InstrumentationTestRunner.class) | ||
@InstrumentationTestConfig(includePrefixes = { "io.grpc", "com.nr.agent.instrumentation.grpc" }, configName="enable_dist_tracing.yml") | ||
public class GrpcDistributedTracingTest { | ||
|
||
private static TestServer server; | ||
private static TestClient client; | ||
|
||
@BeforeClass | ||
public static void before() throws Exception { | ||
server = new TestServer(); | ||
server.start(); | ||
client = new TestClient("localhost", server.getPort()); | ||
} | ||
|
||
@AfterClass | ||
public static void after() throws InterruptedException { | ||
if (client != null) { | ||
client.shutdown(); | ||
} | ||
if (server != null) { | ||
server.stop(); | ||
} | ||
} | ||
|
||
@Test | ||
public void testDTAsyncRequest() { | ||
client.helloAsync("Async"); | ||
|
||
String clientTxName = "OtherTransaction/Custom/app.TestClient/helloAsync"; | ||
String serverTxName = "WebTransaction/gRPC/helloworld.Greeter/SayHello"; | ||
|
||
Introspector introspector = InstrumentationTestRunner.getIntrospector(); | ||
|
||
assertEquals(2, introspector.getFinishedTransactionCount(30000)); | ||
|
||
Collection<TransactionEvent> clientTxns = introspector.getTransactionEvents(clientTxName); | ||
assertEquals(1, clientTxns.size()); | ||
String clientGuid = ""; | ||
String clientTripId = ""; | ||
for (TransactionEvent txn: clientTxns) { | ||
clientGuid = txn.getMyGuid(); | ||
clientTripId = txn.getTripId(); | ||
} | ||
|
||
Collection<TransactionEvent> serverTxns = introspector.getTransactionEvents(serverTxName); | ||
assertEquals(1, serverTxns.size()); | ||
for (TransactionEvent txn: serverTxns) { | ||
assertEquals(clientGuid, txn.getParentId()); | ||
assertEquals(clientTripId, txn.getTripId()); | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
instrumentation/grpc-1.30.0/src/test/resources/enable_dist_tracing.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
common: &default_settings | ||
distributed_tracing: | ||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
instrumentation/grpc-1.4.0/src/test/java/GrpcDistributedTracingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import app.TestClient; | ||
import app.TestServer; | ||
import com.newrelic.agent.introspec.InstrumentationTestConfig; | ||
import com.newrelic.agent.introspec.InstrumentationTestRunner; | ||
import com.newrelic.agent.introspec.Introspector; | ||
import com.newrelic.agent.introspec.TransactionEvent; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.util.Collection; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
@RunWith(InstrumentationTestRunner.class) | ||
@InstrumentationTestConfig(includePrefixes = { "io.grpc", "com.nr.agent.instrumentation.grpc" }, configName="enable_dist_tracing.yml") | ||
public class GrpcDistributedTracingTest { | ||
|
||
private static TestServer server; | ||
private static TestClient client; | ||
|
||
@BeforeClass | ||
public static void before() throws Exception { | ||
server = new TestServer(); | ||
server.start(); | ||
client = new TestClient("localhost", server.getPort()); | ||
} | ||
|
||
@AfterClass | ||
public static void after() throws InterruptedException { | ||
if (client != null) { | ||
client.shutdown(); | ||
} | ||
if (server != null) { | ||
server.stop(); | ||
} | ||
} | ||
|
||
@Test | ||
public void testDTAsyncRequest() { | ||
client.helloAsync("Async"); | ||
|
||
String clientTxName = "OtherTransaction/Custom/app.TestClient/helloAsync"; | ||
String serverTxName = "WebTransaction/gRPC/helloworld.Greeter/SayHello"; | ||
|
||
Introspector introspector = InstrumentationTestRunner.getIntrospector(); | ||
|
||
assertEquals(2, introspector.getFinishedTransactionCount(30000)); | ||
|
||
Collection<TransactionEvent> clientTxns = introspector.getTransactionEvents(clientTxName); | ||
assertEquals(1, clientTxns.size()); | ||
String clientGuid = ""; | ||
String clientTripId = ""; | ||
for (TransactionEvent txn: clientTxns) { | ||
//make other assertions? | ||
clientGuid = txn.getMyGuid(); | ||
clientTripId = txn.getTripId(); | ||
} | ||
|
||
Collection<TransactionEvent> serverTxns = introspector.getTransactionEvents(serverTxName); | ||
assertEquals(1, serverTxns.size()); | ||
for (TransactionEvent txn: serverTxns) { | ||
assertEquals(clientGuid, txn.getParentId()); | ||
assertEquals(clientTripId, txn.getTripId()); | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
instrumentation/grpc-1.4.0/src/test/resources/enable_dist_tracing.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
common: &default_settings | ||
distributed_tracing: | ||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
instrumentation/grpc-1.40.0/src/test/java/GrpcDistributedTracingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
|
||
import app.TestClient; | ||
import app.TestServer; | ||
import com.newrelic.agent.introspec.*; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.util.Collection; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
@RunWith(InstrumentationTestRunner.class) | ||
@InstrumentationTestConfig(includePrefixes = { "io.grpc", "com.nr.agent.instrumentation.grpc" }, configName="enable_dist_tracing.yml") | ||
public class GrpcDistributedTracingTest { | ||
|
||
private static TestServer server; | ||
private static TestClient client; | ||
|
||
@BeforeClass | ||
public static void before() throws Exception { | ||
server = new TestServer(); | ||
server.start(); | ||
client = new TestClient("localhost", server.getPort()); | ||
} | ||
|
||
@AfterClass | ||
public static void after() throws InterruptedException { | ||
if (client != null) { | ||
client.shutdown(); | ||
} | ||
if (server != null) { | ||
server.stop(); | ||
} | ||
} | ||
|
||
@Test | ||
public void testDTAsyncRequest() { | ||
client.helloAsync("Async"); | ||
|
||
String clientTxName = "OtherTransaction/Custom/app.TestClient/helloAsync"; | ||
String serverTxName = "WebTransaction/gRPC/helloworld.Greeter/SayHello"; | ||
|
||
Introspector introspector = InstrumentationTestRunner.getIntrospector(); | ||
|
||
assertEquals(2, introspector.getFinishedTransactionCount(30000)); | ||
|
||
Collection<TransactionEvent> clientTxns = introspector.getTransactionEvents(clientTxName); | ||
assertEquals(1, clientTxns.size()); | ||
String clientGuid = ""; | ||
String clientTripId = ""; | ||
for (TransactionEvent txn: clientTxns) { | ||
//make other assertions? | ||
clientGuid = txn.getMyGuid(); | ||
clientTripId = txn.getTripId(); | ||
} | ||
|
||
Collection<TransactionEvent> serverTxns = introspector.getTransactionEvents(serverTxName); | ||
assertEquals(1, serverTxns.size()); | ||
for (TransactionEvent txn: serverTxns) { | ||
assertEquals(clientGuid, txn.getParentId()); | ||
assertEquals(clientTripId, txn.getTripId()); | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
instrumentation/grpc-1.40.0/src/test/resources/enable_dist_tracing.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
common: &default_settings | ||
distributed_tracing: | ||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters