20
20
import datadog .trace .bootstrap .instrumentation .jdbc .DBInfo ;
21
21
import datadog .trace .bootstrap .instrumentation .jdbc .DBQueryInfo ;
22
22
import datadog .trace .bootstrap .instrumentation .jdbc .JDBCConnectionUrlParser ;
23
- import edu .umd .cs .findbugs .annotations .SuppressFBWarnings ;
24
23
import java .nio .ByteBuffer ;
25
24
import java .nio .ByteOrder ;
26
25
import java .sql .Connection ;
30
29
import java .sql .Statement ;
31
30
import java .util .HashSet ;
32
31
import java .util .Set ;
33
- import java .util .regex .Pattern ;
34
32
import org .slf4j .Logger ;
35
33
import org .slf4j .LoggerFactory ;
36
34
@@ -50,8 +48,6 @@ public class JDBCDecorator extends DatabaseClientDecorator<DBInfo> {
50
48
SpanNaming .instance ().namingSchema ().database ().service ("jdbc" );
51
49
public static final String DBM_PROPAGATION_MODE_STATIC = "service" ;
52
50
public static final String DBM_PROPAGATION_MODE_FULL = "full" ;
53
- private static final Pattern traceParentPattern =
54
- Pattern .compile ("^00-[a-f0-9]{32}-[a-f0-9]{16}-[a-f0-9]{2}$" );
55
51
56
52
public static final String DBM_PROPAGATION_MODE = Config .get ().getDBMPropagationMode ();
57
53
public static final boolean INJECT_COMMENT =
@@ -333,9 +329,6 @@ public long setContextInfo(Connection connection, DBInfo dbInfo) {
333
329
* @param span The span of the instrumented statement
334
330
* @param connection The same connection as the one that will be used for the actual statement
335
331
*/
336
- @ SuppressFBWarnings (
337
- value = "SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE" ,
338
- justification = "Prepared statement not possible with SET" )
339
332
public void setApplicationName (AgentSpan span , Connection connection ) {
340
333
final long startTime = System .currentTimeMillis ();
341
334
try {
@@ -345,15 +338,9 @@ public void setApplicationName(AgentSpan span, Connection connection) {
345
338
return ;
346
339
}
347
340
final String traceParent = DECORATE .traceParent (span , priority );
348
- if (traceParent == null || !traceParentPattern .matcher (traceParent ).matches ()) {
349
- throw new IllegalArgumentException ("Invalid trace parent: " + traceParent );
350
- }
351
341
final String traceContext = "_DD_" + traceParent ;
352
342
353
- // SET doesn't work with parameters
354
- try (Statement statement = connection .createStatement ()) {
355
- statement .execute ("SET application_name = '" + traceContext + "';" );
356
- }
343
+ connection .setClientInfo ("ApplicationName" , traceContext );
357
344
} catch (Throwable e ) {
358
345
if (log .isDebugEnabled ()) {
359
346
log .debug (
0 commit comments