From 62e11c938e7b13cf84e61ceaa862b5e228fa6247 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sat, 9 Nov 2024 17:06:17 -0800 Subject: [PATCH 1/6] Simplify db getter and extractor hierarchy --- .../db/DbClientAttributesExtractor.java | 41 ++++++++++-- .../semconv/db/DbClientAttributesGetter.java | 37 +++++++++- .../db/DbClientCommonAttributesExtractor.java | 67 ------------------- .../db/DbClientCommonAttributesGetter.java | 47 ------------- .../db/SqlClientAttributesExtractor.java | 33 +++++++-- .../semconv/db/SqlClientAttributesGetter.java | 3 +- 6 files changed, 102 insertions(+), 126 deletions(-) delete mode 100644 instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java delete mode 100644 instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java index 279f3171d192..d73167fa276d 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java @@ -12,6 +12,9 @@ import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.internal.SemconvStability; +import io.opentelemetry.instrumentation.api.internal.SpanKey; +import io.opentelemetry.instrumentation.api.internal.SpanKeyProvider; +import javax.annotation.Nullable; /** * Extractor of - extends DbClientCommonAttributesExtractor< - REQUEST, RESPONSE, DbClientAttributesGetter> { + implements AttributesExtractor, SpanKeyProvider { // copied from DbIncubatingAttributes + private static final AttributeKey DB_NAME = AttributeKey.stringKey("db.name"); + private static final AttributeKey DB_NAMESPACE = AttributeKey.stringKey("db.namespace"); + private static final AttributeKey DB_SYSTEM = AttributeKey.stringKey("db.system"); + private static final AttributeKey DB_USER = AttributeKey.stringKey("db.user"); + private static final AttributeKey DB_CONNECTION_STRING = + AttributeKey.stringKey("db.connection_string"); private static final AttributeKey DB_STATEMENT = AttributeKey.stringKey("db.statement"); private static final AttributeKey DB_QUERY_TEXT = AttributeKey.stringKey("db.query.text"); @@ -33,6 +41,8 @@ public final class DbClientAttributesExtractor private static final AttributeKey DB_OPERATION_NAME = AttributeKey.stringKey("db.operation.name"); + private final DbClientAttributesGetter getter; + /** Creates the database client attributes extractor with default configuration. */ public static AttributesExtractor create( DbClientAttributesGetter getter) { @@ -40,20 +50,41 @@ public static AttributesExtractor create( } DbClientAttributesExtractor(DbClientAttributesGetter getter) { - super(getter); + this.getter = getter; } @Override + @SuppressWarnings("deprecation") // using deprecated semconv public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) { - super.onStart(attributes, parentContext, request); - + internalSet(attributes, DB_SYSTEM, getter.getDbSystem(request)); if (SemconvStability.emitStableDatabaseSemconv()) { + internalSet(attributes, DB_NAMESPACE, getter.getDbNamespace(request)); internalSet(attributes, DB_QUERY_TEXT, getter.getDbQueryText(request)); internalSet(attributes, DB_OPERATION_NAME, getter.getDbOperationName(request)); } if (SemconvStability.emitOldDatabaseSemconv()) { + internalSet(attributes, DB_USER, getter.getUser(request)); + internalSet(attributes, DB_NAME, getter.getDbNamespace(request)); + internalSet(attributes, DB_CONNECTION_STRING, getter.getConnectionString(request)); internalSet(attributes, DB_STATEMENT, getter.getDbQueryText(request)); internalSet(attributes, DB_OPERATION, getter.getDbOperationName(request)); } } + + @Override + public void onEnd( + AttributesBuilder attributes, + Context context, + REQUEST request, + @Nullable RESPONSE response, + @Nullable Throwable error) {} + + /** + * This method is internal and is hence not for public use. Its API is unstable and can change at + * any time. + */ + @Override + public SpanKey internalGetSpanKey() { + return SpanKey.DB_CLIENT; + } } diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java index ddf9f8f07a1a..b691bb35ba71 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java @@ -18,7 +18,42 @@ * from the attribute methods, but implement as many as possible for best compliance with the * OpenTelemetry specification. */ -public interface DbClientAttributesGetter extends DbClientCommonAttributesGetter { +public interface DbClientAttributesGetter { + + @Deprecated + @Nullable + default String getSystem(REQUEST request) { + return null; + } + + // TODO: make this required to implement + @Nullable + default String getDbSystem(REQUEST request) { + return getSystem(request); + } + + @Deprecated + @Nullable + String getUser(REQUEST request); + + /** + * @deprecated Use {@link #getDbNamespace(Object)} instead. + */ + @Deprecated + @Nullable + default String getName(REQUEST request) { + return null; + } + + // TODO: make this required to implement + @Nullable + default String getDbNamespace(REQUEST request) { + return getName(request); + } + + @Deprecated + @Nullable + String getConnectionString(REQUEST request); /** * @deprecated Use {@link #getDbQueryText(REQUEST)} instead. diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java deleted file mode 100644 index 9cbf4fb97895..000000000000 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.instrumentation.api.incubator.semconv.db; - -import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet; - -import io.opentelemetry.api.common.AttributeKey; -import io.opentelemetry.api.common.AttributesBuilder; -import io.opentelemetry.context.Context; -import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.internal.SemconvStability; -import io.opentelemetry.instrumentation.api.internal.SpanKey; -import io.opentelemetry.instrumentation.api.internal.SpanKeyProvider; -import javax.annotation.Nullable; - -abstract class DbClientCommonAttributesExtractor< - REQUEST, RESPONSE, GETTER extends DbClientCommonAttributesGetter> - implements AttributesExtractor, SpanKeyProvider { - - // copied from DbIncubatingAttributes - private static final AttributeKey DB_NAME = AttributeKey.stringKey("db.name"); - private static final AttributeKey DB_NAMESPACE = AttributeKey.stringKey("db.namespace"); - private static final AttributeKey DB_SYSTEM = AttributeKey.stringKey("db.system"); - private static final AttributeKey DB_USER = AttributeKey.stringKey("db.user"); - private static final AttributeKey DB_CONNECTION_STRING = - AttributeKey.stringKey("db.connection_string"); - - final GETTER getter; - - DbClientCommonAttributesExtractor(GETTER getter) { - this.getter = getter; - } - - @SuppressWarnings("deprecation") // until old db semconv are dropped - @Override - public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) { - internalSet(attributes, DB_SYSTEM, getter.getDbSystem(request)); - if (SemconvStability.emitStableDatabaseSemconv()) { - internalSet(attributes, DB_NAMESPACE, getter.getDbNamespace(request)); - } - if (SemconvStability.emitOldDatabaseSemconv()) { - internalSet(attributes, DB_USER, getter.getUser(request)); - internalSet(attributes, DB_NAME, getter.getDbNamespace(request)); - internalSet(attributes, DB_CONNECTION_STRING, getter.getConnectionString(request)); - } - } - - @Override - public final void onEnd( - AttributesBuilder attributes, - Context context, - REQUEST request, - @Nullable RESPONSE response, - @Nullable Throwable error) {} - - /** - * This method is internal and is hence not for public use. Its API is unstable and can change at - * any time. - */ - @Override - public SpanKey internalGetSpanKey() { - return SpanKey.DB_CLIENT; - } -} diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java deleted file mode 100644 index bc9a335f4e76..000000000000 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.instrumentation.api.incubator.semconv.db; - -import javax.annotation.Nullable; - -/** An interface for getting attributes common to database clients. */ -public interface DbClientCommonAttributesGetter { - - @Deprecated - @Nullable - default String getSystem(REQUEST request) { - return null; - } - - // TODO: make this required to implement - @Nullable - default String getDbSystem(REQUEST request) { - return getSystem(request); - } - - @Deprecated - @Nullable - String getUser(REQUEST request); - - /** - * @deprecated Use {@link #getDbNamespace(Object)} instead. - */ - @Deprecated - @Nullable - default String getName(REQUEST request) { - return null; - } - - // TODO: make this required to implement - @Nullable - default String getDbNamespace(REQUEST request) { - return getName(request); - } - - @Deprecated - @Nullable - String getConnectionString(REQUEST request); -} diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java index fc5f29efe81b..ca3158b4a6de 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java @@ -12,6 +12,9 @@ import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.internal.SemconvStability; +import io.opentelemetry.instrumentation.api.internal.SpanKey; +import io.opentelemetry.instrumentation.api.internal.SpanKeyProvider; +import javax.annotation.Nullable; /** * Extractor of - extends DbClientCommonAttributesExtractor< - REQUEST, RESPONSE, SqlClientAttributesGetter> { + implements AttributesExtractor, SpanKeyProvider { // copied from DbIncubatingAttributes private static final AttributeKey DB_OPERATION = AttributeKey.stringKey("db.operation"); @@ -58,18 +60,22 @@ public static SqlClientAttributesExtractorBuilder oldSemconvTableAttribute; private final boolean statementSanitizationEnabled; + private final AttributesExtractor delegate; + private final SqlClientAttributesGetter getter; + SqlClientAttributesExtractor( SqlClientAttributesGetter getter, AttributeKey oldSemconvTableAttribute, boolean statementSanitizationEnabled) { - super(getter); + this.delegate = DbClientAttributesExtractor.create(getter); this.oldSemconvTableAttribute = oldSemconvTableAttribute; this.statementSanitizationEnabled = statementSanitizationEnabled; + this.getter = getter; } @Override public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) { - super.onStart(attributes, parentContext, request); + delegate.onStart(attributes, parentContext, request); String rawQueryText = getter.getRawQueryText(request); SqlStatementInfo sanitizedStatement = sanitizer.sanitize(rawQueryText); @@ -97,4 +103,23 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST } } } + + @Override + public void onEnd( + AttributesBuilder attributes, + Context context, + REQUEST request, + @Nullable RESPONSE response, + @Nullable Throwable error) { + delegate.onEnd(attributes, context, request, response, error); + } + + /** + * This method is internal and is hence not for public use. Its API is unstable and can change at + * any time. + */ + @Override + public SpanKey internalGetSpanKey() { + return SpanKey.DB_CLIENT; + } } diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesGetter.java index d0817d63e460..fdf42b6da502 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesGetter.java @@ -18,8 +18,7 @@ * from the attribute methods, but implement as many as possible for best compliance with the * OpenTelemetry specification. */ -public interface SqlClientAttributesGetter - extends DbClientCommonAttributesGetter { +public interface SqlClientAttributesGetter extends DbClientAttributesGetter { /** * Get the raw SQL statement. The value returned by this method is later sanitized by the {@link From 8561995a1f62205581afa84dee8ec9a9cd03d462 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 10 Nov 2024 20:35:34 -0800 Subject: [PATCH 2/6] bring back and deprecate public api --- .../semconv/db/DbClientAttributesGetter.java | 59 ++++++++++--------- .../db/DbClientCommonAttributesGetter.java | 25 ++++++++ 2 files changed, 55 insertions(+), 29 deletions(-) create mode 100644 instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java index b691bb35ba71..502ac4881262 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java @@ -18,42 +18,55 @@ * from the attribute methods, but implement as many as possible for best compliance with the * OpenTelemetry specification. */ -public interface DbClientAttributesGetter { +@SuppressWarnings("deprecation") // using deprecated semconv +public interface DbClientAttributesGetter extends DbClientCommonAttributesGetter { - @Deprecated @Nullable - default String getSystem(REQUEST request) { + String getDbSystem(REQUEST request); + + @Nullable + String getDbNamespace(REQUEST request); + + @Nullable + default String getDbQueryText(REQUEST request) { return null; } - // TODO: make this required to implement @Nullable - default String getDbSystem(REQUEST request) { - return getSystem(request); + default String getDbOperationName(REQUEST request) { + return null; } + /** + * @deprecated Use {@link #getDbSystem(Object)} instead. + */ @Deprecated + @Override @Nullable - String getUser(REQUEST request); + default String getSystem(REQUEST request) { + return getDbSystem(request); + } - /** - * @deprecated Use {@link #getDbNamespace(Object)} instead. - */ @Deprecated @Nullable - default String getName(REQUEST request) { + default String getUser(REQUEST request) { return null; } - // TODO: make this required to implement + /** + * @deprecated Use {@link #getDbNamespace(Object)} instead. + */ + @Deprecated @Nullable - default String getDbNamespace(REQUEST request) { - return getName(request); + default String getName(REQUEST request) { + return getDbNamespace(request); } @Deprecated @Nullable - String getConnectionString(REQUEST request); + default String getConnectionString(REQUEST request) { + return null; + } /** * @deprecated Use {@link #getDbQueryText(REQUEST)} instead. @@ -61,13 +74,7 @@ default String getDbNamespace(REQUEST request) { @Deprecated @Nullable default String getStatement(REQUEST request) { - return null; - } - - // TODO: make this required to implement - @Nullable - default String getDbQueryText(REQUEST request) { - return getStatement(request); + return getDbQueryText(request); } /** @@ -76,12 +83,6 @@ default String getDbQueryText(REQUEST request) { @Deprecated @Nullable default String getOperation(REQUEST request) { - return null; - } - - // TODO: make this required to implement - @Nullable - default String getDbOperationName(REQUEST request) { - return getOperation(request); + return getDbOperationName(request); } } diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java new file mode 100644 index 000000000000..ee6bce082a82 --- /dev/null +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java @@ -0,0 +1,25 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.api.incubator.semconv.db; + +import javax.annotation.Nullable; + +/** An interface for getting attributes common to database clients. */ +@Deprecated +public interface DbClientCommonAttributesGetter { + + @Nullable + String getSystem(REQUEST request); + + @Nullable + String getUser(REQUEST request); + + @Nullable + String getName(REQUEST request); + + @Nullable + String getConnectionString(REQUEST request); +} From 77aa6fb0851d2ad394af1c58403f5d40ae74553e Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 10 Nov 2024 20:37:32 -0800 Subject: [PATCH 3/6] comment --- .../incubator/semconv/db/DbClientCommonAttributesGetter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java index ee6bce082a82..076d006fae68 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java @@ -8,7 +8,7 @@ import javax.annotation.Nullable; /** An interface for getting attributes common to database clients. */ -@Deprecated +@Deprecated // to be removed in 3.0.0 public interface DbClientCommonAttributesGetter { @Nullable From 6b654cf895b168d36a27c4375b7fcbd9986f1429 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 10 Nov 2024 20:41:28 -0800 Subject: [PATCH 4/6] sync more with last release --- .../semconv/db/DbClientAttributesGetter.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java index 502ac4881262..29772f2908dc 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java @@ -27,15 +27,14 @@ public interface DbClientAttributesGetter extends DbClientCommonAttribu @Nullable String getDbNamespace(REQUEST request); + // TODO (trask) add default implementation that returns null @Nullable - default String getDbQueryText(REQUEST request) { - return null; - } + String getDbQueryText(REQUEST request); + // TODO (trask) add default implementation that returns null + // after https://github.com/open-telemetry/semantic-conventions/pull/1566 @Nullable - default String getDbOperationName(REQUEST request) { - return null; - } + String getDbOperationName(REQUEST request); /** * @deprecated Use {@link #getDbSystem(Object)} instead. From bc9a0128abcbca8e6acb6cb6d3d8683b0d1fd995 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 10 Nov 2024 20:48:40 -0800 Subject: [PATCH 5/6] reduce changes --- .../semconv/db/DbClientAttributesGetter.java | 56 ++++++++----------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java index 29772f2908dc..fb1f0319a685 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java @@ -21,67 +21,55 @@ @SuppressWarnings("deprecation") // using deprecated semconv public interface DbClientAttributesGetter extends DbClientCommonAttributesGetter { + /** + * @deprecated Use {@link #getDbQueryText(REQUEST)} instead. + */ + @Deprecated @Nullable - String getDbSystem(REQUEST request); - - @Nullable - String getDbNamespace(REQUEST request); + default String getStatement(REQUEST request) { + return getDbQueryText(request); + } // TODO (trask) add default implementation that returns null @Nullable String getDbQueryText(REQUEST request); - // TODO (trask) add default implementation that returns null - // after https://github.com/open-telemetry/semantic-conventions/pull/1566 - @Nullable - String getDbOperationName(REQUEST request); - /** - * @deprecated Use {@link #getDbSystem(Object)} instead. + * @deprecated Use {@link #getDbOperationName(REQUEST)} instead. */ @Deprecated - @Override @Nullable - default String getSystem(REQUEST request) { - return getDbSystem(request); + default String getOperation(REQUEST request) { + return getDbOperationName(request); } - @Deprecated + // TODO (trask) add default implementation that returns null + // after https://github.com/open-telemetry/semantic-conventions/pull/1566 @Nullable - default String getUser(REQUEST request) { - return null; - } + String getDbOperationName(REQUEST request); - /** - * @deprecated Use {@link #getDbNamespace(Object)} instead. - */ - @Deprecated @Nullable - default String getName(REQUEST request) { - return getDbNamespace(request); - } + String getDbSystem(REQUEST request); - @Deprecated @Nullable - default String getConnectionString(REQUEST request) { - return null; - } + String getDbNamespace(REQUEST request); /** - * @deprecated Use {@link #getDbQueryText(REQUEST)} instead. + * @deprecated Use {@link #getDbSystem(Object)} instead. */ @Deprecated + @Override @Nullable - default String getStatement(REQUEST request) { - return getDbQueryText(request); + default String getSystem(REQUEST request) { + return getDbSystem(request); } /** - * @deprecated Use {@link #getDbOperationName(REQUEST)} instead. + * @deprecated Use {@link #getDbNamespace(Object)} instead. */ @Deprecated @Nullable - default String getOperation(REQUEST request) { - return getDbOperationName(request); + default String getName(REQUEST request) { + return getDbNamespace(request); } } From 9b18a94707b5ec1383f4fbe42c4b7c2b94963868 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 10 Nov 2024 20:49:44 -0800 Subject: [PATCH 6/6] fix --- .../api/incubator/semconv/db/DbClientAttributesGetter.java | 1 + 1 file changed, 1 insertion(+) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java index fb1f0319a685..64fc257e2d37 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java @@ -68,6 +68,7 @@ default String getSystem(REQUEST request) { * @deprecated Use {@link #getDbNamespace(Object)} instead. */ @Deprecated + @Override @Nullable default String getName(REQUEST request) { return getDbNamespace(request);