|
11 | 11 | import io.opentelemetry.api.common.AttributesBuilder;
|
12 | 12 | import io.opentelemetry.context.Context;
|
13 | 13 | import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
14 |
| -import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; |
15 | 14 |
|
16 | 15 | /**
|
17 | 16 | * Extractor of <a
|
18 | 17 | * href="https://github.com/open-telemetry/semantic-conventions/blob/main/docs/database/database-spans.md">database
|
19 | 18 | * attributes</a>. This class is designed with SQL (or SQL-like) database clients in mind.
|
20 | 19 | *
|
21 | 20 | * <p>It sets the same set of attributes as {@link DbClientAttributesExtractor} plus an additional
|
22 |
| - * <code>{@link DbIncubatingAttributes#DB_SQL_TABLE}</code> attribute. The raw SQL statements |
23 |
| - * returned by the {@link SqlClientAttributesGetter#getRawStatement(Object)} method are sanitized |
24 |
| - * before use, all statement parameters are removed. |
| 21 | + * <code>db.sql.table</code> attribute. The raw SQL statements returned by the {@link |
| 22 | + * SqlClientAttributesGetter#getRawStatement(Object)} method are sanitized before use, all statement |
| 23 | + * parameters are removed. |
25 | 24 | */
|
26 | 25 | public final class SqlClientAttributesExtractor<REQUEST, RESPONSE>
|
27 | 26 | extends DbClientCommonAttributesExtractor<
|
28 | 27 | REQUEST, RESPONSE, SqlClientAttributesGetter<REQUEST>> {
|
29 | 28 |
|
| 29 | + // copied from DbIncubatingAttributes |
| 30 | + private static final AttributeKey<String> DB_OPERATION = AttributeKey.stringKey("db.operation"); |
| 31 | + private static final AttributeKey<String> DB_STATEMENT = AttributeKey.stringKey("db.statement"); |
| 32 | + |
30 | 33 | /** Creates the SQL client attributes extractor with default configuration. */
|
31 | 34 | public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
32 | 35 | SqlClientAttributesGetter<REQUEST> getter) {
|
@@ -62,9 +65,8 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST
|
62 | 65 |
|
63 | 66 | SqlStatementInfo sanitizedStatement = sanitizer.sanitize(getter.getRawStatement(request));
|
64 | 67 | String operation = sanitizedStatement.getOperation();
|
65 |
| - internalSet( |
66 |
| - attributes, DbIncubatingAttributes.DB_STATEMENT, sanitizedStatement.getFullStatement()); |
67 |
| - internalSet(attributes, DbIncubatingAttributes.DB_OPERATION, operation); |
| 68 | + internalSet(attributes, DB_STATEMENT, sanitizedStatement.getFullStatement()); |
| 69 | + internalSet(attributes, DB_OPERATION, operation); |
68 | 70 | if (!SQL_CALL.equals(operation)) {
|
69 | 71 | internalSet(attributes, dbTableAttribute, sanitizedStatement.getMainIdentifier());
|
70 | 72 | }
|
|
0 commit comments