-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apply configured service name mapping to DBM-injected
dddbs
(#7064)
* apply configured service name mapping to DBM-injected dddbs * fix nullref that broke some tests * add test * simplify test * clean conf after tests * make DBM test a forked test * apply suggestions
- Loading branch information
Showing
5 changed files
with
85 additions
and
12 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
50 changes: 50 additions & 0 deletions
50
dd-java-agent/instrumentation/jdbc/src/test/groovy/DBMInjectionForkedTest.groovy
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,50 @@ | ||
import datadog.trace.agent.test.AgentTestRunner | ||
import datadog.trace.api.config.TraceInstrumentationConfig | ||
import datadog.trace.api.config.TracerConfig | ||
import test.TestConnection | ||
import test.TestPreparedStatement | ||
import test.TestStatement | ||
|
||
class DBMInjectionForkedTest extends AgentTestRunner { | ||
|
||
@Override | ||
void configurePreAgent() { | ||
super.configurePreAgent() | ||
|
||
injectSysConfig(TraceInstrumentationConfig.DB_DBM_PROPAGATION_MODE_MODE, "full") | ||
// to check that we use the remapped service name in dddbs | ||
injectSysConfig("service.name", "my_service_name") | ||
injectSysConfig(TracerConfig.SERVICE_MAPPING, "testdb:remapped_testdb") | ||
injectSysConfig("dd.trace.jdbc.prepared.statement.class.name", "test.TestPreparedStatement") | ||
injectSysConfig("dd.trace.jdbc.connection.class.name", "test.TestConnection") | ||
} | ||
|
||
static query = "SELECT 1" | ||
static serviceInjection = "ddps='my_service_name',dddbs='remapped_testdb'" | ||
static fullInjection = serviceInjection + ",traceparent='00-00000000000000000000000000000004-0000000000000003-01'" | ||
|
||
def "prepared stmt"() { | ||
setup: | ||
def connection = new TestConnection(false) | ||
|
||
when: | ||
def statement = connection.prepareStatement(query) as TestPreparedStatement | ||
statement.execute() | ||
|
||
then: | ||
// even in full propagation mode, we cannot inject trace info in prepared statements | ||
assert statement.sql == "/*${serviceInjection}*/ ${query}" | ||
} | ||
|
||
def "single query"() { | ||
setup: | ||
def connection = new TestConnection(false) | ||
|
||
when: | ||
def statement = connection.createStatement() as TestStatement | ||
statement.executeQuery(query) | ||
|
||
then: | ||
assert statement.sql == "/*${fullInjection}*/ ${query}" | ||
} | ||
} |
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
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