|
19 | 19 | import datadog.trace.bootstrap.instrumentation.jdbc.DBInfo; |
20 | 20 | import datadog.trace.bootstrap.instrumentation.jdbc.DBQueryInfo; |
21 | 21 | import datadog.trace.bootstrap.instrumentation.jdbc.JDBCConnectionUrlParser; |
| 22 | +import java.io.ByteArrayOutputStream; |
22 | 23 | import java.sql.Connection; |
23 | 24 | import java.sql.DatabaseMetaData; |
24 | 25 | import java.sql.PreparedStatement; |
@@ -277,15 +278,16 @@ public long setContextInfo(Connection connection, DBInfo dbInfo) { |
277 | 278 | PreparedStatement instrumentationStatement = null; |
278 | 279 | try (AgentScope scope = activateSpan(instrumentationSpan)) { |
279 | 280 | String samplingDecision = instrumentationSpan.forceSamplingDecision() > 0 ? "1" : "0"; |
280 | | - String contextInfo = |
281 | | - VERSION |
282 | | - + samplingDecision |
283 | | - + DDSpanId.toHexStringPadded(spanID) |
284 | | - + instrumentationSpan.getTraceId().toHexString(); |
| 281 | + |
| 282 | + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| 283 | + outputStream.write(hexStringToByteArray(VERSION + samplingDecision)); |
| 284 | + outputStream.write(hexStringToByteArray(DDSpanId.toHexStringPadded(spanID))); |
| 285 | + outputStream.write(hexStringToByteArray(instrumentationSpan.getTraceId().toHexString())); |
| 286 | + final byte[] contextInfo = outputStream.toByteArray(); |
285 | 287 |
|
286 | 288 | String instrumentationSql = "set context_info ?"; |
287 | 289 | instrumentationStatement = connection.prepareStatement(instrumentationSql); |
288 | | - instrumentationStatement.setBytes(1, hexStringToByteArray(contextInfo)); |
| 290 | + instrumentationStatement.setBytes(1, contextInfo); |
289 | 291 | DECORATE.onStatement(instrumentationSpan, instrumentationSql); |
290 | 292 | instrumentationStatement.execute(); |
291 | 293 | } catch (Exception e) { |
|
0 commit comments