diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbCassandraSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbCassandraSemanticConvention.java new file mode 100644 index 0000000000..9d2e136f46 --- /dev/null +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbCassandraSemanticConvention.java @@ -0,0 +1,124 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.opentelemetry.auto.typedspan; + +import io.opentelemetry.trace.Span; + +public interface DbCassandraSemanticConvention { + void end(); + + Span getSpan(); + + /** + * Sets a value for db.system + * + * @param dbSystem An identifier for the database management system (DBMS) product being used. See + * below for a list of well-known identifiers.. + */ + public DbCassandraSemanticConvention setDbSystem(String dbSystem); + + /** + * Sets a value for db.connection_string + * + * @param dbConnectionString The connection string used to connect to the database.. + *
It is recommended to remove embedded credentials. + */ + public DbCassandraSemanticConvention setDbConnectionString(String dbConnectionString); + + /** + * Sets a value for db.user + * + * @param dbUser Username for accessing the database.. + */ + public DbCassandraSemanticConvention setDbUser(String dbUser); + + /** + * Sets a value for db.jdbc.driver_classname + * + * @param dbJdbcDriverClassname The fully-qualified class name of the [Java Database Connectivity + * (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver used to + * connect.. + */ + public DbCassandraSemanticConvention setDbJdbcDriverClassname(String dbJdbcDriverClassname); + + /** + * Sets a value for db.name + * + * @param dbName If no tech-specific attribute is defined, this attribute is used to report the + * name of the database being accessed. For commands that switch the database, this should be + * set to the target database (even if the command fails).. + *
In some SQL databases, the database name to be used is called "schema name". + */ + public DbCassandraSemanticConvention setDbName(String dbName); + + /** + * Sets a value for db.statement + * + * @param dbStatement The database statement being executed.. + *
The value may be sanitized to exclude sensitive information. + */ + public DbCassandraSemanticConvention setDbStatement(String dbStatement); + + /** + * Sets a value for db.operation + * + * @param dbOperation The name of the operation being executed, e.g. the [MongoDB command + * name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as + * `findAndModify`.. + *
While it would semantically make sense to set this, e.g., to a SQL keyword like `SELECT` + * or `INSERT`, it is not recommended to attempt any client-side parsing of `db.statement` + * just to get this property (the back end can do that if required). + */ + public DbCassandraSemanticConvention setDbOperation(String dbOperation); + + /** + * Sets a value for net.peer.name + * + * @param netPeerName Remote hostname or similar, see note below.. + */ + public DbCassandraSemanticConvention setNetPeerName(String netPeerName); + + /** + * Sets a value for net.peer.ip + * + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or + * [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). + */ + public DbCassandraSemanticConvention setNetPeerIp(String netPeerIp); + + /** + * Sets a value for net.peer.port + * + * @param netPeerPort Remote port number.. + */ + public DbCassandraSemanticConvention setNetPeerPort(long netPeerPort); + + /** + * Sets a value for net.transport + * + * @param netTransport Transport protocol used. See note below.. + */ + public DbCassandraSemanticConvention setNetTransport(String netTransport); + + /** + * Sets a value for db.cassandra.keyspace + * + * @param dbCassandraKeyspace The name of the keyspace being accessed. To be used instead of the + * generic `db.name` attribute.. + */ + public DbCassandraSemanticConvention setDbCassandraKeyspace(String dbCassandraKeyspace); +} diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbCassandraSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbCassandraSpan.java new file mode 100644 index 0000000000..c8ebae8ab4 --- /dev/null +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbCassandraSpan.java @@ -0,0 +1,386 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.opentelemetry.auto.typedspan; + +import io.opentelemetry.trace.Span; +import io.opentelemetry.trace.SpanContext; +import io.opentelemetry.trace.Tracer; + +public class DbCassandraSpan extends DelegatingSpan implements DbCassandraSemanticConvention { + + protected DbCassandraSpan(Span span) { + super(span); + } + + /** + * Entry point to generate a {@link DbCassandraSpan}. + * + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link DbCassandraSpan} object. + */ + public static DbCassandraSpanBuilder createDbCassandraSpan(Tracer tracer, String spanName) { + return new DbCassandraSpanBuilder(tracer, spanName); + } + + /** + * Creates a {@link DbCassandraSpan} from a {@link DbSpan}. + * + * @param builder {@link DbSpan.DbSpanBuilder} to use. + * @return a {@link DbCassandraSpan} object built from a {@link DbSpan}. + */ + public static DbCassandraSpanBuilder createDbCassandraSpan(DbSpan.DbSpanBuilder builder) { + // we accept a builder from Db since DbCassandra "extends" Db + return new DbCassandraSpanBuilder(builder.getSpanBuilder()); + } + + /** @return the Span used internally */ + @Override + public Span getSpan() { + return this.delegate; + } + + /** Terminates the Span. Here there is the checking for required attributes. */ + @Override + public void end() { + delegate.end(); + } + + /** + * Sets db.system. + * + * @param dbSystem An identifier for the database management system (DBMS) product being used. See + * below for a list of well-known identifiers. + */ + @Override + public DbCassandraSemanticConvention setDbSystem(String dbSystem) { + delegate.setAttribute("db.system", dbSystem); + return this; + } + + /** + * Sets db.connection_string. + * + * @param dbConnectionString The connection string used to connect to the database. + *
It is recommended to remove embedded credentials. + */ + @Override + public DbCassandraSemanticConvention setDbConnectionString(String dbConnectionString) { + delegate.setAttribute("db.connection_string", dbConnectionString); + return this; + } + + /** + * Sets db.user. + * + * @param dbUser Username for accessing the database. + */ + @Override + public DbCassandraSemanticConvention setDbUser(String dbUser) { + delegate.setAttribute("db.user", dbUser); + return this; + } + + /** + * Sets db.jdbc.driver_classname. + * + * @param dbJdbcDriverClassname The fully-qualified class name of the [Java Database Connectivity + * (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver used to + * connect. + */ + @Override + public DbCassandraSemanticConvention setDbJdbcDriverClassname(String dbJdbcDriverClassname) { + delegate.setAttribute("db.jdbc.driver_classname", dbJdbcDriverClassname); + return this; + } + + /** + * Sets db.name. + * + * @param dbName If no tech-specific attribute is defined, this attribute is used to report the + * name of the database being accessed. For commands that switch the database, this should be + * set to the target database (even if the command fails). + *
In some SQL databases, the database name to be used is called "schema name". + */ + @Override + public DbCassandraSemanticConvention setDbName(String dbName) { + delegate.setAttribute("db.name", dbName); + return this; + } + + /** + * Sets db.statement. + * + * @param dbStatement The database statement being executed. + *
The value may be sanitized to exclude sensitive information. + */ + @Override + public DbCassandraSemanticConvention setDbStatement(String dbStatement) { + delegate.setAttribute("db.statement", dbStatement); + return this; + } + + /** + * Sets db.operation. + * + * @param dbOperation The name of the operation being executed, e.g. the [MongoDB command + * name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as + * `findAndModify`. + *
While it would semantically make sense to set this, e.g., to a SQL keyword like `SELECT` + * or `INSERT`, it is not recommended to attempt any client-side parsing of `db.statement` + * just to get this property (the back end can do that if required). + */ + @Override + public DbCassandraSemanticConvention setDbOperation(String dbOperation) { + delegate.setAttribute("db.operation", dbOperation); + return this; + } + + /** + * Sets net.peer.name. + * + * @param netPeerName Remote hostname or similar, see note below. + */ + @Override + public DbCassandraSemanticConvention setNetPeerName(String netPeerName) { + delegate.setAttribute("net.peer.name", netPeerName); + return this; + } + + /** + * Sets net.peer.ip. + * + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or + * [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). + */ + @Override + public DbCassandraSemanticConvention setNetPeerIp(String netPeerIp) { + delegate.setAttribute("net.peer.ip", netPeerIp); + return this; + } + + /** + * Sets net.peer.port. + * + * @param netPeerPort Remote port number. + */ + @Override + public DbCassandraSemanticConvention setNetPeerPort(long netPeerPort) { + delegate.setAttribute("net.peer.port", netPeerPort); + return this; + } + + /** + * Sets net.transport. + * + * @param netTransport Transport protocol used. See note below. + */ + @Override + public DbCassandraSemanticConvention setNetTransport(String netTransport) { + delegate.setAttribute("net.transport", netTransport); + return this; + } + + /** + * Sets db.cassandra.keyspace. + * + * @param dbCassandraKeyspace The name of the keyspace being accessed. To be used instead of the + * generic `db.name` attribute. + */ + @Override + public DbCassandraSemanticConvention setDbCassandraKeyspace(String dbCassandraKeyspace) { + delegate.setAttribute("db.cassandra.keyspace", dbCassandraKeyspace); + return this; + } + + /** Builder class for {@link DbCassandraSpan}. */ + public static class DbCassandraSpanBuilder { + // Protected because maybe we want to extend manually these classes + protected Span.Builder internalBuilder; + + protected DbCassandraSpanBuilder(Tracer tracer, String spanName) { + internalBuilder = tracer.spanBuilder(spanName); + } + + public DbCassandraSpanBuilder(Span.Builder spanBuilder) { + this.internalBuilder = spanBuilder; + } + + public Span.Builder getSpanBuilder() { + return this.internalBuilder; + } + + /** sets the {@link Span} parent. */ + public DbCassandraSpanBuilder setParent(Span parent) { + this.internalBuilder.setParent(parent); + return this; + } + + /** sets the {@link Span} parent. */ + public DbCassandraSpanBuilder setParent(SpanContext remoteParent) { + this.internalBuilder.setParent(remoteParent); + return this; + } + + /** this method sets the type of the {@link Span} is only available in the builder. */ + public DbCassandraSpanBuilder setKind(Span.Kind kind) { + internalBuilder.setSpanKind(kind); + return this; + } + + /** starts the span */ + public DbCassandraSpan start() { + // check for sampling relevant field here, but there are none. + return new DbCassandraSpan(this.internalBuilder.startSpan()); + } + + /** + * Sets db.system. + * + * @param dbSystem An identifier for the database management system (DBMS) product being used. + * See below for a list of well-known identifiers. + */ + public DbCassandraSpanBuilder setDbSystem(String dbSystem) { + internalBuilder.setAttribute("db.system", dbSystem); + return this; + } + + /** + * Sets db.connection_string. + * + * @param dbConnectionString The connection string used to connect to the database. + *
It is recommended to remove embedded credentials. + */ + public DbCassandraSpanBuilder setDbConnectionString(String dbConnectionString) { + internalBuilder.setAttribute("db.connection_string", dbConnectionString); + return this; + } + + /** + * Sets db.user. + * + * @param dbUser Username for accessing the database. + */ + public DbCassandraSpanBuilder setDbUser(String dbUser) { + internalBuilder.setAttribute("db.user", dbUser); + return this; + } + + /** + * Sets db.jdbc.driver_classname. + * + * @param dbJdbcDriverClassname The fully-qualified class name of the [Java Database + * Connectivity (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver + * used to connect. + */ + public DbCassandraSpanBuilder setDbJdbcDriverClassname(String dbJdbcDriverClassname) { + internalBuilder.setAttribute("db.jdbc.driver_classname", dbJdbcDriverClassname); + return this; + } + + /** + * Sets db.name. + * + * @param dbName If no tech-specific attribute is defined, this attribute is used to report the + * name of the database being accessed. For commands that switch the database, this should + * be set to the target database (even if the command fails). + *
In some SQL databases, the database name to be used is called "schema name". + */ + public DbCassandraSpanBuilder setDbName(String dbName) { + internalBuilder.setAttribute("db.name", dbName); + return this; + } + + /** + * Sets db.statement. + * + * @param dbStatement The database statement being executed. + *
The value may be sanitized to exclude sensitive information. + */ + public DbCassandraSpanBuilder setDbStatement(String dbStatement) { + internalBuilder.setAttribute("db.statement", dbStatement); + return this; + } + + /** + * Sets db.operation. + * + * @param dbOperation The name of the operation being executed, e.g. the [MongoDB command + * name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as + * `findAndModify`. + *
While it would semantically make sense to set this, e.g., to a SQL keyword like + * `SELECT` or `INSERT`, it is not recommended to attempt any client-side parsing of + * `db.statement` just to get this property (the back end can do that if required). + */ + public DbCassandraSpanBuilder setDbOperation(String dbOperation) { + internalBuilder.setAttribute("db.operation", dbOperation); + return this; + } + + /** + * Sets net.peer.name. + * + * @param netPeerName Remote hostname or similar, see note below. + */ + public DbCassandraSpanBuilder setNetPeerName(String netPeerName) { + internalBuilder.setAttribute("net.peer.name", netPeerName); + return this; + } + + /** + * Sets net.peer.ip. + * + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or + * [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). + */ + public DbCassandraSpanBuilder setNetPeerIp(String netPeerIp) { + internalBuilder.setAttribute("net.peer.ip", netPeerIp); + return this; + } + + /** + * Sets net.peer.port. + * + * @param netPeerPort Remote port number. + */ + public DbCassandraSpanBuilder setNetPeerPort(long netPeerPort) { + internalBuilder.setAttribute("net.peer.port", netPeerPort); + return this; + } + + /** + * Sets net.transport. + * + * @param netTransport Transport protocol used. See note below. + */ + public DbCassandraSpanBuilder setNetTransport(String netTransport) { + internalBuilder.setAttribute("net.transport", netTransport); + return this; + } + + /** + * Sets db.cassandra.keyspace. + * + * @param dbCassandraKeyspace The name of the keyspace being accessed. To be used instead of the + * generic `db.name` attribute. + */ + public DbCassandraSpanBuilder setDbCassandraKeyspace(String dbCassandraKeyspace) { + internalBuilder.setAttribute("db.cassandra.keyspace", dbCassandraKeyspace); + return this; + } + } +} diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbHbaseSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbHbaseSemanticConvention.java new file mode 100644 index 0000000000..284adfff05 --- /dev/null +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbHbaseSemanticConvention.java @@ -0,0 +1,124 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.opentelemetry.auto.typedspan; + +import io.opentelemetry.trace.Span; + +public interface DbHbaseSemanticConvention { + void end(); + + Span getSpan(); + + /** + * Sets a value for db.system + * + * @param dbSystem An identifier for the database management system (DBMS) product being used. See + * below for a list of well-known identifiers.. + */ + public DbHbaseSemanticConvention setDbSystem(String dbSystem); + + /** + * Sets a value for db.connection_string + * + * @param dbConnectionString The connection string used to connect to the database.. + *
It is recommended to remove embedded credentials. + */ + public DbHbaseSemanticConvention setDbConnectionString(String dbConnectionString); + + /** + * Sets a value for db.user + * + * @param dbUser Username for accessing the database.. + */ + public DbHbaseSemanticConvention setDbUser(String dbUser); + + /** + * Sets a value for db.jdbc.driver_classname + * + * @param dbJdbcDriverClassname The fully-qualified class name of the [Java Database Connectivity + * (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver used to + * connect.. + */ + public DbHbaseSemanticConvention setDbJdbcDriverClassname(String dbJdbcDriverClassname); + + /** + * Sets a value for db.name + * + * @param dbName If no tech-specific attribute is defined, this attribute is used to report the + * name of the database being accessed. For commands that switch the database, this should be + * set to the target database (even if the command fails).. + *
In some SQL databases, the database name to be used is called "schema name". + */ + public DbHbaseSemanticConvention setDbName(String dbName); + + /** + * Sets a value for db.statement + * + * @param dbStatement The database statement being executed.. + *
The value may be sanitized to exclude sensitive information. + */ + public DbHbaseSemanticConvention setDbStatement(String dbStatement); + + /** + * Sets a value for db.operation + * + * @param dbOperation The name of the operation being executed, e.g. the [MongoDB command + * name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as + * `findAndModify`.. + *
While it would semantically make sense to set this, e.g., to a SQL keyword like `SELECT` + * or `INSERT`, it is not recommended to attempt any client-side parsing of `db.statement` + * just to get this property (the back end can do that if required). + */ + public DbHbaseSemanticConvention setDbOperation(String dbOperation); + + /** + * Sets a value for net.peer.name + * + * @param netPeerName Remote hostname or similar, see note below.. + */ + public DbHbaseSemanticConvention setNetPeerName(String netPeerName); + + /** + * Sets a value for net.peer.ip + * + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or + * [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). + */ + public DbHbaseSemanticConvention setNetPeerIp(String netPeerIp); + + /** + * Sets a value for net.peer.port + * + * @param netPeerPort Remote port number.. + */ + public DbHbaseSemanticConvention setNetPeerPort(long netPeerPort); + + /** + * Sets a value for net.transport + * + * @param netTransport Transport protocol used. See note below.. + */ + public DbHbaseSemanticConvention setNetTransport(String netTransport); + + /** + * Sets a value for db.hbase.namespace + * + * @param dbHbaseNamespace The [HBase namespace](https://hbase.apache.org/book.html#_namespace) + * being accessed. To be used instead of the generic `db.name` attribute.. + */ + public DbHbaseSemanticConvention setDbHbaseNamespace(String dbHbaseNamespace); +} diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbHbaseSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbHbaseSpan.java new file mode 100644 index 0000000000..2f02defdb8 --- /dev/null +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbHbaseSpan.java @@ -0,0 +1,386 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.opentelemetry.auto.typedspan; + +import io.opentelemetry.trace.Span; +import io.opentelemetry.trace.SpanContext; +import io.opentelemetry.trace.Tracer; + +public class DbHbaseSpan extends DelegatingSpan implements DbHbaseSemanticConvention { + + protected DbHbaseSpan(Span span) { + super(span); + } + + /** + * Entry point to generate a {@link DbHbaseSpan}. + * + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link DbHbaseSpan} object. + */ + public static DbHbaseSpanBuilder createDbHbaseSpan(Tracer tracer, String spanName) { + return new DbHbaseSpanBuilder(tracer, spanName); + } + + /** + * Creates a {@link DbHbaseSpan} from a {@link DbSpan}. + * + * @param builder {@link DbSpan.DbSpanBuilder} to use. + * @return a {@link DbHbaseSpan} object built from a {@link DbSpan}. + */ + public static DbHbaseSpanBuilder createDbHbaseSpan(DbSpan.DbSpanBuilder builder) { + // we accept a builder from Db since DbHbase "extends" Db + return new DbHbaseSpanBuilder(builder.getSpanBuilder()); + } + + /** @return the Span used internally */ + @Override + public Span getSpan() { + return this.delegate; + } + + /** Terminates the Span. Here there is the checking for required attributes. */ + @Override + public void end() { + delegate.end(); + } + + /** + * Sets db.system. + * + * @param dbSystem An identifier for the database management system (DBMS) product being used. See + * below for a list of well-known identifiers. + */ + @Override + public DbHbaseSemanticConvention setDbSystem(String dbSystem) { + delegate.setAttribute("db.system", dbSystem); + return this; + } + + /** + * Sets db.connection_string. + * + * @param dbConnectionString The connection string used to connect to the database. + *
It is recommended to remove embedded credentials. + */ + @Override + public DbHbaseSemanticConvention setDbConnectionString(String dbConnectionString) { + delegate.setAttribute("db.connection_string", dbConnectionString); + return this; + } + + /** + * Sets db.user. + * + * @param dbUser Username for accessing the database. + */ + @Override + public DbHbaseSemanticConvention setDbUser(String dbUser) { + delegate.setAttribute("db.user", dbUser); + return this; + } + + /** + * Sets db.jdbc.driver_classname. + * + * @param dbJdbcDriverClassname The fully-qualified class name of the [Java Database Connectivity + * (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver used to + * connect. + */ + @Override + public DbHbaseSemanticConvention setDbJdbcDriverClassname(String dbJdbcDriverClassname) { + delegate.setAttribute("db.jdbc.driver_classname", dbJdbcDriverClassname); + return this; + } + + /** + * Sets db.name. + * + * @param dbName If no tech-specific attribute is defined, this attribute is used to report the + * name of the database being accessed. For commands that switch the database, this should be + * set to the target database (even if the command fails). + *
In some SQL databases, the database name to be used is called "schema name". + */ + @Override + public DbHbaseSemanticConvention setDbName(String dbName) { + delegate.setAttribute("db.name", dbName); + return this; + } + + /** + * Sets db.statement. + * + * @param dbStatement The database statement being executed. + *
The value may be sanitized to exclude sensitive information. + */ + @Override + public DbHbaseSemanticConvention setDbStatement(String dbStatement) { + delegate.setAttribute("db.statement", dbStatement); + return this; + } + + /** + * Sets db.operation. + * + * @param dbOperation The name of the operation being executed, e.g. the [MongoDB command + * name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as + * `findAndModify`. + *
While it would semantically make sense to set this, e.g., to a SQL keyword like `SELECT` + * or `INSERT`, it is not recommended to attempt any client-side parsing of `db.statement` + * just to get this property (the back end can do that if required). + */ + @Override + public DbHbaseSemanticConvention setDbOperation(String dbOperation) { + delegate.setAttribute("db.operation", dbOperation); + return this; + } + + /** + * Sets net.peer.name. + * + * @param netPeerName Remote hostname or similar, see note below. + */ + @Override + public DbHbaseSemanticConvention setNetPeerName(String netPeerName) { + delegate.setAttribute("net.peer.name", netPeerName); + return this; + } + + /** + * Sets net.peer.ip. + * + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or + * [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). + */ + @Override + public DbHbaseSemanticConvention setNetPeerIp(String netPeerIp) { + delegate.setAttribute("net.peer.ip", netPeerIp); + return this; + } + + /** + * Sets net.peer.port. + * + * @param netPeerPort Remote port number. + */ + @Override + public DbHbaseSemanticConvention setNetPeerPort(long netPeerPort) { + delegate.setAttribute("net.peer.port", netPeerPort); + return this; + } + + /** + * Sets net.transport. + * + * @param netTransport Transport protocol used. See note below. + */ + @Override + public DbHbaseSemanticConvention setNetTransport(String netTransport) { + delegate.setAttribute("net.transport", netTransport); + return this; + } + + /** + * Sets db.hbase.namespace. + * + * @param dbHbaseNamespace The [HBase namespace](https://hbase.apache.org/book.html#_namespace) + * being accessed. To be used instead of the generic `db.name` attribute. + */ + @Override + public DbHbaseSemanticConvention setDbHbaseNamespace(String dbHbaseNamespace) { + delegate.setAttribute("db.hbase.namespace", dbHbaseNamespace); + return this; + } + + /** Builder class for {@link DbHbaseSpan}. */ + public static class DbHbaseSpanBuilder { + // Protected because maybe we want to extend manually these classes + protected Span.Builder internalBuilder; + + protected DbHbaseSpanBuilder(Tracer tracer, String spanName) { + internalBuilder = tracer.spanBuilder(spanName); + } + + public DbHbaseSpanBuilder(Span.Builder spanBuilder) { + this.internalBuilder = spanBuilder; + } + + public Span.Builder getSpanBuilder() { + return this.internalBuilder; + } + + /** sets the {@link Span} parent. */ + public DbHbaseSpanBuilder setParent(Span parent) { + this.internalBuilder.setParent(parent); + return this; + } + + /** sets the {@link Span} parent. */ + public DbHbaseSpanBuilder setParent(SpanContext remoteParent) { + this.internalBuilder.setParent(remoteParent); + return this; + } + + /** this method sets the type of the {@link Span} is only available in the builder. */ + public DbHbaseSpanBuilder setKind(Span.Kind kind) { + internalBuilder.setSpanKind(kind); + return this; + } + + /** starts the span */ + public DbHbaseSpan start() { + // check for sampling relevant field here, but there are none. + return new DbHbaseSpan(this.internalBuilder.startSpan()); + } + + /** + * Sets db.system. + * + * @param dbSystem An identifier for the database management system (DBMS) product being used. + * See below for a list of well-known identifiers. + */ + public DbHbaseSpanBuilder setDbSystem(String dbSystem) { + internalBuilder.setAttribute("db.system", dbSystem); + return this; + } + + /** + * Sets db.connection_string. + * + * @param dbConnectionString The connection string used to connect to the database. + *
It is recommended to remove embedded credentials. + */ + public DbHbaseSpanBuilder setDbConnectionString(String dbConnectionString) { + internalBuilder.setAttribute("db.connection_string", dbConnectionString); + return this; + } + + /** + * Sets db.user. + * + * @param dbUser Username for accessing the database. + */ + public DbHbaseSpanBuilder setDbUser(String dbUser) { + internalBuilder.setAttribute("db.user", dbUser); + return this; + } + + /** + * Sets db.jdbc.driver_classname. + * + * @param dbJdbcDriverClassname The fully-qualified class name of the [Java Database + * Connectivity (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver + * used to connect. + */ + public DbHbaseSpanBuilder setDbJdbcDriverClassname(String dbJdbcDriverClassname) { + internalBuilder.setAttribute("db.jdbc.driver_classname", dbJdbcDriverClassname); + return this; + } + + /** + * Sets db.name. + * + * @param dbName If no tech-specific attribute is defined, this attribute is used to report the + * name of the database being accessed. For commands that switch the database, this should + * be set to the target database (even if the command fails). + *
In some SQL databases, the database name to be used is called "schema name". + */ + public DbHbaseSpanBuilder setDbName(String dbName) { + internalBuilder.setAttribute("db.name", dbName); + return this; + } + + /** + * Sets db.statement. + * + * @param dbStatement The database statement being executed. + *
The value may be sanitized to exclude sensitive information. + */ + public DbHbaseSpanBuilder setDbStatement(String dbStatement) { + internalBuilder.setAttribute("db.statement", dbStatement); + return this; + } + + /** + * Sets db.operation. + * + * @param dbOperation The name of the operation being executed, e.g. the [MongoDB command + * name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as + * `findAndModify`. + *
While it would semantically make sense to set this, e.g., to a SQL keyword like + * `SELECT` or `INSERT`, it is not recommended to attempt any client-side parsing of + * `db.statement` just to get this property (the back end can do that if required). + */ + public DbHbaseSpanBuilder setDbOperation(String dbOperation) { + internalBuilder.setAttribute("db.operation", dbOperation); + return this; + } + + /** + * Sets net.peer.name. + * + * @param netPeerName Remote hostname or similar, see note below. + */ + public DbHbaseSpanBuilder setNetPeerName(String netPeerName) { + internalBuilder.setAttribute("net.peer.name", netPeerName); + return this; + } + + /** + * Sets net.peer.ip. + * + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or + * [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). + */ + public DbHbaseSpanBuilder setNetPeerIp(String netPeerIp) { + internalBuilder.setAttribute("net.peer.ip", netPeerIp); + return this; + } + + /** + * Sets net.peer.port. + * + * @param netPeerPort Remote port number. + */ + public DbHbaseSpanBuilder setNetPeerPort(long netPeerPort) { + internalBuilder.setAttribute("net.peer.port", netPeerPort); + return this; + } + + /** + * Sets net.transport. + * + * @param netTransport Transport protocol used. See note below. + */ + public DbHbaseSpanBuilder setNetTransport(String netTransport) { + internalBuilder.setAttribute("net.transport", netTransport); + return this; + } + + /** + * Sets db.hbase.namespace. + * + * @param dbHbaseNamespace The [HBase namespace](https://hbase.apache.org/book.html#_namespace) + * being accessed. To be used instead of the generic `db.name` attribute. + */ + public DbHbaseSpanBuilder setDbHbaseNamespace(String dbHbaseNamespace) { + internalBuilder.setAttribute("db.hbase.namespace", dbHbaseNamespace); + return this; + } + } +} diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMongodbSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMongodbSemanticConvention.java new file mode 100644 index 0000000000..d4dc394c75 --- /dev/null +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMongodbSemanticConvention.java @@ -0,0 +1,124 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.opentelemetry.auto.typedspan; + +import io.opentelemetry.trace.Span; + +public interface DbMongodbSemanticConvention { + void end(); + + Span getSpan(); + + /** + * Sets a value for db.system + * + * @param dbSystem An identifier for the database management system (DBMS) product being used. See + * below for a list of well-known identifiers.. + */ + public DbMongodbSemanticConvention setDbSystem(String dbSystem); + + /** + * Sets a value for db.connection_string + * + * @param dbConnectionString The connection string used to connect to the database.. + *
It is recommended to remove embedded credentials. + */ + public DbMongodbSemanticConvention setDbConnectionString(String dbConnectionString); + + /** + * Sets a value for db.user + * + * @param dbUser Username for accessing the database.. + */ + public DbMongodbSemanticConvention setDbUser(String dbUser); + + /** + * Sets a value for db.jdbc.driver_classname + * + * @param dbJdbcDriverClassname The fully-qualified class name of the [Java Database Connectivity + * (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver used to + * connect.. + */ + public DbMongodbSemanticConvention setDbJdbcDriverClassname(String dbJdbcDriverClassname); + + /** + * Sets a value for db.name + * + * @param dbName If no tech-specific attribute is defined, this attribute is used to report the + * name of the database being accessed. For commands that switch the database, this should be + * set to the target database (even if the command fails).. + *
In some SQL databases, the database name to be used is called "schema name". + */ + public DbMongodbSemanticConvention setDbName(String dbName); + + /** + * Sets a value for db.statement + * + * @param dbStatement The database statement being executed.. + *
The value may be sanitized to exclude sensitive information. + */ + public DbMongodbSemanticConvention setDbStatement(String dbStatement); + + /** + * Sets a value for db.operation + * + * @param dbOperation The name of the operation being executed, e.g. the [MongoDB command + * name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as + * `findAndModify`.. + *
While it would semantically make sense to set this, e.g., to a SQL keyword like `SELECT` + * or `INSERT`, it is not recommended to attempt any client-side parsing of `db.statement` + * just to get this property (the back end can do that if required). + */ + public DbMongodbSemanticConvention setDbOperation(String dbOperation); + + /** + * Sets a value for net.peer.name + * + * @param netPeerName Remote hostname or similar, see note below.. + */ + public DbMongodbSemanticConvention setNetPeerName(String netPeerName); + + /** + * Sets a value for net.peer.ip + * + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or + * [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). + */ + public DbMongodbSemanticConvention setNetPeerIp(String netPeerIp); + + /** + * Sets a value for net.peer.port + * + * @param netPeerPort Remote port number.. + */ + public DbMongodbSemanticConvention setNetPeerPort(long netPeerPort); + + /** + * Sets a value for net.transport + * + * @param netTransport Transport protocol used. See note below.. + */ + public DbMongodbSemanticConvention setNetTransport(String netTransport); + + /** + * Sets a value for db.mongodb.collection + * + * @param dbMongodbCollection The collection being accessed within the database stated in + * `db.name`.. + */ + public DbMongodbSemanticConvention setDbMongodbCollection(String dbMongodbCollection); +} diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMongodbSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMongodbSpan.java new file mode 100644 index 0000000000..b1f64cdab0 --- /dev/null +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMongodbSpan.java @@ -0,0 +1,386 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.opentelemetry.auto.typedspan; + +import io.opentelemetry.trace.Span; +import io.opentelemetry.trace.SpanContext; +import io.opentelemetry.trace.Tracer; + +public class DbMongodbSpan extends DelegatingSpan implements DbMongodbSemanticConvention { + + protected DbMongodbSpan(Span span) { + super(span); + } + + /** + * Entry point to generate a {@link DbMongodbSpan}. + * + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link DbMongodbSpan} object. + */ + public static DbMongodbSpanBuilder createDbMongodbSpan(Tracer tracer, String spanName) { + return new DbMongodbSpanBuilder(tracer, spanName); + } + + /** + * Creates a {@link DbMongodbSpan} from a {@link DbSpan}. + * + * @param builder {@link DbSpan.DbSpanBuilder} to use. + * @return a {@link DbMongodbSpan} object built from a {@link DbSpan}. + */ + public static DbMongodbSpanBuilder createDbMongodbSpan(DbSpan.DbSpanBuilder builder) { + // we accept a builder from Db since DbMongodb "extends" Db + return new DbMongodbSpanBuilder(builder.getSpanBuilder()); + } + + /** @return the Span used internally */ + @Override + public Span getSpan() { + return this.delegate; + } + + /** Terminates the Span. Here there is the checking for required attributes. */ + @Override + public void end() { + delegate.end(); + } + + /** + * Sets db.system. + * + * @param dbSystem An identifier for the database management system (DBMS) product being used. See + * below for a list of well-known identifiers. + */ + @Override + public DbMongodbSemanticConvention setDbSystem(String dbSystem) { + delegate.setAttribute("db.system", dbSystem); + return this; + } + + /** + * Sets db.connection_string. + * + * @param dbConnectionString The connection string used to connect to the database. + *
It is recommended to remove embedded credentials. + */ + @Override + public DbMongodbSemanticConvention setDbConnectionString(String dbConnectionString) { + delegate.setAttribute("db.connection_string", dbConnectionString); + return this; + } + + /** + * Sets db.user. + * + * @param dbUser Username for accessing the database. + */ + @Override + public DbMongodbSemanticConvention setDbUser(String dbUser) { + delegate.setAttribute("db.user", dbUser); + return this; + } + + /** + * Sets db.jdbc.driver_classname. + * + * @param dbJdbcDriverClassname The fully-qualified class name of the [Java Database Connectivity + * (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver used to + * connect. + */ + @Override + public DbMongodbSemanticConvention setDbJdbcDriverClassname(String dbJdbcDriverClassname) { + delegate.setAttribute("db.jdbc.driver_classname", dbJdbcDriverClassname); + return this; + } + + /** + * Sets db.name. + * + * @param dbName If no tech-specific attribute is defined, this attribute is used to report the + * name of the database being accessed. For commands that switch the database, this should be + * set to the target database (even if the command fails). + *
In some SQL databases, the database name to be used is called "schema name". + */ + @Override + public DbMongodbSemanticConvention setDbName(String dbName) { + delegate.setAttribute("db.name", dbName); + return this; + } + + /** + * Sets db.statement. + * + * @param dbStatement The database statement being executed. + *
The value may be sanitized to exclude sensitive information. + */ + @Override + public DbMongodbSemanticConvention setDbStatement(String dbStatement) { + delegate.setAttribute("db.statement", dbStatement); + return this; + } + + /** + * Sets db.operation. + * + * @param dbOperation The name of the operation being executed, e.g. the [MongoDB command + * name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as + * `findAndModify`. + *
While it would semantically make sense to set this, e.g., to a SQL keyword like `SELECT` + * or `INSERT`, it is not recommended to attempt any client-side parsing of `db.statement` + * just to get this property (the back end can do that if required). + */ + @Override + public DbMongodbSemanticConvention setDbOperation(String dbOperation) { + delegate.setAttribute("db.operation", dbOperation); + return this; + } + + /** + * Sets net.peer.name. + * + * @param netPeerName Remote hostname or similar, see note below. + */ + @Override + public DbMongodbSemanticConvention setNetPeerName(String netPeerName) { + delegate.setAttribute("net.peer.name", netPeerName); + return this; + } + + /** + * Sets net.peer.ip. + * + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or + * [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). + */ + @Override + public DbMongodbSemanticConvention setNetPeerIp(String netPeerIp) { + delegate.setAttribute("net.peer.ip", netPeerIp); + return this; + } + + /** + * Sets net.peer.port. + * + * @param netPeerPort Remote port number. + */ + @Override + public DbMongodbSemanticConvention setNetPeerPort(long netPeerPort) { + delegate.setAttribute("net.peer.port", netPeerPort); + return this; + } + + /** + * Sets net.transport. + * + * @param netTransport Transport protocol used. See note below. + */ + @Override + public DbMongodbSemanticConvention setNetTransport(String netTransport) { + delegate.setAttribute("net.transport", netTransport); + return this; + } + + /** + * Sets db.mongodb.collection. + * + * @param dbMongodbCollection The collection being accessed within the database stated in + * `db.name`. + */ + @Override + public DbMongodbSemanticConvention setDbMongodbCollection(String dbMongodbCollection) { + delegate.setAttribute("db.mongodb.collection", dbMongodbCollection); + return this; + } + + /** Builder class for {@link DbMongodbSpan}. */ + public static class DbMongodbSpanBuilder { + // Protected because maybe we want to extend manually these classes + protected Span.Builder internalBuilder; + + protected DbMongodbSpanBuilder(Tracer tracer, String spanName) { + internalBuilder = tracer.spanBuilder(spanName); + } + + public DbMongodbSpanBuilder(Span.Builder spanBuilder) { + this.internalBuilder = spanBuilder; + } + + public Span.Builder getSpanBuilder() { + return this.internalBuilder; + } + + /** sets the {@link Span} parent. */ + public DbMongodbSpanBuilder setParent(Span parent) { + this.internalBuilder.setParent(parent); + return this; + } + + /** sets the {@link Span} parent. */ + public DbMongodbSpanBuilder setParent(SpanContext remoteParent) { + this.internalBuilder.setParent(remoteParent); + return this; + } + + /** this method sets the type of the {@link Span} is only available in the builder. */ + public DbMongodbSpanBuilder setKind(Span.Kind kind) { + internalBuilder.setSpanKind(kind); + return this; + } + + /** starts the span */ + public DbMongodbSpan start() { + // check for sampling relevant field here, but there are none. + return new DbMongodbSpan(this.internalBuilder.startSpan()); + } + + /** + * Sets db.system. + * + * @param dbSystem An identifier for the database management system (DBMS) product being used. + * See below for a list of well-known identifiers. + */ + public DbMongodbSpanBuilder setDbSystem(String dbSystem) { + internalBuilder.setAttribute("db.system", dbSystem); + return this; + } + + /** + * Sets db.connection_string. + * + * @param dbConnectionString The connection string used to connect to the database. + *
It is recommended to remove embedded credentials. + */ + public DbMongodbSpanBuilder setDbConnectionString(String dbConnectionString) { + internalBuilder.setAttribute("db.connection_string", dbConnectionString); + return this; + } + + /** + * Sets db.user. + * + * @param dbUser Username for accessing the database. + */ + public DbMongodbSpanBuilder setDbUser(String dbUser) { + internalBuilder.setAttribute("db.user", dbUser); + return this; + } + + /** + * Sets db.jdbc.driver_classname. + * + * @param dbJdbcDriverClassname The fully-qualified class name of the [Java Database + * Connectivity (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver + * used to connect. + */ + public DbMongodbSpanBuilder setDbJdbcDriverClassname(String dbJdbcDriverClassname) { + internalBuilder.setAttribute("db.jdbc.driver_classname", dbJdbcDriverClassname); + return this; + } + + /** + * Sets db.name. + * + * @param dbName If no tech-specific attribute is defined, this attribute is used to report the + * name of the database being accessed. For commands that switch the database, this should + * be set to the target database (even if the command fails). + *
In some SQL databases, the database name to be used is called "schema name". + */ + public DbMongodbSpanBuilder setDbName(String dbName) { + internalBuilder.setAttribute("db.name", dbName); + return this; + } + + /** + * Sets db.statement. + * + * @param dbStatement The database statement being executed. + *
The value may be sanitized to exclude sensitive information. + */ + public DbMongodbSpanBuilder setDbStatement(String dbStatement) { + internalBuilder.setAttribute("db.statement", dbStatement); + return this; + } + + /** + * Sets db.operation. + * + * @param dbOperation The name of the operation being executed, e.g. the [MongoDB command + * name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as + * `findAndModify`. + *
While it would semantically make sense to set this, e.g., to a SQL keyword like + * `SELECT` or `INSERT`, it is not recommended to attempt any client-side parsing of + * `db.statement` just to get this property (the back end can do that if required). + */ + public DbMongodbSpanBuilder setDbOperation(String dbOperation) { + internalBuilder.setAttribute("db.operation", dbOperation); + return this; + } + + /** + * Sets net.peer.name. + * + * @param netPeerName Remote hostname or similar, see note below. + */ + public DbMongodbSpanBuilder setNetPeerName(String netPeerName) { + internalBuilder.setAttribute("net.peer.name", netPeerName); + return this; + } + + /** + * Sets net.peer.ip. + * + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or + * [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). + */ + public DbMongodbSpanBuilder setNetPeerIp(String netPeerIp) { + internalBuilder.setAttribute("net.peer.ip", netPeerIp); + return this; + } + + /** + * Sets net.peer.port. + * + * @param netPeerPort Remote port number. + */ + public DbMongodbSpanBuilder setNetPeerPort(long netPeerPort) { + internalBuilder.setAttribute("net.peer.port", netPeerPort); + return this; + } + + /** + * Sets net.transport. + * + * @param netTransport Transport protocol used. See note below. + */ + public DbMongodbSpanBuilder setNetTransport(String netTransport) { + internalBuilder.setAttribute("net.transport", netTransport); + return this; + } + + /** + * Sets db.mongodb.collection. + * + * @param dbMongodbCollection The collection being accessed within the database stated in + * `db.name`. + */ + public DbMongodbSpanBuilder setDbMongodbCollection(String dbMongodbCollection) { + internalBuilder.setAttribute("db.mongodb.collection", dbMongodbCollection); + return this; + } + } +} diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMssqlSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMssqlSemanticConvention.java new file mode 100644 index 0000000000..2cd85ae801 --- /dev/null +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMssqlSemanticConvention.java @@ -0,0 +1,127 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.opentelemetry.auto.typedspan; + +import io.opentelemetry.trace.Span; + +public interface DbMssqlSemanticConvention { + void end(); + + Span getSpan(); + + /** + * Sets a value for db.system + * + * @param dbSystem An identifier for the database management system (DBMS) product being used. See + * below for a list of well-known identifiers.. + */ + public DbMssqlSemanticConvention setDbSystem(String dbSystem); + + /** + * Sets a value for db.connection_string + * + * @param dbConnectionString The connection string used to connect to the database.. + *
It is recommended to remove embedded credentials. + */ + public DbMssqlSemanticConvention setDbConnectionString(String dbConnectionString); + + /** + * Sets a value for db.user + * + * @param dbUser Username for accessing the database.. + */ + public DbMssqlSemanticConvention setDbUser(String dbUser); + + /** + * Sets a value for db.jdbc.driver_classname + * + * @param dbJdbcDriverClassname The fully-qualified class name of the [Java Database Connectivity + * (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver used to + * connect.. + */ + public DbMssqlSemanticConvention setDbJdbcDriverClassname(String dbJdbcDriverClassname); + + /** + * Sets a value for db.name + * + * @param dbName If no tech-specific attribute is defined, this attribute is used to report the + * name of the database being accessed. For commands that switch the database, this should be + * set to the target database (even if the command fails).. + *
In some SQL databases, the database name to be used is called "schema name". + */ + public DbMssqlSemanticConvention setDbName(String dbName); + + /** + * Sets a value for db.statement + * + * @param dbStatement The database statement being executed.. + *
The value may be sanitized to exclude sensitive information. + */ + public DbMssqlSemanticConvention setDbStatement(String dbStatement); + + /** + * Sets a value for db.operation + * + * @param dbOperation The name of the operation being executed, e.g. the [MongoDB command + * name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as + * `findAndModify`.. + *
While it would semantically make sense to set this, e.g., to a SQL keyword like `SELECT` + * or `INSERT`, it is not recommended to attempt any client-side parsing of `db.statement` + * just to get this property (the back end can do that if required). + */ + public DbMssqlSemanticConvention setDbOperation(String dbOperation); + + /** + * Sets a value for net.peer.name + * + * @param netPeerName Remote hostname or similar, see note below.. + */ + public DbMssqlSemanticConvention setNetPeerName(String netPeerName); + + /** + * Sets a value for net.peer.ip + * + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or + * [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). + */ + public DbMssqlSemanticConvention setNetPeerIp(String netPeerIp); + + /** + * Sets a value for net.peer.port + * + * @param netPeerPort Remote port number.. + */ + public DbMssqlSemanticConvention setNetPeerPort(long netPeerPort); + + /** + * Sets a value for net.transport + * + * @param netTransport Transport protocol used. See note below.. + */ + public DbMssqlSemanticConvention setNetTransport(String netTransport); + + /** + * Sets a value for db.mssql.instance_name + * + * @param dbMssqlInstanceName The Microsoft SQL Server [instance + * name](https://docs.microsoft.com/en-us/sql/connect/jdbc/building-the-connection-url?view=sql-server-ver15) + * connecting to. This name is used to determine the port of a named instance.. + *
If setting a `db.mssql.instance_name`, `net.peer.port` is no longer required (but still + * recommended if non-standard). + */ + public DbMssqlSemanticConvention setDbMssqlInstanceName(String dbMssqlInstanceName); +} diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMssqlSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMssqlSpan.java new file mode 100644 index 0000000000..4c45c46ef6 --- /dev/null +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMssqlSpan.java @@ -0,0 +1,392 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.opentelemetry.auto.typedspan; + +import io.opentelemetry.trace.Span; +import io.opentelemetry.trace.SpanContext; +import io.opentelemetry.trace.Tracer; + +public class DbMssqlSpan extends DelegatingSpan implements DbMssqlSemanticConvention { + + protected DbMssqlSpan(Span span) { + super(span); + } + + /** + * Entry point to generate a {@link DbMssqlSpan}. + * + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link DbMssqlSpan} object. + */ + public static DbMssqlSpanBuilder createDbMssqlSpan(Tracer tracer, String spanName) { + return new DbMssqlSpanBuilder(tracer, spanName); + } + + /** + * Creates a {@link DbMssqlSpan} from a {@link DbSpan}. + * + * @param builder {@link DbSpan.DbSpanBuilder} to use. + * @return a {@link DbMssqlSpan} object built from a {@link DbSpan}. + */ + public static DbMssqlSpanBuilder createDbMssqlSpan(DbSpan.DbSpanBuilder builder) { + // we accept a builder from Db since DbMssql "extends" Db + return new DbMssqlSpanBuilder(builder.getSpanBuilder()); + } + + /** @return the Span used internally */ + @Override + public Span getSpan() { + return this.delegate; + } + + /** Terminates the Span. Here there is the checking for required attributes. */ + @Override + public void end() { + delegate.end(); + } + + /** + * Sets db.system. + * + * @param dbSystem An identifier for the database management system (DBMS) product being used. See + * below for a list of well-known identifiers. + */ + @Override + public DbMssqlSemanticConvention setDbSystem(String dbSystem) { + delegate.setAttribute("db.system", dbSystem); + return this; + } + + /** + * Sets db.connection_string. + * + * @param dbConnectionString The connection string used to connect to the database. + *
It is recommended to remove embedded credentials. + */ + @Override + public DbMssqlSemanticConvention setDbConnectionString(String dbConnectionString) { + delegate.setAttribute("db.connection_string", dbConnectionString); + return this; + } + + /** + * Sets db.user. + * + * @param dbUser Username for accessing the database. + */ + @Override + public DbMssqlSemanticConvention setDbUser(String dbUser) { + delegate.setAttribute("db.user", dbUser); + return this; + } + + /** + * Sets db.jdbc.driver_classname. + * + * @param dbJdbcDriverClassname The fully-qualified class name of the [Java Database Connectivity + * (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver used to + * connect. + */ + @Override + public DbMssqlSemanticConvention setDbJdbcDriverClassname(String dbJdbcDriverClassname) { + delegate.setAttribute("db.jdbc.driver_classname", dbJdbcDriverClassname); + return this; + } + + /** + * Sets db.name. + * + * @param dbName If no tech-specific attribute is defined, this attribute is used to report the + * name of the database being accessed. For commands that switch the database, this should be + * set to the target database (even if the command fails). + *
In some SQL databases, the database name to be used is called "schema name". + */ + @Override + public DbMssqlSemanticConvention setDbName(String dbName) { + delegate.setAttribute("db.name", dbName); + return this; + } + + /** + * Sets db.statement. + * + * @param dbStatement The database statement being executed. + *
The value may be sanitized to exclude sensitive information. + */ + @Override + public DbMssqlSemanticConvention setDbStatement(String dbStatement) { + delegate.setAttribute("db.statement", dbStatement); + return this; + } + + /** + * Sets db.operation. + * + * @param dbOperation The name of the operation being executed, e.g. the [MongoDB command + * name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as + * `findAndModify`. + *
While it would semantically make sense to set this, e.g., to a SQL keyword like `SELECT` + * or `INSERT`, it is not recommended to attempt any client-side parsing of `db.statement` + * just to get this property (the back end can do that if required). + */ + @Override + public DbMssqlSemanticConvention setDbOperation(String dbOperation) { + delegate.setAttribute("db.operation", dbOperation); + return this; + } + + /** + * Sets net.peer.name. + * + * @param netPeerName Remote hostname or similar, see note below. + */ + @Override + public DbMssqlSemanticConvention setNetPeerName(String netPeerName) { + delegate.setAttribute("net.peer.name", netPeerName); + return this; + } + + /** + * Sets net.peer.ip. + * + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or + * [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). + */ + @Override + public DbMssqlSemanticConvention setNetPeerIp(String netPeerIp) { + delegate.setAttribute("net.peer.ip", netPeerIp); + return this; + } + + /** + * Sets net.peer.port. + * + * @param netPeerPort Remote port number. + */ + @Override + public DbMssqlSemanticConvention setNetPeerPort(long netPeerPort) { + delegate.setAttribute("net.peer.port", netPeerPort); + return this; + } + + /** + * Sets net.transport. + * + * @param netTransport Transport protocol used. See note below. + */ + @Override + public DbMssqlSemanticConvention setNetTransport(String netTransport) { + delegate.setAttribute("net.transport", netTransport); + return this; + } + + /** + * Sets db.mssql.instance_name. + * + * @param dbMssqlInstanceName The Microsoft SQL Server [instance + * name](https://docs.microsoft.com/en-us/sql/connect/jdbc/building-the-connection-url?view=sql-server-ver15) + * connecting to. This name is used to determine the port of a named instance. + *
If setting a `db.mssql.instance_name`, `net.peer.port` is no longer required (but still + * recommended if non-standard). + */ + @Override + public DbMssqlSemanticConvention setDbMssqlInstanceName(String dbMssqlInstanceName) { + delegate.setAttribute("db.mssql.instance_name", dbMssqlInstanceName); + return this; + } + + /** Builder class for {@link DbMssqlSpan}. */ + public static class DbMssqlSpanBuilder { + // Protected because maybe we want to extend manually these classes + protected Span.Builder internalBuilder; + + protected DbMssqlSpanBuilder(Tracer tracer, String spanName) { + internalBuilder = tracer.spanBuilder(spanName); + } + + public DbMssqlSpanBuilder(Span.Builder spanBuilder) { + this.internalBuilder = spanBuilder; + } + + public Span.Builder getSpanBuilder() { + return this.internalBuilder; + } + + /** sets the {@link Span} parent. */ + public DbMssqlSpanBuilder setParent(Span parent) { + this.internalBuilder.setParent(parent); + return this; + } + + /** sets the {@link Span} parent. */ + public DbMssqlSpanBuilder setParent(SpanContext remoteParent) { + this.internalBuilder.setParent(remoteParent); + return this; + } + + /** this method sets the type of the {@link Span} is only available in the builder. */ + public DbMssqlSpanBuilder setKind(Span.Kind kind) { + internalBuilder.setSpanKind(kind); + return this; + } + + /** starts the span */ + public DbMssqlSpan start() { + // check for sampling relevant field here, but there are none. + return new DbMssqlSpan(this.internalBuilder.startSpan()); + } + + /** + * Sets db.system. + * + * @param dbSystem An identifier for the database management system (DBMS) product being used. + * See below for a list of well-known identifiers. + */ + public DbMssqlSpanBuilder setDbSystem(String dbSystem) { + internalBuilder.setAttribute("db.system", dbSystem); + return this; + } + + /** + * Sets db.connection_string. + * + * @param dbConnectionString The connection string used to connect to the database. + *
It is recommended to remove embedded credentials. + */ + public DbMssqlSpanBuilder setDbConnectionString(String dbConnectionString) { + internalBuilder.setAttribute("db.connection_string", dbConnectionString); + return this; + } + + /** + * Sets db.user. + * + * @param dbUser Username for accessing the database. + */ + public DbMssqlSpanBuilder setDbUser(String dbUser) { + internalBuilder.setAttribute("db.user", dbUser); + return this; + } + + /** + * Sets db.jdbc.driver_classname. + * + * @param dbJdbcDriverClassname The fully-qualified class name of the [Java Database + * Connectivity (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver + * used to connect. + */ + public DbMssqlSpanBuilder setDbJdbcDriverClassname(String dbJdbcDriverClassname) { + internalBuilder.setAttribute("db.jdbc.driver_classname", dbJdbcDriverClassname); + return this; + } + + /** + * Sets db.name. + * + * @param dbName If no tech-specific attribute is defined, this attribute is used to report the + * name of the database being accessed. For commands that switch the database, this should + * be set to the target database (even if the command fails). + *
In some SQL databases, the database name to be used is called "schema name". + */ + public DbMssqlSpanBuilder setDbName(String dbName) { + internalBuilder.setAttribute("db.name", dbName); + return this; + } + + /** + * Sets db.statement. + * + * @param dbStatement The database statement being executed. + *
The value may be sanitized to exclude sensitive information. + */ + public DbMssqlSpanBuilder setDbStatement(String dbStatement) { + internalBuilder.setAttribute("db.statement", dbStatement); + return this; + } + + /** + * Sets db.operation. + * + * @param dbOperation The name of the operation being executed, e.g. the [MongoDB command + * name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as + * `findAndModify`. + *
While it would semantically make sense to set this, e.g., to a SQL keyword like + * `SELECT` or `INSERT`, it is not recommended to attempt any client-side parsing of + * `db.statement` just to get this property (the back end can do that if required). + */ + public DbMssqlSpanBuilder setDbOperation(String dbOperation) { + internalBuilder.setAttribute("db.operation", dbOperation); + return this; + } + + /** + * Sets net.peer.name. + * + * @param netPeerName Remote hostname or similar, see note below. + */ + public DbMssqlSpanBuilder setNetPeerName(String netPeerName) { + internalBuilder.setAttribute("net.peer.name", netPeerName); + return this; + } + + /** + * Sets net.peer.ip. + * + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or + * [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). + */ + public DbMssqlSpanBuilder setNetPeerIp(String netPeerIp) { + internalBuilder.setAttribute("net.peer.ip", netPeerIp); + return this; + } + + /** + * Sets net.peer.port. + * + * @param netPeerPort Remote port number. + */ + public DbMssqlSpanBuilder setNetPeerPort(long netPeerPort) { + internalBuilder.setAttribute("net.peer.port", netPeerPort); + return this; + } + + /** + * Sets net.transport. + * + * @param netTransport Transport protocol used. See note below. + */ + public DbMssqlSpanBuilder setNetTransport(String netTransport) { + internalBuilder.setAttribute("net.transport", netTransport); + return this; + } + + /** + * Sets db.mssql.instance_name. + * + * @param dbMssqlInstanceName The Microsoft SQL Server [instance + * name](https://docs.microsoft.com/en-us/sql/connect/jdbc/building-the-connection-url?view=sql-server-ver15) + * connecting to. This name is used to determine the port of a named instance. + *
If setting a `db.mssql.instance_name`, `net.peer.port` is no longer required (but + * still recommended if non-standard). + */ + public DbMssqlSpanBuilder setDbMssqlInstanceName(String dbMssqlInstanceName) { + internalBuilder.setAttribute("db.mssql.instance_name", dbMssqlInstanceName); + return this; + } + } +} diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbRedisSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbRedisSemanticConvention.java new file mode 100644 index 0000000000..1b7a47da6d --- /dev/null +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbRedisSemanticConvention.java @@ -0,0 +1,125 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.opentelemetry.auto.typedspan; + +import io.opentelemetry.trace.Span; + +public interface DbRedisSemanticConvention { + void end(); + + Span getSpan(); + + /** + * Sets a value for db.system + * + * @param dbSystem An identifier for the database management system (DBMS) product being used. See + * below for a list of well-known identifiers.. + */ + public DbRedisSemanticConvention setDbSystem(String dbSystem); + + /** + * Sets a value for db.connection_string + * + * @param dbConnectionString The connection string used to connect to the database.. + *
It is recommended to remove embedded credentials. + */ + public DbRedisSemanticConvention setDbConnectionString(String dbConnectionString); + + /** + * Sets a value for db.user + * + * @param dbUser Username for accessing the database.. + */ + public DbRedisSemanticConvention setDbUser(String dbUser); + + /** + * Sets a value for db.jdbc.driver_classname + * + * @param dbJdbcDriverClassname The fully-qualified class name of the [Java Database Connectivity + * (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver used to + * connect.. + */ + public DbRedisSemanticConvention setDbJdbcDriverClassname(String dbJdbcDriverClassname); + + /** + * Sets a value for db.name + * + * @param dbName If no tech-specific attribute is defined, this attribute is used to report the + * name of the database being accessed. For commands that switch the database, this should be + * set to the target database (even if the command fails).. + *
In some SQL databases, the database name to be used is called "schema name". + */ + public DbRedisSemanticConvention setDbName(String dbName); + + /** + * Sets a value for db.statement + * + * @param dbStatement The database statement being executed.. + *
The value may be sanitized to exclude sensitive information. + */ + public DbRedisSemanticConvention setDbStatement(String dbStatement); + + /** + * Sets a value for db.operation + * + * @param dbOperation The name of the operation being executed, e.g. the [MongoDB command + * name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as + * `findAndModify`.. + *
While it would semantically make sense to set this, e.g., to a SQL keyword like `SELECT` + * or `INSERT`, it is not recommended to attempt any client-side parsing of `db.statement` + * just to get this property (the back end can do that if required). + */ + public DbRedisSemanticConvention setDbOperation(String dbOperation); + + /** + * Sets a value for net.peer.name + * + * @param netPeerName Remote hostname or similar, see note below.. + */ + public DbRedisSemanticConvention setNetPeerName(String netPeerName); + + /** + * Sets a value for net.peer.ip + * + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or + * [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). + */ + public DbRedisSemanticConvention setNetPeerIp(String netPeerIp); + + /** + * Sets a value for net.peer.port + * + * @param netPeerPort Remote port number.. + */ + public DbRedisSemanticConvention setNetPeerPort(long netPeerPort); + + /** + * Sets a value for net.transport + * + * @param netTransport Transport protocol used. See note below.. + */ + public DbRedisSemanticConvention setNetTransport(String netTransport); + + /** + * Sets a value for db.redis.database_index + * + * @param dbRedisDatabaseIndex The index of the database being accessed as used in the [`SELECT` + * command](https://redis.io/commands/select), provided as an integer. To be used instead of + * the generic `db.name` attribute.. + */ + public DbRedisSemanticConvention setDbRedisDatabaseIndex(long dbRedisDatabaseIndex); +} diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbRedisSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbRedisSpan.java new file mode 100644 index 0000000000..0810cb40c7 --- /dev/null +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbRedisSpan.java @@ -0,0 +1,388 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.opentelemetry.auto.typedspan; + +import io.opentelemetry.trace.Span; +import io.opentelemetry.trace.SpanContext; +import io.opentelemetry.trace.Tracer; + +public class DbRedisSpan extends DelegatingSpan implements DbRedisSemanticConvention { + + protected DbRedisSpan(Span span) { + super(span); + } + + /** + * Entry point to generate a {@link DbRedisSpan}. + * + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link DbRedisSpan} object. + */ + public static DbRedisSpanBuilder createDbRedisSpan(Tracer tracer, String spanName) { + return new DbRedisSpanBuilder(tracer, spanName); + } + + /** + * Creates a {@link DbRedisSpan} from a {@link DbSpan}. + * + * @param builder {@link DbSpan.DbSpanBuilder} to use. + * @return a {@link DbRedisSpan} object built from a {@link DbSpan}. + */ + public static DbRedisSpanBuilder createDbRedisSpan(DbSpan.DbSpanBuilder builder) { + // we accept a builder from Db since DbRedis "extends" Db + return new DbRedisSpanBuilder(builder.getSpanBuilder()); + } + + /** @return the Span used internally */ + @Override + public Span getSpan() { + return this.delegate; + } + + /** Terminates the Span. Here there is the checking for required attributes. */ + @Override + public void end() { + delegate.end(); + } + + /** + * Sets db.system. + * + * @param dbSystem An identifier for the database management system (DBMS) product being used. See + * below for a list of well-known identifiers. + */ + @Override + public DbRedisSemanticConvention setDbSystem(String dbSystem) { + delegate.setAttribute("db.system", dbSystem); + return this; + } + + /** + * Sets db.connection_string. + * + * @param dbConnectionString The connection string used to connect to the database. + *
It is recommended to remove embedded credentials. + */ + @Override + public DbRedisSemanticConvention setDbConnectionString(String dbConnectionString) { + delegate.setAttribute("db.connection_string", dbConnectionString); + return this; + } + + /** + * Sets db.user. + * + * @param dbUser Username for accessing the database. + */ + @Override + public DbRedisSemanticConvention setDbUser(String dbUser) { + delegate.setAttribute("db.user", dbUser); + return this; + } + + /** + * Sets db.jdbc.driver_classname. + * + * @param dbJdbcDriverClassname The fully-qualified class name of the [Java Database Connectivity + * (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver used to + * connect. + */ + @Override + public DbRedisSemanticConvention setDbJdbcDriverClassname(String dbJdbcDriverClassname) { + delegate.setAttribute("db.jdbc.driver_classname", dbJdbcDriverClassname); + return this; + } + + /** + * Sets db.name. + * + * @param dbName If no tech-specific attribute is defined, this attribute is used to report the + * name of the database being accessed. For commands that switch the database, this should be + * set to the target database (even if the command fails). + *
In some SQL databases, the database name to be used is called "schema name". + */ + @Override + public DbRedisSemanticConvention setDbName(String dbName) { + delegate.setAttribute("db.name", dbName); + return this; + } + + /** + * Sets db.statement. + * + * @param dbStatement The database statement being executed. + *
The value may be sanitized to exclude sensitive information. + */ + @Override + public DbRedisSemanticConvention setDbStatement(String dbStatement) { + delegate.setAttribute("db.statement", dbStatement); + return this; + } + + /** + * Sets db.operation. + * + * @param dbOperation The name of the operation being executed, e.g. the [MongoDB command + * name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as + * `findAndModify`. + *
While it would semantically make sense to set this, e.g., to a SQL keyword like `SELECT` + * or `INSERT`, it is not recommended to attempt any client-side parsing of `db.statement` + * just to get this property (the back end can do that if required). + */ + @Override + public DbRedisSemanticConvention setDbOperation(String dbOperation) { + delegate.setAttribute("db.operation", dbOperation); + return this; + } + + /** + * Sets net.peer.name. + * + * @param netPeerName Remote hostname or similar, see note below. + */ + @Override + public DbRedisSemanticConvention setNetPeerName(String netPeerName) { + delegate.setAttribute("net.peer.name", netPeerName); + return this; + } + + /** + * Sets net.peer.ip. + * + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or + * [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). + */ + @Override + public DbRedisSemanticConvention setNetPeerIp(String netPeerIp) { + delegate.setAttribute("net.peer.ip", netPeerIp); + return this; + } + + /** + * Sets net.peer.port. + * + * @param netPeerPort Remote port number. + */ + @Override + public DbRedisSemanticConvention setNetPeerPort(long netPeerPort) { + delegate.setAttribute("net.peer.port", netPeerPort); + return this; + } + + /** + * Sets net.transport. + * + * @param netTransport Transport protocol used. See note below. + */ + @Override + public DbRedisSemanticConvention setNetTransport(String netTransport) { + delegate.setAttribute("net.transport", netTransport); + return this; + } + + /** + * Sets db.redis.database_index. + * + * @param dbRedisDatabaseIndex The index of the database being accessed as used in the [`SELECT` + * command](https://redis.io/commands/select), provided as an integer. To be used instead of + * the generic `db.name` attribute. + */ + @Override + public DbRedisSemanticConvention setDbRedisDatabaseIndex(long dbRedisDatabaseIndex) { + delegate.setAttribute("db.redis.database_index", dbRedisDatabaseIndex); + return this; + } + + /** Builder class for {@link DbRedisSpan}. */ + public static class DbRedisSpanBuilder { + // Protected because maybe we want to extend manually these classes + protected Span.Builder internalBuilder; + + protected DbRedisSpanBuilder(Tracer tracer, String spanName) { + internalBuilder = tracer.spanBuilder(spanName); + } + + public DbRedisSpanBuilder(Span.Builder spanBuilder) { + this.internalBuilder = spanBuilder; + } + + public Span.Builder getSpanBuilder() { + return this.internalBuilder; + } + + /** sets the {@link Span} parent. */ + public DbRedisSpanBuilder setParent(Span parent) { + this.internalBuilder.setParent(parent); + return this; + } + + /** sets the {@link Span} parent. */ + public DbRedisSpanBuilder setParent(SpanContext remoteParent) { + this.internalBuilder.setParent(remoteParent); + return this; + } + + /** this method sets the type of the {@link Span} is only available in the builder. */ + public DbRedisSpanBuilder setKind(Span.Kind kind) { + internalBuilder.setSpanKind(kind); + return this; + } + + /** starts the span */ + public DbRedisSpan start() { + // check for sampling relevant field here, but there are none. + return new DbRedisSpan(this.internalBuilder.startSpan()); + } + + /** + * Sets db.system. + * + * @param dbSystem An identifier for the database management system (DBMS) product being used. + * See below for a list of well-known identifiers. + */ + public DbRedisSpanBuilder setDbSystem(String dbSystem) { + internalBuilder.setAttribute("db.system", dbSystem); + return this; + } + + /** + * Sets db.connection_string. + * + * @param dbConnectionString The connection string used to connect to the database. + *
It is recommended to remove embedded credentials. + */ + public DbRedisSpanBuilder setDbConnectionString(String dbConnectionString) { + internalBuilder.setAttribute("db.connection_string", dbConnectionString); + return this; + } + + /** + * Sets db.user. + * + * @param dbUser Username for accessing the database. + */ + public DbRedisSpanBuilder setDbUser(String dbUser) { + internalBuilder.setAttribute("db.user", dbUser); + return this; + } + + /** + * Sets db.jdbc.driver_classname. + * + * @param dbJdbcDriverClassname The fully-qualified class name of the [Java Database + * Connectivity (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver + * used to connect. + */ + public DbRedisSpanBuilder setDbJdbcDriverClassname(String dbJdbcDriverClassname) { + internalBuilder.setAttribute("db.jdbc.driver_classname", dbJdbcDriverClassname); + return this; + } + + /** + * Sets db.name. + * + * @param dbName If no tech-specific attribute is defined, this attribute is used to report the + * name of the database being accessed. For commands that switch the database, this should + * be set to the target database (even if the command fails). + *
In some SQL databases, the database name to be used is called "schema name". + */ + public DbRedisSpanBuilder setDbName(String dbName) { + internalBuilder.setAttribute("db.name", dbName); + return this; + } + + /** + * Sets db.statement. + * + * @param dbStatement The database statement being executed. + *
The value may be sanitized to exclude sensitive information. + */ + public DbRedisSpanBuilder setDbStatement(String dbStatement) { + internalBuilder.setAttribute("db.statement", dbStatement); + return this; + } + + /** + * Sets db.operation. + * + * @param dbOperation The name of the operation being executed, e.g. the [MongoDB command + * name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as + * `findAndModify`. + *
While it would semantically make sense to set this, e.g., to a SQL keyword like + * `SELECT` or `INSERT`, it is not recommended to attempt any client-side parsing of + * `db.statement` just to get this property (the back end can do that if required). + */ + public DbRedisSpanBuilder setDbOperation(String dbOperation) { + internalBuilder.setAttribute("db.operation", dbOperation); + return this; + } + + /** + * Sets net.peer.name. + * + * @param netPeerName Remote hostname or similar, see note below. + */ + public DbRedisSpanBuilder setNetPeerName(String netPeerName) { + internalBuilder.setAttribute("net.peer.name", netPeerName); + return this; + } + + /** + * Sets net.peer.ip. + * + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or + * [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). + */ + public DbRedisSpanBuilder setNetPeerIp(String netPeerIp) { + internalBuilder.setAttribute("net.peer.ip", netPeerIp); + return this; + } + + /** + * Sets net.peer.port. + * + * @param netPeerPort Remote port number. + */ + public DbRedisSpanBuilder setNetPeerPort(long netPeerPort) { + internalBuilder.setAttribute("net.peer.port", netPeerPort); + return this; + } + + /** + * Sets net.transport. + * + * @param netTransport Transport protocol used. See note below. + */ + public DbRedisSpanBuilder setNetTransport(String netTransport) { + internalBuilder.setAttribute("net.transport", netTransport); + return this; + } + + /** + * Sets db.redis.database_index. + * + * @param dbRedisDatabaseIndex The index of the database being accessed as used in the [`SELECT` + * command](https://redis.io/commands/select), provided as an integer. To be used instead of + * the generic `db.name` attribute. + */ + public DbRedisSpanBuilder setDbRedisDatabaseIndex(long dbRedisDatabaseIndex) { + internalBuilder.setAttribute("db.redis.database_index", dbRedisDatabaseIndex); + return this; + } + } +} diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbSemanticConvention.java new file mode 100644 index 0000000000..d2e8c0a689 --- /dev/null +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbSemanticConvention.java @@ -0,0 +1,116 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.opentelemetry.auto.typedspan; + +import io.opentelemetry.trace.Span; + +public interface DbSemanticConvention { + void end(); + + Span getSpan(); + + /** + * Sets a value for db.system + * + * @param dbSystem An identifier for the database management system (DBMS) product being used. See + * below for a list of well-known identifiers.. + */ + public DbSemanticConvention setDbSystem(String dbSystem); + + /** + * Sets a value for db.connection_string + * + * @param dbConnectionString The connection string used to connect to the database.. + *
It is recommended to remove embedded credentials. + */ + public DbSemanticConvention setDbConnectionString(String dbConnectionString); + + /** + * Sets a value for db.user + * + * @param dbUser Username for accessing the database.. + */ + public DbSemanticConvention setDbUser(String dbUser); + + /** + * Sets a value for db.jdbc.driver_classname + * + * @param dbJdbcDriverClassname The fully-qualified class name of the [Java Database Connectivity + * (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver used to + * connect.. + */ + public DbSemanticConvention setDbJdbcDriverClassname(String dbJdbcDriverClassname); + + /** + * Sets a value for db.name + * + * @param dbName If no tech-specific attribute is defined, this attribute is used to report the + * name of the database being accessed. For commands that switch the database, this should be + * set to the target database (even if the command fails).. + *
In some SQL databases, the database name to be used is called "schema name". + */ + public DbSemanticConvention setDbName(String dbName); + + /** + * Sets a value for db.statement + * + * @param dbStatement The database statement being executed.. + *
The value may be sanitized to exclude sensitive information. + */ + public DbSemanticConvention setDbStatement(String dbStatement); + + /** + * Sets a value for db.operation + * + * @param dbOperation The name of the operation being executed, e.g. the [MongoDB command + * name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as + * `findAndModify`.. + *
While it would semantically make sense to set this, e.g., to a SQL keyword like `SELECT` + * or `INSERT`, it is not recommended to attempt any client-side parsing of `db.statement` + * just to get this property (the back end can do that if required). + */ + public DbSemanticConvention setDbOperation(String dbOperation); + + /** + * Sets a value for net.peer.name + * + * @param netPeerName Remote hostname or similar, see note below.. + */ + public DbSemanticConvention setNetPeerName(String netPeerName); + + /** + * Sets a value for net.peer.ip + * + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or + * [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). + */ + public DbSemanticConvention setNetPeerIp(String netPeerIp); + + /** + * Sets a value for net.peer.port + * + * @param netPeerPort Remote port number.. + */ + public DbSemanticConvention setNetPeerPort(long netPeerPort); + + /** + * Sets a value for net.transport + * + * @param netTransport Transport protocol used. See note below.. + */ + public DbSemanticConvention setNetTransport(String netTransport); +} diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbSpan.java new file mode 100644 index 0000000000..4921c225d2 --- /dev/null +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbSpan.java @@ -0,0 +1,352 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.opentelemetry.auto.typedspan; + +import io.opentelemetry.trace.Span; +import io.opentelemetry.trace.SpanContext; +import io.opentelemetry.trace.Tracer; + +public class DbSpan extends DelegatingSpan implements DbSemanticConvention { + + protected DbSpan(Span span) { + super(span); + } + + /** + * Entry point to generate a {@link DbSpan}. + * + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link DbSpan} object. + */ + public static DbSpanBuilder createDbSpan(Tracer tracer, String spanName) { + return new DbSpanBuilder(tracer, spanName).setKind(Span.Kind.CLIENT); + } + + /** @return the Span used internally */ + @Override + public Span getSpan() { + return this.delegate; + } + + /** Terminates the Span. Here there is the checking for required attributes. */ + @Override + public void end() { + delegate.end(); + } + + /** + * Sets db.system. + * + * @param dbSystem An identifier for the database management system (DBMS) product being used. See + * below for a list of well-known identifiers. + */ + @Override + public DbSemanticConvention setDbSystem(String dbSystem) { + delegate.setAttribute("db.system", dbSystem); + return this; + } + + /** + * Sets db.connection_string. + * + * @param dbConnectionString The connection string used to connect to the database. + *
It is recommended to remove embedded credentials. + */ + @Override + public DbSemanticConvention setDbConnectionString(String dbConnectionString) { + delegate.setAttribute("db.connection_string", dbConnectionString); + return this; + } + + /** + * Sets db.user. + * + * @param dbUser Username for accessing the database. + */ + @Override + public DbSemanticConvention setDbUser(String dbUser) { + delegate.setAttribute("db.user", dbUser); + return this; + } + + /** + * Sets db.jdbc.driver_classname. + * + * @param dbJdbcDriverClassname The fully-qualified class name of the [Java Database Connectivity + * (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver used to + * connect. + */ + @Override + public DbSemanticConvention setDbJdbcDriverClassname(String dbJdbcDriverClassname) { + delegate.setAttribute("db.jdbc.driver_classname", dbJdbcDriverClassname); + return this; + } + + /** + * Sets db.name. + * + * @param dbName If no tech-specific attribute is defined, this attribute is used to report the + * name of the database being accessed. For commands that switch the database, this should be + * set to the target database (even if the command fails). + *
In some SQL databases, the database name to be used is called "schema name". + */ + @Override + public DbSemanticConvention setDbName(String dbName) { + delegate.setAttribute("db.name", dbName); + return this; + } + + /** + * Sets db.statement. + * + * @param dbStatement The database statement being executed. + *
The value may be sanitized to exclude sensitive information. + */ + @Override + public DbSemanticConvention setDbStatement(String dbStatement) { + delegate.setAttribute("db.statement", dbStatement); + return this; + } + + /** + * Sets db.operation. + * + * @param dbOperation The name of the operation being executed, e.g. the [MongoDB command + * name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as + * `findAndModify`. + *
While it would semantically make sense to set this, e.g., to a SQL keyword like `SELECT` + * or `INSERT`, it is not recommended to attempt any client-side parsing of `db.statement` + * just to get this property (the back end can do that if required). + */ + @Override + public DbSemanticConvention setDbOperation(String dbOperation) { + delegate.setAttribute("db.operation", dbOperation); + return this; + } + + /** + * Sets net.peer.name. + * + * @param netPeerName Remote hostname or similar, see note below. + */ + @Override + public DbSemanticConvention setNetPeerName(String netPeerName) { + delegate.setAttribute("net.peer.name", netPeerName); + return this; + } + + /** + * Sets net.peer.ip. + * + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or + * [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). + */ + @Override + public DbSemanticConvention setNetPeerIp(String netPeerIp) { + delegate.setAttribute("net.peer.ip", netPeerIp); + return this; + } + + /** + * Sets net.peer.port. + * + * @param netPeerPort Remote port number. + */ + @Override + public DbSemanticConvention setNetPeerPort(long netPeerPort) { + delegate.setAttribute("net.peer.port", netPeerPort); + return this; + } + + /** + * Sets net.transport. + * + * @param netTransport Transport protocol used. See note below. + */ + @Override + public DbSemanticConvention setNetTransport(String netTransport) { + delegate.setAttribute("net.transport", netTransport); + return this; + } + + /** Builder class for {@link DbSpan}. */ + public static class DbSpanBuilder { + // Protected because maybe we want to extend manually these classes + protected Span.Builder internalBuilder; + + protected DbSpanBuilder(Tracer tracer, String spanName) { + internalBuilder = tracer.spanBuilder(spanName); + } + + public DbSpanBuilder(Span.Builder spanBuilder) { + this.internalBuilder = spanBuilder; + } + + public Span.Builder getSpanBuilder() { + return this.internalBuilder; + } + + /** sets the {@link Span} parent. */ + public DbSpanBuilder setParent(Span parent) { + this.internalBuilder.setParent(parent); + return this; + } + + /** sets the {@link Span} parent. */ + public DbSpanBuilder setParent(SpanContext remoteParent) { + this.internalBuilder.setParent(remoteParent); + return this; + } + + /** this method sets the type of the {@link Span} is only available in the builder. */ + public DbSpanBuilder setKind(Span.Kind kind) { + internalBuilder.setSpanKind(kind); + return this; + } + + /** starts the span */ + public DbSpan start() { + // check for sampling relevant field here, but there are none. + return new DbSpan(this.internalBuilder.startSpan()); + } + + /** + * Sets db.system. + * + * @param dbSystem An identifier for the database management system (DBMS) product being used. + * See below for a list of well-known identifiers. + */ + public DbSpanBuilder setDbSystem(String dbSystem) { + internalBuilder.setAttribute("db.system", dbSystem); + return this; + } + + /** + * Sets db.connection_string. + * + * @param dbConnectionString The connection string used to connect to the database. + *
It is recommended to remove embedded credentials. + */ + public DbSpanBuilder setDbConnectionString(String dbConnectionString) { + internalBuilder.setAttribute("db.connection_string", dbConnectionString); + return this; + } + + /** + * Sets db.user. + * + * @param dbUser Username for accessing the database. + */ + public DbSpanBuilder setDbUser(String dbUser) { + internalBuilder.setAttribute("db.user", dbUser); + return this; + } + + /** + * Sets db.jdbc.driver_classname. + * + * @param dbJdbcDriverClassname The fully-qualified class name of the [Java Database + * Connectivity (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver + * used to connect. + */ + public DbSpanBuilder setDbJdbcDriverClassname(String dbJdbcDriverClassname) { + internalBuilder.setAttribute("db.jdbc.driver_classname", dbJdbcDriverClassname); + return this; + } + + /** + * Sets db.name. + * + * @param dbName If no tech-specific attribute is defined, this attribute is used to report the + * name of the database being accessed. For commands that switch the database, this should + * be set to the target database (even if the command fails). + *
In some SQL databases, the database name to be used is called "schema name". + */ + public DbSpanBuilder setDbName(String dbName) { + internalBuilder.setAttribute("db.name", dbName); + return this; + } + + /** + * Sets db.statement. + * + * @param dbStatement The database statement being executed. + *
The value may be sanitized to exclude sensitive information. + */ + public DbSpanBuilder setDbStatement(String dbStatement) { + internalBuilder.setAttribute("db.statement", dbStatement); + return this; + } + + /** + * Sets db.operation. + * + * @param dbOperation The name of the operation being executed, e.g. the [MongoDB command + * name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as + * `findAndModify`. + *
While it would semantically make sense to set this, e.g., to a SQL keyword like + * `SELECT` or `INSERT`, it is not recommended to attempt any client-side parsing of + * `db.statement` just to get this property (the back end can do that if required). + */ + public DbSpanBuilder setDbOperation(String dbOperation) { + internalBuilder.setAttribute("db.operation", dbOperation); + return this; + } + + /** + * Sets net.peer.name. + * + * @param netPeerName Remote hostname or similar, see note below. + */ + public DbSpanBuilder setNetPeerName(String netPeerName) { + internalBuilder.setAttribute("net.peer.name", netPeerName); + return this; + } + + /** + * Sets net.peer.ip. + * + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or + * [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). + */ + public DbSpanBuilder setNetPeerIp(String netPeerIp) { + internalBuilder.setAttribute("net.peer.ip", netPeerIp); + return this; + } + + /** + * Sets net.peer.port. + * + * @param netPeerPort Remote port number. + */ + public DbSpanBuilder setNetPeerPort(long netPeerPort) { + internalBuilder.setAttribute("net.peer.port", netPeerPort); + return this; + } + + /** + * Sets net.transport. + * + * @param netTransport Transport protocol used. See note below. + */ + public DbSpanBuilder setNetTransport(String netTransport) { + internalBuilder.setAttribute("net.transport", netTransport); + return this; + } + } +} diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DelegatingSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DelegatingSpan.java new file mode 100644 index 0000000000..0274b4ec8d --- /dev/null +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DelegatingSpan.java @@ -0,0 +1,118 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.opentelemetry.auto.typedspan; + +import io.opentelemetry.common.AttributeValue; +import io.opentelemetry.common.Attributes; +import io.opentelemetry.trace.EndSpanOptions; +import io.opentelemetry.trace.Event; +import io.opentelemetry.trace.Span; +import io.opentelemetry.trace.SpanContext; +import io.opentelemetry.trace.Status; + +public class DelegatingSpan implements Span { + protected final Span delegate; + + public DelegatingSpan(final Span delegate) { + this.delegate = delegate; + } + + @Override + public void setAttribute(final String key, final String value) { + delegate.setAttribute(key, value); + } + + @Override + public void setAttribute(final String key, final long value) { + delegate.setAttribute(key, value); + } + + @Override + public void setAttribute(final String key, final double value) { + delegate.setAttribute(key, value); + } + + @Override + public void setAttribute(final String key, final boolean value) { + delegate.setAttribute(key, value); + } + + @Override + public void setAttribute(final String key, final AttributeValue value) { + delegate.setAttribute(key, value); + } + + @Override + public void addEvent(final String name) { + delegate.addEvent(name); + } + + @Override + public void addEvent(final String name, final long timestamp) { + delegate.addEvent(name, timestamp); + } + + @Override + public void addEvent(String name, Attributes attributes) { + delegate.addEvent(name, attributes); + } + + @Override + public void addEvent(String name, Attributes attributes, long timestamp) { + delegate.addEvent(name, attributes, timestamp); + } + + @Override + public void addEvent(final Event event) { + delegate.addEvent(event); + } + + @Override + public void addEvent(final Event event, final long timestamp) { + delegate.addEvent(event, timestamp); + } + + @Override + public void setStatus(final Status status) { + delegate.setStatus(status); + } + + @Override + public void updateName(final String name) { + delegate.updateName(name); + } + + @Override + public void end() { + delegate.end(); + } + + @Override + public void end(final EndSpanOptions endOptions) { + delegate.end(endOptions); + } + + @Override + public SpanContext getContext() { + return delegate.getContext(); + } + + @Override + public boolean isRecording() { + return delegate.isRecording(); + } +} diff --git a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/Constants.java b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/Constants.java index 8ef9a431bb..b363cd3786 100644 --- a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/Constants.java +++ b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/Constants.java @@ -35,7 +35,8 @@ public final class Constants { "io.opentelemetry.auto.config", "io.opentelemetry.auto.bootstrap", "io.opentelemetry.auto.instrumentation.api", - "io.opentelemetry.auto.shaded" + "io.opentelemetry.auto.shaded", + "io.opentelemetry.auto.typedspan", }; // This is used in IntegrationTestUtils.java diff --git a/testing-common/src/main/groovy/io/opentelemetry/auto/test/SpockRunner.java b/testing-common/src/main/groovy/io/opentelemetry/auto/test/SpockRunner.java index c03ac3e3f7..9c6b8960f7 100644 --- a/testing-common/src/main/groovy/io/opentelemetry/auto/test/SpockRunner.java +++ b/testing-common/src/main/groovy/io/opentelemetry/auto/test/SpockRunner.java @@ -52,7 +52,8 @@ public class SpockRunner extends Sputnik { "io.opentelemetry.auto.config", "io.opentelemetry.auto.bootstrap", "io.opentelemetry.auto.instrumentation.api", - "io.opentelemetry.auto.shaded" + "io.opentelemetry.auto.shaded", + "io.opentelemetry.auto.typedspan", }; private static final String[] TEST_BOOTSTRAP_PREFIXES;