From f117a8b66a46edc8529213a3f9b952f5868d8c87 Mon Sep 17 00:00:00 2001 From: Giovanni Liva Date: Sat, 18 Jul 2020 16:51:05 +0200 Subject: [PATCH] Address feedback of @iNikem --- .../DbCassandraSemanticConvention.java | 61 +-- .../auto/typedspan/DbCassandraSpan.java | 233 +++------ .../typedspan/DbHbaseSemanticConvention.java | 61 +-- .../auto/typedspan/DbHbaseSpan.java | 233 +++------ .../typedspan/DbJdbcSemanticConvention.java | 96 ++++ .../auto/typedspan/DbJdbcSpan.java | 458 +++++++++++++++++ .../DbMongodbSemanticConvention.java | 61 +-- .../auto/typedspan/DbMongodbSpan.java | 233 +++------ .../typedspan/DbMysqlSemanticConvention.java | 97 ++++ .../auto/typedspan/DbMysqlSpan.java | 460 ++++++++++++++++++ .../typedspan/DbRedisSemanticConvention.java | 62 +-- .../auto/typedspan/DbRedisSpan.java | 236 +++------ .../auto/typedspan/DbSemanticConvention.java | 57 +-- .../opentelemetry/auto/typedspan/DbSpan.java | 213 +++----- .../auto/typedspan/DelegatingSpan.java | 6 +- .../FaasDatasourceSemanticConvention.java | 26 +- .../auto/typedspan/FaasDatasourceSpan.java | 122 ++--- .../typedspan/FaasHttpSemanticConvention.java | 61 +-- .../auto/typedspan/FaasHttpSpan.java | 241 +++------ .../FaasPubsubSemanticConvention.java | 52 +- .../auto/typedspan/FaasPubsubSpan.java | 215 +++----- .../typedspan/FaasSemanticConvention.java | 6 +- .../auto/typedspan/FaasSpan.java | 56 ++- .../FaasTimerSemanticConvention.java | 15 +- .../auto/typedspan/FaasTimerSpan.java | 89 ++-- .../GrpcClientSemanticConvention.java | 15 +- .../auto/typedspan/GrpcClientSpan.java | 106 ++-- .../GrpcServerSemanticConvention.java | 15 +- .../auto/typedspan/GrpcServerSpan.java | 106 ++-- .../HttpClientSemanticConvention.java | 40 +- .../auto/typedspan/HttpClientSpan.java | 189 +++---- .../typedspan/HttpSemanticConvention.java | 40 +- .../HttpServerSemanticConvention.java | 59 +-- .../auto/typedspan/HttpServerSpan.java | 231 +++------ .../auto/typedspan/HttpSpan.java | 161 +++--- .../typedspan/IdentitySemanticConvention.java | 17 +- .../auto/typedspan/IdentitySpan.java | 70 ++- .../MessagingConsumerSemanticConvention.java | 66 +-- .../auto/typedspan/MessagingConsumerSpan.java | 236 ++++----- ...ConsumerSynchronousSemanticConvention.java | 79 +-- .../MessagingConsumerSynchronousSpan.java | 269 ++++------ .../MessagingProducerSemanticConvention.java | 62 +-- .../auto/typedspan/MessagingProducerSpan.java | 228 +++------ ...ProducerSynchronousSemanticConvention.java | 72 +-- .../MessagingProducerSynchronousSpan.java | 253 ++++------ .../MessagingSemanticConvention.java | 50 +- .../auto/typedspan/MessagingSpan.java | 189 +++---- .../typedspan/NetworkSemanticConvention.java | 14 +- .../auto/typedspan/NetworkSpan.java | 88 ++-- .../auto/typedspan/RpcSemanticConvention.java | 15 +- .../opentelemetry/auto/typedspan/RpcSpan.java | 97 ++-- .../typedspan/HttpTypedSpanExampleTest.java | 6 +- 52 files changed, 2772 insertions(+), 3451 deletions(-) create mode 100644 agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbJdbcSemanticConvention.java create mode 100644 agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbJdbcSpan.java create mode 100644 agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMysqlSemanticConvention.java create mode 100644 agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMysqlSpan.java 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 index 05c66a61762e..1c5a4a3ffc37 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbCassandraSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbCassandraSemanticConvention.java @@ -22,112 +22,75 @@ public interface DbCassandraSemanticConvention { 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.. + * @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. + *

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.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 DbCassandraSemanticConvention setDbMssqlInstanceName(String dbMssqlInstanceName); - - /** - * Sets a value for db.jdbc.driver_classname - * - * @param dbJdbcDriverClassname The fully-qualified class name of the 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". + * @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. + *

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). + * @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). + * @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.. + * @param dbCassandraKeyspace The name of the keyspace being accessed. To be used instead of the generic `db.name` attribute.. */ public DbCassandraSemanticConvention setDbCassandraKeyspace(String dbCassandraKeyspace); -} + +} \ No newline at end of file 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 index fc60ec94ff26..16e0fb9e8798 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbCassandraSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbCassandraSpan.java @@ -24,25 +24,18 @@ * Required attributes: * *

* * Conditional attributes: * * @@ -63,8 +56,6 @@ enum AttributeStatus { DB_SYSTEM, DB_CONNECTION_STRING, DB_USER, - DB_MSSQL_INSTANCE_NAME, - DB_JDBC_DRIVER_CLASSNAME, DB_NAME, DB_STATEMENT, DB_OPERATION, @@ -73,6 +64,7 @@ enum AttributeStatus { NET_PEER_PORT, NET_TRANSPORT, DB_CASSANDRA_KEYSPACE; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -100,7 +92,6 @@ public long getValue() { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(DbCassandraSpan.class.getName()); - public final AttributeStatus status; protected DbCassandraSpan(Span span, AttributeStatus status) { @@ -108,25 +99,23 @@ protected DbCassandraSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * 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) { + /** + * 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 createDbCassandraSpanBuilder(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 + * 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 createDbCassandraSpanBuilder(DbSpan.DbSpanBuilder builder) { + // we accept a builder from Db since DbCassandra "extends" Db return new DbCassandraSpanBuilder(builder.getSpanBuilder(), builder.status.getValue()); } @@ -152,8 +141,8 @@ public void end() { // extra constraints. { boolean flag = - (!this.status.isSet(AttributeStatus.NET_PEER_NAME)) - || (!this.status.isSet(AttributeStatus.NET_PEER_IP)); + (!this.status.isSet(AttributeStatus.NET_PEER_NAME) ) || + (!this.status.isSet(AttributeStatus.NET_PEER_IP) ) ; if (flag) { logger.info("Constraint not respected!"); } @@ -182,11 +171,10 @@ public void 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.. + * @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) { @@ -197,9 +185,8 @@ public DbCassandraSemanticConvention setDbSystem(String dbSystem) { /** * Sets db.connection_string. - * - * @param dbConnectionString The connection string used to connect to the database.. - *

It is recommended to remove embedded credentials. + * @param dbConnectionString The connection string used to connect to the database. + *

It is recommended to remove embedded credentials. */ @Override public DbCassandraSemanticConvention setDbConnectionString(String dbConnectionString) { @@ -210,8 +197,7 @@ public DbCassandraSemanticConvention setDbConnectionString(String dbConnectionSt /** * Sets db.user. - * - * @param dbUser Username for accessing the database.. + * @param dbUser Username for accessing the database. */ @Override public DbCassandraSemanticConvention setDbUser(String dbUser) { @@ -220,42 +206,10 @@ public DbCassandraSemanticConvention setDbUser(String dbUser) { 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 DbCassandraSemanticConvention setDbMssqlInstanceName(String dbMssqlInstanceName) { - status.set(AttributeStatus.DB_MSSQL_INSTANCE_NAME); - delegate.setAttribute("db.mssql.instance_name", dbMssqlInstanceName); - return this; - } - - /** - * Sets db.jdbc.driver_classname. - * - * @param dbJdbcDriverClassname The fully-qualified class name of the JDBC driver used to - * connect.. - */ - @Override - public DbCassandraSemanticConvention setDbJdbcDriverClassname(String dbJdbcDriverClassname) { - status.set(AttributeStatus.DB_JDBC_DRIVER_CLASSNAME); - 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". + * @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) { @@ -266,9 +220,8 @@ public DbCassandraSemanticConvention setDbName(String dbName) { /** * Sets db.statement. - * - * @param dbStatement The database statement being executed.. - *

The value may be sanitized to exclude sensitive information. + * @param dbStatement The database statement being executed. + *

The value may be sanitized to exclude sensitive information. */ @Override public DbCassandraSemanticConvention setDbStatement(String dbStatement) { @@ -279,13 +232,8 @@ public DbCassandraSemanticConvention setDbStatement(String dbStatement) { /** * 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). + * @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) { @@ -296,8 +244,7 @@ public DbCassandraSemanticConvention setDbOperation(String dbOperation) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ @Override public DbCassandraSemanticConvention setNetPeerName(String netPeerName) { @@ -308,9 +255,7 @@ public DbCassandraSemanticConvention setNetPeerName(String netPeerName) { /** * 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). + * @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) { @@ -321,8 +266,7 @@ public DbCassandraSemanticConvention setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ @Override public DbCassandraSemanticConvention setNetPeerPort(long netPeerPort) { @@ -333,8 +277,7 @@ public DbCassandraSemanticConvention setNetPeerPort(long netPeerPort) { /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ @Override public DbCassandraSemanticConvention setNetTransport(String netTransport) { @@ -345,9 +288,7 @@ public DbCassandraSemanticConvention setNetTransport(String netTransport) { /** * Sets db.cassandra.keyspace. - * - * @param dbCassandraKeyspace The name of the keyspace being accessed. To be used instead of the - * generic `db.name` attribute.. + * @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) { @@ -356,39 +297,42 @@ public DbCassandraSemanticConvention setDbCassandraKeyspace(String dbCassandraKe return this; } - /** Builder class for {@link DbCassandraSpan}. */ - public static class DbCassandraSpanBuilder { + + /** + * Builder class for {@link DbCassandraSpan}. + */ + public static class DbCassandraSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected DbCassandraSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public DbCassandraSpanBuilder(Builder spanBuilder, long attributes) { + public DbCassandraSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public DbCassandraSpanBuilder setParent(Span parent) { + public DbCassandraSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public DbCassandraSpanBuilder setParent(SpanContext remoteParent) { + 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(Kind kind) { + public DbCassandraSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -399,11 +343,10 @@ public DbCassandraSpan start() { return new DbCassandraSpan(this.internalBuilder.startSpan(), status); } + /** * 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.. + * @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) { status.set(AttributeStatus.DB_SYSTEM); @@ -413,9 +356,8 @@ public DbCassandraSpanBuilder setDbSystem(String dbSystem) { /** * Sets db.connection_string. - * - * @param dbConnectionString The connection string used to connect to the database.. - *

It is recommended to remove embedded credentials. + * @param dbConnectionString The connection string used to connect to the database. + *

It is recommended to remove embedded credentials. */ public DbCassandraSpanBuilder setDbConnectionString(String dbConnectionString) { status.set(AttributeStatus.DB_CONNECTION_STRING); @@ -425,8 +367,7 @@ public DbCassandraSpanBuilder setDbConnectionString(String dbConnectionString) { /** * Sets db.user. - * - * @param dbUser Username for accessing the database.. + * @param dbUser Username for accessing the database. */ public DbCassandraSpanBuilder setDbUser(String dbUser) { status.set(AttributeStatus.DB_USER); @@ -434,40 +375,10 @@ public DbCassandraSpanBuilder setDbUser(String dbUser) { 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 DbCassandraSpanBuilder setDbMssqlInstanceName(String dbMssqlInstanceName) { - status.set(AttributeStatus.DB_MSSQL_INSTANCE_NAME); - internalBuilder.setAttribute("db.mssql.instance_name", dbMssqlInstanceName); - return this; - } - - /** - * Sets db.jdbc.driver_classname. - * - * @param dbJdbcDriverClassname The fully-qualified class name of the JDBC driver used to - * connect.. - */ - public DbCassandraSpanBuilder setDbJdbcDriverClassname(String dbJdbcDriverClassname) { - status.set(AttributeStatus.DB_JDBC_DRIVER_CLASSNAME); - 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". + * @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) { status.set(AttributeStatus.DB_NAME); @@ -477,9 +388,8 @@ public DbCassandraSpanBuilder setDbName(String dbName) { /** * Sets db.statement. - * - * @param dbStatement The database statement being executed.. - *

The value may be sanitized to exclude sensitive information. + * @param dbStatement The database statement being executed. + *

The value may be sanitized to exclude sensitive information. */ public DbCassandraSpanBuilder setDbStatement(String dbStatement) { status.set(AttributeStatus.DB_STATEMENT); @@ -489,13 +399,8 @@ public DbCassandraSpanBuilder setDbStatement(String dbStatement) { /** * 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). + * @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) { status.set(AttributeStatus.DB_OPERATION); @@ -505,8 +410,7 @@ public DbCassandraSpanBuilder setDbOperation(String dbOperation) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ public DbCassandraSpanBuilder setNetPeerName(String netPeerName) { status.set(AttributeStatus.NET_PEER_NAME); @@ -516,9 +420,7 @@ public DbCassandraSpanBuilder setNetPeerName(String netPeerName) { /** * 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). + * @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) { status.set(AttributeStatus.NET_PEER_IP); @@ -528,8 +430,7 @@ public DbCassandraSpanBuilder setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ public DbCassandraSpanBuilder setNetPeerPort(long netPeerPort) { status.set(AttributeStatus.NET_PEER_PORT); @@ -539,8 +440,7 @@ public DbCassandraSpanBuilder setNetPeerPort(long netPeerPort) { /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ public DbCassandraSpanBuilder setNetTransport(String netTransport) { status.set(AttributeStatus.NET_TRANSPORT); @@ -550,14 +450,13 @@ public DbCassandraSpanBuilder setNetTransport(String netTransport) { /** * Sets db.cassandra.keyspace. - * - * @param dbCassandraKeyspace The name of the keyspace being accessed. To be used instead of the - * generic `db.name` attribute.. + * @param dbCassandraKeyspace The name of the keyspace being accessed. To be used instead of the generic `db.name` attribute. */ public DbCassandraSpanBuilder setDbCassandraKeyspace(String dbCassandraKeyspace) { status.set(AttributeStatus.DB_CASSANDRA_KEYSPACE); internalBuilder.setAttribute("db.cassandra.keyspace", dbCassandraKeyspace); return this; } + } -} +} \ No newline at end of file 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 index f5b286d1f91a..7a6cc9132a03 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbHbaseSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbHbaseSemanticConvention.java @@ -22,112 +22,75 @@ public interface DbHbaseSemanticConvention { 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.. + * @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. + *

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.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 DbHbaseSemanticConvention setDbMssqlInstanceName(String dbMssqlInstanceName); - - /** - * Sets a value for db.jdbc.driver_classname - * - * @param dbJdbcDriverClassname The fully-qualified class name of the 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". + * @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. + *

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). + * @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). + * @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.. + * @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); -} + +} \ No newline at end of file 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 index bbd4c9491299..06a680815e17 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbHbaseSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbHbaseSpan.java @@ -24,25 +24,18 @@ * Required attributes: * *

* * Conditional attributes: * * @@ -63,8 +56,6 @@ enum AttributeStatus { DB_SYSTEM, DB_CONNECTION_STRING, DB_USER, - DB_MSSQL_INSTANCE_NAME, - DB_JDBC_DRIVER_CLASSNAME, DB_NAME, DB_STATEMENT, DB_OPERATION, @@ -73,6 +64,7 @@ enum AttributeStatus { NET_PEER_PORT, NET_TRANSPORT, DB_HBASE_NAMESPACE; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -100,7 +92,6 @@ public long getValue() { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(DbHbaseSpan.class.getName()); - public final AttributeStatus status; protected DbHbaseSpan(Span span, AttributeStatus status) { @@ -108,25 +99,23 @@ protected DbHbaseSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * 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) { + /** + * 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 createDbHbaseSpanBuilder(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 + * 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 createDbHbaseSpanBuilder(DbSpan.DbSpanBuilder builder) { + // we accept a builder from Db since DbHbase "extends" Db return new DbHbaseSpanBuilder(builder.getSpanBuilder(), builder.status.getValue()); } @@ -152,8 +141,8 @@ public void end() { // extra constraints. { boolean flag = - (!this.status.isSet(AttributeStatus.NET_PEER_NAME)) - || (!this.status.isSet(AttributeStatus.NET_PEER_IP)); + (!this.status.isSet(AttributeStatus.NET_PEER_NAME) ) || + (!this.status.isSet(AttributeStatus.NET_PEER_IP) ) ; if (flag) { logger.info("Constraint not respected!"); } @@ -182,11 +171,10 @@ public void 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.. + * @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) { @@ -197,9 +185,8 @@ public DbHbaseSemanticConvention setDbSystem(String dbSystem) { /** * Sets db.connection_string. - * - * @param dbConnectionString The connection string used to connect to the database.. - *

It is recommended to remove embedded credentials. + * @param dbConnectionString The connection string used to connect to the database. + *

It is recommended to remove embedded credentials. */ @Override public DbHbaseSemanticConvention setDbConnectionString(String dbConnectionString) { @@ -210,8 +197,7 @@ public DbHbaseSemanticConvention setDbConnectionString(String dbConnectionString /** * Sets db.user. - * - * @param dbUser Username for accessing the database.. + * @param dbUser Username for accessing the database. */ @Override public DbHbaseSemanticConvention setDbUser(String dbUser) { @@ -220,42 +206,10 @@ public DbHbaseSemanticConvention setDbUser(String dbUser) { 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 DbHbaseSemanticConvention setDbMssqlInstanceName(String dbMssqlInstanceName) { - status.set(AttributeStatus.DB_MSSQL_INSTANCE_NAME); - delegate.setAttribute("db.mssql.instance_name", dbMssqlInstanceName); - return this; - } - - /** - * Sets db.jdbc.driver_classname. - * - * @param dbJdbcDriverClassname The fully-qualified class name of the JDBC driver used to - * connect.. - */ - @Override - public DbHbaseSemanticConvention setDbJdbcDriverClassname(String dbJdbcDriverClassname) { - status.set(AttributeStatus.DB_JDBC_DRIVER_CLASSNAME); - 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". + * @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) { @@ -266,9 +220,8 @@ public DbHbaseSemanticConvention setDbName(String dbName) { /** * Sets db.statement. - * - * @param dbStatement The database statement being executed.. - *

The value may be sanitized to exclude sensitive information. + * @param dbStatement The database statement being executed. + *

The value may be sanitized to exclude sensitive information. */ @Override public DbHbaseSemanticConvention setDbStatement(String dbStatement) { @@ -279,13 +232,8 @@ public DbHbaseSemanticConvention setDbStatement(String dbStatement) { /** * 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). + * @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) { @@ -296,8 +244,7 @@ public DbHbaseSemanticConvention setDbOperation(String dbOperation) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ @Override public DbHbaseSemanticConvention setNetPeerName(String netPeerName) { @@ -308,9 +255,7 @@ public DbHbaseSemanticConvention setNetPeerName(String netPeerName) { /** * 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). + * @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) { @@ -321,8 +266,7 @@ public DbHbaseSemanticConvention setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ @Override public DbHbaseSemanticConvention setNetPeerPort(long netPeerPort) { @@ -333,8 +277,7 @@ public DbHbaseSemanticConvention setNetPeerPort(long netPeerPort) { /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ @Override public DbHbaseSemanticConvention setNetTransport(String netTransport) { @@ -345,9 +288,7 @@ public DbHbaseSemanticConvention setNetTransport(String netTransport) { /** * 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.. + * @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) { @@ -356,39 +297,42 @@ public DbHbaseSemanticConvention setDbHbaseNamespace(String dbHbaseNamespace) { return this; } - /** Builder class for {@link DbHbaseSpan}. */ - public static class DbHbaseSpanBuilder { + + /** + * Builder class for {@link DbHbaseSpan}. + */ + public static class DbHbaseSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected DbHbaseSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public DbHbaseSpanBuilder(Builder spanBuilder, long attributes) { + public DbHbaseSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public DbHbaseSpanBuilder setParent(Span parent) { + public DbHbaseSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public DbHbaseSpanBuilder setParent(SpanContext remoteParent) { + 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(Kind kind) { + public DbHbaseSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -399,11 +343,10 @@ public DbHbaseSpan start() { return new DbHbaseSpan(this.internalBuilder.startSpan(), status); } + /** * 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.. + * @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) { status.set(AttributeStatus.DB_SYSTEM); @@ -413,9 +356,8 @@ public DbHbaseSpanBuilder setDbSystem(String dbSystem) { /** * Sets db.connection_string. - * - * @param dbConnectionString The connection string used to connect to the database.. - *

It is recommended to remove embedded credentials. + * @param dbConnectionString The connection string used to connect to the database. + *

It is recommended to remove embedded credentials. */ public DbHbaseSpanBuilder setDbConnectionString(String dbConnectionString) { status.set(AttributeStatus.DB_CONNECTION_STRING); @@ -425,8 +367,7 @@ public DbHbaseSpanBuilder setDbConnectionString(String dbConnectionString) { /** * Sets db.user. - * - * @param dbUser Username for accessing the database.. + * @param dbUser Username for accessing the database. */ public DbHbaseSpanBuilder setDbUser(String dbUser) { status.set(AttributeStatus.DB_USER); @@ -434,40 +375,10 @@ public DbHbaseSpanBuilder setDbUser(String dbUser) { 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 DbHbaseSpanBuilder setDbMssqlInstanceName(String dbMssqlInstanceName) { - status.set(AttributeStatus.DB_MSSQL_INSTANCE_NAME); - internalBuilder.setAttribute("db.mssql.instance_name", dbMssqlInstanceName); - return this; - } - - /** - * Sets db.jdbc.driver_classname. - * - * @param dbJdbcDriverClassname The fully-qualified class name of the JDBC driver used to - * connect.. - */ - public DbHbaseSpanBuilder setDbJdbcDriverClassname(String dbJdbcDriverClassname) { - status.set(AttributeStatus.DB_JDBC_DRIVER_CLASSNAME); - 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". + * @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) { status.set(AttributeStatus.DB_NAME); @@ -477,9 +388,8 @@ public DbHbaseSpanBuilder setDbName(String dbName) { /** * Sets db.statement. - * - * @param dbStatement The database statement being executed.. - *

The value may be sanitized to exclude sensitive information. + * @param dbStatement The database statement being executed. + *

The value may be sanitized to exclude sensitive information. */ public DbHbaseSpanBuilder setDbStatement(String dbStatement) { status.set(AttributeStatus.DB_STATEMENT); @@ -489,13 +399,8 @@ public DbHbaseSpanBuilder setDbStatement(String dbStatement) { /** * 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). + * @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) { status.set(AttributeStatus.DB_OPERATION); @@ -505,8 +410,7 @@ public DbHbaseSpanBuilder setDbOperation(String dbOperation) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ public DbHbaseSpanBuilder setNetPeerName(String netPeerName) { status.set(AttributeStatus.NET_PEER_NAME); @@ -516,9 +420,7 @@ public DbHbaseSpanBuilder setNetPeerName(String netPeerName) { /** * 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). + * @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) { status.set(AttributeStatus.NET_PEER_IP); @@ -528,8 +430,7 @@ public DbHbaseSpanBuilder setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ public DbHbaseSpanBuilder setNetPeerPort(long netPeerPort) { status.set(AttributeStatus.NET_PEER_PORT); @@ -539,8 +440,7 @@ public DbHbaseSpanBuilder setNetPeerPort(long netPeerPort) { /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ public DbHbaseSpanBuilder setNetTransport(String netTransport) { status.set(AttributeStatus.NET_TRANSPORT); @@ -550,14 +450,13 @@ public DbHbaseSpanBuilder setNetTransport(String netTransport) { /** * 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.. + * @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) { status.set(AttributeStatus.DB_HBASE_NAMESPACE); internalBuilder.setAttribute("db.hbase.namespace", dbHbaseNamespace); return this; } + } -} +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbJdbcSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbJdbcSemanticConvention.java new file mode 100644 index 000000000000..b47132dab164 --- /dev/null +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbJdbcSemanticConvention.java @@ -0,0 +1,96 @@ +/* + * 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 DbJdbcSemanticConvention { + 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 DbJdbcSemanticConvention 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 DbJdbcSemanticConvention setDbConnectionString(String dbConnectionString); + + /** + * Sets a value for db.user + * @param dbUser Username for accessing the database.. + */ + public DbJdbcSemanticConvention setDbUser(String dbUser); + + /** + * 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 DbJdbcSemanticConvention 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 DbJdbcSemanticConvention 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 DbJdbcSemanticConvention setDbOperation(String dbOperation); + + /** + * Sets a value for net.peer.name + * @param netPeerName Remote hostname or similar, see note below.. + */ + public DbJdbcSemanticConvention 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 DbJdbcSemanticConvention setNetPeerIp(String netPeerIp); + + /** + * Sets a value for net.peer.port + * @param netPeerPort Remote port number.. + */ + public DbJdbcSemanticConvention setNetPeerPort(long netPeerPort); + + /** + * Sets a value for net.transport + * @param netTransport Transport protocol used. See note below.. + */ + public DbJdbcSemanticConvention setNetTransport(String netTransport); + + /** + * Sets a value for db.jdbc.jdbc.driver_classname + * @param dbJdbcJdbcDriverClassname The fully-qualified class name of the JDBC driver used to connect.. + */ + public DbJdbcSemanticConvention setDbJdbcJdbcDriverClassname(String dbJdbcJdbcDriverClassname); + +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbJdbcSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbJdbcSpan.java new file mode 100644 index 000000000000..38a0967de157 --- /dev/null +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbJdbcSpan.java @@ -0,0 +1,458 @@ +/* + * 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; +import java.util.logging.Logger; + +/** + * Required attributes: + * + *

+ * + * Conditional attributes: + * + * + * + * Additional constraints + * + *

At least one of the following must be set: + * + *

+ */ +public class DbJdbcSpan extends DelegatingSpan implements DbJdbcSemanticConvention { + + enum AttributeStatus { + EMPTY, + DB_SYSTEM, + DB_CONNECTION_STRING, + DB_USER, + DB_NAME, + DB_STATEMENT, + DB_OPERATION, + NET_PEER_NAME, + NET_PEER_IP, + NET_PEER_PORT, + NET_TRANSPORT, + DB_JDBC_JDBC_DRIVER_CLASSNAME; + + + @SuppressWarnings("ImmutableEnumChecker") + private long flag; + + AttributeStatus() { + this.flag = 1L << this.ordinal(); + } + + public boolean isSet(AttributeStatus attribute) { + return (this.flag & attribute.flag) > 0; + } + + public void set(AttributeStatus attribute) { + this.flag |= attribute.flag; + } + + public void set(long attribute) { + this.flag = attribute; + } + + public long getValue() { + return flag; + } + } + + @SuppressWarnings("unused") + private static final Logger logger = Logger.getLogger(DbJdbcSpan.class.getName()); + public final AttributeStatus status; + + protected DbJdbcSpan(Span span, AttributeStatus status) { + super(span); + this.status = status; + } + + /** + * Entry point to generate a {@link DbJdbcSpan}. + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link DbJdbcSpan} object. + */ + public static DbJdbcSpanBuilder createDbJdbcSpanBuilder(Tracer tracer, String spanName) { + return new DbJdbcSpanBuilder(tracer, spanName); + } + + /** + * Creates a {@link DbJdbcSpan} from a {@link DbSpan}. + * @param builder {@link DbSpan.DbSpanBuilder} to use. + * @return a {@link DbJdbcSpan} object built from a {@link DbSpan}. + */ + public static DbJdbcSpanBuilder createDbJdbcSpanBuilder(DbSpan.DbSpanBuilder builder) { + // we accept a builder from Db since DbJdbc "extends" Db + return new DbJdbcSpanBuilder(builder.getSpanBuilder(), builder.status.getValue()); + } + + /** @return the Span used internally */ + @Override + public Span getSpan() { + return this.delegate; + } + + /** Terminates the Span. Here there is the checking for required attributes. */ + @Override + @SuppressWarnings("UnnecessaryParentheses") + public void end() { + delegate.end(); + + // required attributes + if (!this.status.isSet(AttributeStatus.DB_SYSTEM)) { + logger.warning("Wrong usage - Span missing db.system attribute"); + } + // extra constraints. + { + boolean flag = + (!this.status.isSet(AttributeStatus.NET_PEER_NAME) ) || + (!this.status.isSet(AttributeStatus.NET_PEER_IP) ) ; + if (flag) { + logger.info("Constraint not respected!"); + } + } + // conditional attributes + if (!this.status.isSet(AttributeStatus.DB_NAME)) { + logger.info("WARNING! Missing db.name attribute!"); + } + if (!this.status.isSet(AttributeStatus.DB_STATEMENT)) { + logger.info("WARNING! Missing db.statement attribute!"); + } + if (!this.status.isSet(AttributeStatus.DB_OPERATION)) { + logger.info("WARNING! Missing db.operation attribute!"); + } + if (!this.status.isSet(AttributeStatus.NET_PEER_NAME)) { + logger.info("WARNING! Missing net.peer.name attribute!"); + } + if (!this.status.isSet(AttributeStatus.NET_PEER_IP)) { + logger.info("WARNING! Missing net.peer.ip attribute!"); + } + if (!this.status.isSet(AttributeStatus.NET_PEER_PORT)) { + logger.info("WARNING! Missing net.peer.port attribute!"); + } + if (!this.status.isSet(AttributeStatus.NET_TRANSPORT)) { + logger.info("WARNING! Missing net.transport attribute!"); + } + } + + + /** + * 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 DbJdbcSemanticConvention setDbSystem(String dbSystem) { + status.set(AttributeStatus.DB_SYSTEM); + 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 DbJdbcSemanticConvention setDbConnectionString(String dbConnectionString) { + status.set(AttributeStatus.DB_CONNECTION_STRING); + delegate.setAttribute("db.connection_string", dbConnectionString); + return this; + } + + /** + * Sets db.user. + * @param dbUser Username for accessing the database. + */ + @Override + public DbJdbcSemanticConvention setDbUser(String dbUser) { + status.set(AttributeStatus.DB_USER); + delegate.setAttribute("db.user", dbUser); + 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 DbJdbcSemanticConvention setDbName(String dbName) { + status.set(AttributeStatus.DB_NAME); + 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 DbJdbcSemanticConvention setDbStatement(String dbStatement) { + status.set(AttributeStatus.DB_STATEMENT); + 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 DbJdbcSemanticConvention setDbOperation(String dbOperation) { + status.set(AttributeStatus.DB_OPERATION); + delegate.setAttribute("db.operation", dbOperation); + return this; + } + + /** + * Sets net.peer.name. + * @param netPeerName Remote hostname or similar, see note below. + */ + @Override + public DbJdbcSemanticConvention setNetPeerName(String netPeerName) { + status.set(AttributeStatus.NET_PEER_NAME); + 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 DbJdbcSemanticConvention setNetPeerIp(String netPeerIp) { + status.set(AttributeStatus.NET_PEER_IP); + delegate.setAttribute("net.peer.ip", netPeerIp); + return this; + } + + /** + * Sets net.peer.port. + * @param netPeerPort Remote port number. + */ + @Override + public DbJdbcSemanticConvention setNetPeerPort(long netPeerPort) { + status.set(AttributeStatus.NET_PEER_PORT); + delegate.setAttribute("net.peer.port", netPeerPort); + return this; + } + + /** + * Sets net.transport. + * @param netTransport Transport protocol used. See note below. + */ + @Override + public DbJdbcSemanticConvention setNetTransport(String netTransport) { + status.set(AttributeStatus.NET_TRANSPORT); + delegate.setAttribute("net.transport", netTransport); + return this; + } + + /** + * Sets db.jdbc.jdbc.driver_classname. + * @param dbJdbcJdbcDriverClassname The fully-qualified class name of the JDBC driver used to connect. + */ + @Override + public DbJdbcSemanticConvention setDbJdbcJdbcDriverClassname(String dbJdbcJdbcDriverClassname) { + status.set(AttributeStatus.DB_JDBC_JDBC_DRIVER_CLASSNAME); + delegate.setAttribute("db.jdbc.jdbc.driver_classname", dbJdbcJdbcDriverClassname); + return this; + } + + + /** + * Builder class for {@link DbJdbcSpan}. + */ + public static class DbJdbcSpanBuilder { + // Protected because maybe we want to extend manually these classes + protected Span.Builder internalBuilder; + protected AttributeStatus status = AttributeStatus.EMPTY; + + protected DbJdbcSpanBuilder(Tracer tracer, String spanName) { + internalBuilder = tracer.spanBuilder(spanName); + } + + public DbJdbcSpanBuilder(Span.Builder spanBuilder, long attributes) { + this.internalBuilder = spanBuilder; + this.status.set(attributes); + } + + public Span.Builder getSpanBuilder() { + return this.internalBuilder; + } + + /** sets the {@link Span} parent. */ + public DbJdbcSpanBuilder setParent(Span parent){ + this.internalBuilder.setParent(parent); + return this; + } + + /** sets the {@link Span} parent. */ + public DbJdbcSpanBuilder 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 DbJdbcSpanBuilder setKind(Span.Kind kind) { + internalBuilder.setSpanKind(kind); + return this; + } + + /** starts the span */ + public DbJdbcSpan start() { + // check for sampling relevant field here, but there are none. + return new DbJdbcSpan(this.internalBuilder.startSpan(), status); + } + + + /** + * 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 DbJdbcSpanBuilder setDbSystem(String dbSystem) { + status.set(AttributeStatus.DB_SYSTEM); + 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 DbJdbcSpanBuilder setDbConnectionString(String dbConnectionString) { + status.set(AttributeStatus.DB_CONNECTION_STRING); + internalBuilder.setAttribute("db.connection_string", dbConnectionString); + return this; + } + + /** + * Sets db.user. + * @param dbUser Username for accessing the database. + */ + public DbJdbcSpanBuilder setDbUser(String dbUser) { + status.set(AttributeStatus.DB_USER); + internalBuilder.setAttribute("db.user", dbUser); + 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 DbJdbcSpanBuilder setDbName(String dbName) { + status.set(AttributeStatus.DB_NAME); + 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 DbJdbcSpanBuilder setDbStatement(String dbStatement) { + status.set(AttributeStatus.DB_STATEMENT); + 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 DbJdbcSpanBuilder setDbOperation(String dbOperation) { + status.set(AttributeStatus.DB_OPERATION); + internalBuilder.setAttribute("db.operation", dbOperation); + return this; + } + + /** + * Sets net.peer.name. + * @param netPeerName Remote hostname or similar, see note below. + */ + public DbJdbcSpanBuilder setNetPeerName(String netPeerName) { + status.set(AttributeStatus.NET_PEER_NAME); + 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 DbJdbcSpanBuilder setNetPeerIp(String netPeerIp) { + status.set(AttributeStatus.NET_PEER_IP); + internalBuilder.setAttribute("net.peer.ip", netPeerIp); + return this; + } + + /** + * Sets net.peer.port. + * @param netPeerPort Remote port number. + */ + public DbJdbcSpanBuilder setNetPeerPort(long netPeerPort) { + status.set(AttributeStatus.NET_PEER_PORT); + internalBuilder.setAttribute("net.peer.port", netPeerPort); + return this; + } + + /** + * Sets net.transport. + * @param netTransport Transport protocol used. See note below. + */ + public DbJdbcSpanBuilder setNetTransport(String netTransport) { + status.set(AttributeStatus.NET_TRANSPORT); + internalBuilder.setAttribute("net.transport", netTransport); + return this; + } + + /** + * Sets db.jdbc.jdbc.driver_classname. + * @param dbJdbcJdbcDriverClassname The fully-qualified class name of the JDBC driver used to connect. + */ + public DbJdbcSpanBuilder setDbJdbcJdbcDriverClassname(String dbJdbcJdbcDriverClassname) { + status.set(AttributeStatus.DB_JDBC_JDBC_DRIVER_CLASSNAME); + internalBuilder.setAttribute("db.jdbc.jdbc.driver_classname", dbJdbcJdbcDriverClassname); + return this; + } + + } +} \ No newline at end of file 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 index fc721e6655ae..5f397382dda4 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMongodbSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMongodbSemanticConvention.java @@ -22,112 +22,75 @@ public interface DbMongodbSemanticConvention { 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.. + * @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. + *

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.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 DbMongodbSemanticConvention setDbMssqlInstanceName(String dbMssqlInstanceName); - - /** - * Sets a value for db.jdbc.driver_classname - * - * @param dbJdbcDriverClassname The fully-qualified class name of the 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". + * @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. + *

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). + * @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). + * @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`.. + * @param dbMongodbCollection The collection being accessed within the database stated in `db.name`.. */ public DbMongodbSemanticConvention setDbMongodbCollection(String dbMongodbCollection); -} + +} \ No newline at end of file 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 index 7ec0ec9481c7..61901700f00a 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMongodbSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMongodbSpan.java @@ -24,25 +24,18 @@ * Required attributes: * *

* * Conditional attributes: * * @@ -63,8 +56,6 @@ enum AttributeStatus { DB_SYSTEM, DB_CONNECTION_STRING, DB_USER, - DB_MSSQL_INSTANCE_NAME, - DB_JDBC_DRIVER_CLASSNAME, DB_NAME, DB_STATEMENT, DB_OPERATION, @@ -73,6 +64,7 @@ enum AttributeStatus { NET_PEER_PORT, NET_TRANSPORT, DB_MONGODB_COLLECTION; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -100,7 +92,6 @@ public long getValue() { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(DbMongodbSpan.class.getName()); - public final AttributeStatus status; protected DbMongodbSpan(Span span, AttributeStatus status) { @@ -108,25 +99,23 @@ protected DbMongodbSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * 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) { + /** + * 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 createDbMongodbSpanBuilder(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 + * 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 createDbMongodbSpanBuilder(DbSpan.DbSpanBuilder builder) { + // we accept a builder from Db since DbMongodb "extends" Db return new DbMongodbSpanBuilder(builder.getSpanBuilder(), builder.status.getValue()); } @@ -152,8 +141,8 @@ public void end() { // extra constraints. { boolean flag = - (!this.status.isSet(AttributeStatus.NET_PEER_NAME)) - || (!this.status.isSet(AttributeStatus.NET_PEER_IP)); + (!this.status.isSet(AttributeStatus.NET_PEER_NAME) ) || + (!this.status.isSet(AttributeStatus.NET_PEER_IP) ) ; if (flag) { logger.info("Constraint not respected!"); } @@ -182,11 +171,10 @@ public void 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.. + * @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) { @@ -197,9 +185,8 @@ public DbMongodbSemanticConvention setDbSystem(String dbSystem) { /** * Sets db.connection_string. - * - * @param dbConnectionString The connection string used to connect to the database.. - *

It is recommended to remove embedded credentials. + * @param dbConnectionString The connection string used to connect to the database. + *

It is recommended to remove embedded credentials. */ @Override public DbMongodbSemanticConvention setDbConnectionString(String dbConnectionString) { @@ -210,8 +197,7 @@ public DbMongodbSemanticConvention setDbConnectionString(String dbConnectionStri /** * Sets db.user. - * - * @param dbUser Username for accessing the database.. + * @param dbUser Username for accessing the database. */ @Override public DbMongodbSemanticConvention setDbUser(String dbUser) { @@ -220,42 +206,10 @@ public DbMongodbSemanticConvention setDbUser(String dbUser) { 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 DbMongodbSemanticConvention setDbMssqlInstanceName(String dbMssqlInstanceName) { - status.set(AttributeStatus.DB_MSSQL_INSTANCE_NAME); - delegate.setAttribute("db.mssql.instance_name", dbMssqlInstanceName); - return this; - } - - /** - * Sets db.jdbc.driver_classname. - * - * @param dbJdbcDriverClassname The fully-qualified class name of the JDBC driver used to - * connect.. - */ - @Override - public DbMongodbSemanticConvention setDbJdbcDriverClassname(String dbJdbcDriverClassname) { - status.set(AttributeStatus.DB_JDBC_DRIVER_CLASSNAME); - 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". + * @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) { @@ -266,9 +220,8 @@ public DbMongodbSemanticConvention setDbName(String dbName) { /** * Sets db.statement. - * - * @param dbStatement The database statement being executed.. - *

The value may be sanitized to exclude sensitive information. + * @param dbStatement The database statement being executed. + *

The value may be sanitized to exclude sensitive information. */ @Override public DbMongodbSemanticConvention setDbStatement(String dbStatement) { @@ -279,13 +232,8 @@ public DbMongodbSemanticConvention setDbStatement(String dbStatement) { /** * 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). + * @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) { @@ -296,8 +244,7 @@ public DbMongodbSemanticConvention setDbOperation(String dbOperation) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ @Override public DbMongodbSemanticConvention setNetPeerName(String netPeerName) { @@ -308,9 +255,7 @@ public DbMongodbSemanticConvention setNetPeerName(String netPeerName) { /** * 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). + * @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) { @@ -321,8 +266,7 @@ public DbMongodbSemanticConvention setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ @Override public DbMongodbSemanticConvention setNetPeerPort(long netPeerPort) { @@ -333,8 +277,7 @@ public DbMongodbSemanticConvention setNetPeerPort(long netPeerPort) { /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ @Override public DbMongodbSemanticConvention setNetTransport(String netTransport) { @@ -345,9 +288,7 @@ public DbMongodbSemanticConvention setNetTransport(String netTransport) { /** * Sets db.mongodb.collection. - * - * @param dbMongodbCollection The collection being accessed within the database stated in - * `db.name`.. + * @param dbMongodbCollection The collection being accessed within the database stated in `db.name`. */ @Override public DbMongodbSemanticConvention setDbMongodbCollection(String dbMongodbCollection) { @@ -356,39 +297,42 @@ public DbMongodbSemanticConvention setDbMongodbCollection(String dbMongodbCollec return this; } - /** Builder class for {@link DbMongodbSpan}. */ - public static class DbMongodbSpanBuilder { + + /** + * Builder class for {@link DbMongodbSpan}. + */ + public static class DbMongodbSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected DbMongodbSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public DbMongodbSpanBuilder(Builder spanBuilder, long attributes) { + public DbMongodbSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public DbMongodbSpanBuilder setParent(Span parent) { + public DbMongodbSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public DbMongodbSpanBuilder setParent(SpanContext remoteParent) { + 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(Kind kind) { + public DbMongodbSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -399,11 +343,10 @@ public DbMongodbSpan start() { return new DbMongodbSpan(this.internalBuilder.startSpan(), status); } + /** * 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.. + * @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) { status.set(AttributeStatus.DB_SYSTEM); @@ -413,9 +356,8 @@ public DbMongodbSpanBuilder setDbSystem(String dbSystem) { /** * Sets db.connection_string. - * - * @param dbConnectionString The connection string used to connect to the database.. - *

It is recommended to remove embedded credentials. + * @param dbConnectionString The connection string used to connect to the database. + *

It is recommended to remove embedded credentials. */ public DbMongodbSpanBuilder setDbConnectionString(String dbConnectionString) { status.set(AttributeStatus.DB_CONNECTION_STRING); @@ -425,8 +367,7 @@ public DbMongodbSpanBuilder setDbConnectionString(String dbConnectionString) { /** * Sets db.user. - * - * @param dbUser Username for accessing the database.. + * @param dbUser Username for accessing the database. */ public DbMongodbSpanBuilder setDbUser(String dbUser) { status.set(AttributeStatus.DB_USER); @@ -434,40 +375,10 @@ public DbMongodbSpanBuilder setDbUser(String dbUser) { 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 DbMongodbSpanBuilder setDbMssqlInstanceName(String dbMssqlInstanceName) { - status.set(AttributeStatus.DB_MSSQL_INSTANCE_NAME); - internalBuilder.setAttribute("db.mssql.instance_name", dbMssqlInstanceName); - return this; - } - - /** - * Sets db.jdbc.driver_classname. - * - * @param dbJdbcDriverClassname The fully-qualified class name of the JDBC driver used to - * connect.. - */ - public DbMongodbSpanBuilder setDbJdbcDriverClassname(String dbJdbcDriverClassname) { - status.set(AttributeStatus.DB_JDBC_DRIVER_CLASSNAME); - 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". + * @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) { status.set(AttributeStatus.DB_NAME); @@ -477,9 +388,8 @@ public DbMongodbSpanBuilder setDbName(String dbName) { /** * Sets db.statement. - * - * @param dbStatement The database statement being executed.. - *

The value may be sanitized to exclude sensitive information. + * @param dbStatement The database statement being executed. + *

The value may be sanitized to exclude sensitive information. */ public DbMongodbSpanBuilder setDbStatement(String dbStatement) { status.set(AttributeStatus.DB_STATEMENT); @@ -489,13 +399,8 @@ public DbMongodbSpanBuilder setDbStatement(String dbStatement) { /** * 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). + * @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) { status.set(AttributeStatus.DB_OPERATION); @@ -505,8 +410,7 @@ public DbMongodbSpanBuilder setDbOperation(String dbOperation) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ public DbMongodbSpanBuilder setNetPeerName(String netPeerName) { status.set(AttributeStatus.NET_PEER_NAME); @@ -516,9 +420,7 @@ public DbMongodbSpanBuilder setNetPeerName(String netPeerName) { /** * 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). + * @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) { status.set(AttributeStatus.NET_PEER_IP); @@ -528,8 +430,7 @@ public DbMongodbSpanBuilder setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ public DbMongodbSpanBuilder setNetPeerPort(long netPeerPort) { status.set(AttributeStatus.NET_PEER_PORT); @@ -539,8 +440,7 @@ public DbMongodbSpanBuilder setNetPeerPort(long netPeerPort) { /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ public DbMongodbSpanBuilder setNetTransport(String netTransport) { status.set(AttributeStatus.NET_TRANSPORT); @@ -550,14 +450,13 @@ public DbMongodbSpanBuilder setNetTransport(String netTransport) { /** * Sets db.mongodb.collection. - * - * @param dbMongodbCollection The collection being accessed within the database stated in - * `db.name`.. + * @param dbMongodbCollection The collection being accessed within the database stated in `db.name`. */ public DbMongodbSpanBuilder setDbMongodbCollection(String dbMongodbCollection) { status.set(AttributeStatus.DB_MONGODB_COLLECTION); internalBuilder.setAttribute("db.mongodb.collection", dbMongodbCollection); return this; } + } -} +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMysqlSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMysqlSemanticConvention.java new file mode 100644 index 000000000000..af557fc64e92 --- /dev/null +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMysqlSemanticConvention.java @@ -0,0 +1,97 @@ +/* + * 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 DbMysqlSemanticConvention { + 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 DbMysqlSemanticConvention 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 DbMysqlSemanticConvention setDbConnectionString(String dbConnectionString); + + /** + * Sets a value for db.user + * @param dbUser Username for accessing the database.. + */ + public DbMysqlSemanticConvention setDbUser(String dbUser); + + /** + * 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 DbMysqlSemanticConvention 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 DbMysqlSemanticConvention 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 DbMysqlSemanticConvention setDbOperation(String dbOperation); + + /** + * Sets a value for net.peer.name + * @param netPeerName Remote hostname or similar, see note below.. + */ + public DbMysqlSemanticConvention 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 DbMysqlSemanticConvention setNetPeerIp(String netPeerIp); + + /** + * Sets a value for net.peer.port + * @param netPeerPort Remote port number.. + */ + public DbMysqlSemanticConvention setNetPeerPort(long netPeerPort); + + /** + * Sets a value for net.transport + * @param netTransport Transport protocol used. See note below.. + */ + public DbMysqlSemanticConvention 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 DbMysqlSemanticConvention setDbMssqlInstanceName(String dbMssqlInstanceName); + +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMysqlSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMysqlSpan.java new file mode 100644 index 000000000000..e0f0d3a9bd78 --- /dev/null +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbMysqlSpan.java @@ -0,0 +1,460 @@ +/* + * 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; +import java.util.logging.Logger; + +/** + * Required attributes: + * + *

+ * + * Conditional attributes: + * + * + * + * Additional constraints + * + *

At least one of the following must be set: + * + *

+ */ +public class DbMysqlSpan extends DelegatingSpan implements DbMysqlSemanticConvention { + + enum AttributeStatus { + EMPTY, + DB_SYSTEM, + DB_CONNECTION_STRING, + DB_USER, + DB_NAME, + DB_STATEMENT, + DB_OPERATION, + NET_PEER_NAME, + NET_PEER_IP, + NET_PEER_PORT, + NET_TRANSPORT, + DB_MSSQL_INSTANCE_NAME; + + + @SuppressWarnings("ImmutableEnumChecker") + private long flag; + + AttributeStatus() { + this.flag = 1L << this.ordinal(); + } + + public boolean isSet(AttributeStatus attribute) { + return (this.flag & attribute.flag) > 0; + } + + public void set(AttributeStatus attribute) { + this.flag |= attribute.flag; + } + + public void set(long attribute) { + this.flag = attribute; + } + + public long getValue() { + return flag; + } + } + + @SuppressWarnings("unused") + private static final Logger logger = Logger.getLogger(DbMysqlSpan.class.getName()); + public final AttributeStatus status; + + protected DbMysqlSpan(Span span, AttributeStatus status) { + super(span); + this.status = status; + } + + /** + * Entry point to generate a {@link DbMysqlSpan}. + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link DbMysqlSpan} object. + */ + public static DbMysqlSpanBuilder createDbMysqlSpanBuilder(Tracer tracer, String spanName) { + return new DbMysqlSpanBuilder(tracer, spanName); + } + + /** + * Creates a {@link DbMysqlSpan} from a {@link DbSpan}. + * @param builder {@link DbSpan.DbSpanBuilder} to use. + * @return a {@link DbMysqlSpan} object built from a {@link DbSpan}. + */ + public static DbMysqlSpanBuilder createDbMysqlSpanBuilder(DbSpan.DbSpanBuilder builder) { + // we accept a builder from Db since DbMysql "extends" Db + return new DbMysqlSpanBuilder(builder.getSpanBuilder(), builder.status.getValue()); + } + + /** @return the Span used internally */ + @Override + public Span getSpan() { + return this.delegate; + } + + /** Terminates the Span. Here there is the checking for required attributes. */ + @Override + @SuppressWarnings("UnnecessaryParentheses") + public void end() { + delegate.end(); + + // required attributes + if (!this.status.isSet(AttributeStatus.DB_SYSTEM)) { + logger.warning("Wrong usage - Span missing db.system attribute"); + } + // extra constraints. + { + boolean flag = + (!this.status.isSet(AttributeStatus.NET_PEER_NAME) ) || + (!this.status.isSet(AttributeStatus.NET_PEER_IP) ) ; + if (flag) { + logger.info("Constraint not respected!"); + } + } + // conditional attributes + if (!this.status.isSet(AttributeStatus.DB_NAME)) { + logger.info("WARNING! Missing db.name attribute!"); + } + if (!this.status.isSet(AttributeStatus.DB_STATEMENT)) { + logger.info("WARNING! Missing db.statement attribute!"); + } + if (!this.status.isSet(AttributeStatus.DB_OPERATION)) { + logger.info("WARNING! Missing db.operation attribute!"); + } + if (!this.status.isSet(AttributeStatus.NET_PEER_NAME)) { + logger.info("WARNING! Missing net.peer.name attribute!"); + } + if (!this.status.isSet(AttributeStatus.NET_PEER_IP)) { + logger.info("WARNING! Missing net.peer.ip attribute!"); + } + if (!this.status.isSet(AttributeStatus.NET_PEER_PORT)) { + logger.info("WARNING! Missing net.peer.port attribute!"); + } + if (!this.status.isSet(AttributeStatus.NET_TRANSPORT)) { + logger.info("WARNING! Missing net.transport attribute!"); + } + } + + + /** + * 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 DbMysqlSemanticConvention setDbSystem(String dbSystem) { + status.set(AttributeStatus.DB_SYSTEM); + 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 DbMysqlSemanticConvention setDbConnectionString(String dbConnectionString) { + status.set(AttributeStatus.DB_CONNECTION_STRING); + delegate.setAttribute("db.connection_string", dbConnectionString); + return this; + } + + /** + * Sets db.user. + * @param dbUser Username for accessing the database. + */ + @Override + public DbMysqlSemanticConvention setDbUser(String dbUser) { + status.set(AttributeStatus.DB_USER); + delegate.setAttribute("db.user", dbUser); + 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 DbMysqlSemanticConvention setDbName(String dbName) { + status.set(AttributeStatus.DB_NAME); + 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 DbMysqlSemanticConvention setDbStatement(String dbStatement) { + status.set(AttributeStatus.DB_STATEMENT); + 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 DbMysqlSemanticConvention setDbOperation(String dbOperation) { + status.set(AttributeStatus.DB_OPERATION); + delegate.setAttribute("db.operation", dbOperation); + return this; + } + + /** + * Sets net.peer.name. + * @param netPeerName Remote hostname or similar, see note below. + */ + @Override + public DbMysqlSemanticConvention setNetPeerName(String netPeerName) { + status.set(AttributeStatus.NET_PEER_NAME); + 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 DbMysqlSemanticConvention setNetPeerIp(String netPeerIp) { + status.set(AttributeStatus.NET_PEER_IP); + delegate.setAttribute("net.peer.ip", netPeerIp); + return this; + } + + /** + * Sets net.peer.port. + * @param netPeerPort Remote port number. + */ + @Override + public DbMysqlSemanticConvention setNetPeerPort(long netPeerPort) { + status.set(AttributeStatus.NET_PEER_PORT); + delegate.setAttribute("net.peer.port", netPeerPort); + return this; + } + + /** + * Sets net.transport. + * @param netTransport Transport protocol used. See note below. + */ + @Override + public DbMysqlSemanticConvention setNetTransport(String netTransport) { + status.set(AttributeStatus.NET_TRANSPORT); + 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 DbMysqlSemanticConvention setDbMssqlInstanceName(String dbMssqlInstanceName) { + status.set(AttributeStatus.DB_MSSQL_INSTANCE_NAME); + delegate.setAttribute("db.mssql.instance_name", dbMssqlInstanceName); + return this; + } + + + /** + * Builder class for {@link DbMysqlSpan}. + */ + public static class DbMysqlSpanBuilder { + // Protected because maybe we want to extend manually these classes + protected Span.Builder internalBuilder; + protected AttributeStatus status = AttributeStatus.EMPTY; + + protected DbMysqlSpanBuilder(Tracer tracer, String spanName) { + internalBuilder = tracer.spanBuilder(spanName); + } + + public DbMysqlSpanBuilder(Span.Builder spanBuilder, long attributes) { + this.internalBuilder = spanBuilder; + this.status.set(attributes); + } + + public Span.Builder getSpanBuilder() { + return this.internalBuilder; + } + + /** sets the {@link Span} parent. */ + public DbMysqlSpanBuilder setParent(Span parent){ + this.internalBuilder.setParent(parent); + return this; + } + + /** sets the {@link Span} parent. */ + public DbMysqlSpanBuilder 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 DbMysqlSpanBuilder setKind(Span.Kind kind) { + internalBuilder.setSpanKind(kind); + return this; + } + + /** starts the span */ + public DbMysqlSpan start() { + // check for sampling relevant field here, but there are none. + return new DbMysqlSpan(this.internalBuilder.startSpan(), status); + } + + + /** + * 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 DbMysqlSpanBuilder setDbSystem(String dbSystem) { + status.set(AttributeStatus.DB_SYSTEM); + 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 DbMysqlSpanBuilder setDbConnectionString(String dbConnectionString) { + status.set(AttributeStatus.DB_CONNECTION_STRING); + internalBuilder.setAttribute("db.connection_string", dbConnectionString); + return this; + } + + /** + * Sets db.user. + * @param dbUser Username for accessing the database. + */ + public DbMysqlSpanBuilder setDbUser(String dbUser) { + status.set(AttributeStatus.DB_USER); + internalBuilder.setAttribute("db.user", dbUser); + 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 DbMysqlSpanBuilder setDbName(String dbName) { + status.set(AttributeStatus.DB_NAME); + 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 DbMysqlSpanBuilder setDbStatement(String dbStatement) { + status.set(AttributeStatus.DB_STATEMENT); + 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 DbMysqlSpanBuilder setDbOperation(String dbOperation) { + status.set(AttributeStatus.DB_OPERATION); + internalBuilder.setAttribute("db.operation", dbOperation); + return this; + } + + /** + * Sets net.peer.name. + * @param netPeerName Remote hostname or similar, see note below. + */ + public DbMysqlSpanBuilder setNetPeerName(String netPeerName) { + status.set(AttributeStatus.NET_PEER_NAME); + 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 DbMysqlSpanBuilder setNetPeerIp(String netPeerIp) { + status.set(AttributeStatus.NET_PEER_IP); + internalBuilder.setAttribute("net.peer.ip", netPeerIp); + return this; + } + + /** + * Sets net.peer.port. + * @param netPeerPort Remote port number. + */ + public DbMysqlSpanBuilder setNetPeerPort(long netPeerPort) { + status.set(AttributeStatus.NET_PEER_PORT); + internalBuilder.setAttribute("net.peer.port", netPeerPort); + return this; + } + + /** + * Sets net.transport. + * @param netTransport Transport protocol used. See note below. + */ + public DbMysqlSpanBuilder setNetTransport(String netTransport) { + status.set(AttributeStatus.NET_TRANSPORT); + 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 DbMysqlSpanBuilder setDbMssqlInstanceName(String dbMssqlInstanceName) { + status.set(AttributeStatus.DB_MSSQL_INSTANCE_NAME); + internalBuilder.setAttribute("db.mssql.instance_name", dbMssqlInstanceName); + return this; + } + + } +} \ No newline at end of file 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 index 22ff44dcf7f5..48f3ad4704a9 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbRedisSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbRedisSemanticConvention.java @@ -22,113 +22,75 @@ public interface DbRedisSemanticConvention { 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.. + * @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. + *

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.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 DbRedisSemanticConvention setDbMssqlInstanceName(String dbMssqlInstanceName); - - /** - * Sets a value for db.jdbc.driver_classname - * - * @param dbJdbcDriverClassname The fully-qualified class name of the 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". + * @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. + *

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). + * @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). + * @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.. + * @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); -} + +} \ No newline at end of file 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 index 4863fd89fea0..aa08418aecd6 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbRedisSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbRedisSpan.java @@ -24,28 +24,20 @@ * Required attributes: * *

* * Conditional attributes: * * * * Additional constraints @@ -64,8 +56,6 @@ enum AttributeStatus { DB_SYSTEM, DB_CONNECTION_STRING, DB_USER, - DB_MSSQL_INSTANCE_NAME, - DB_JDBC_DRIVER_CLASSNAME, DB_NAME, DB_STATEMENT, DB_OPERATION, @@ -74,6 +64,7 @@ enum AttributeStatus { NET_PEER_PORT, NET_TRANSPORT, DB_REDIS_DATABASE_INDEX; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -101,7 +92,6 @@ public long getValue() { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(DbRedisSpan.class.getName()); - public final AttributeStatus status; protected DbRedisSpan(Span span, AttributeStatus status) { @@ -109,25 +99,23 @@ protected DbRedisSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * 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) { + /** + * 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 createDbRedisSpanBuilder(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 + * 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 createDbRedisSpanBuilder(DbSpan.DbSpanBuilder builder) { + // we accept a builder from Db since DbRedis "extends" Db return new DbRedisSpanBuilder(builder.getSpanBuilder(), builder.status.getValue()); } @@ -150,8 +138,8 @@ public void end() { // extra constraints. { boolean flag = - (!this.status.isSet(AttributeStatus.NET_PEER_NAME)) - || (!this.status.isSet(AttributeStatus.NET_PEER_IP)); + (!this.status.isSet(AttributeStatus.NET_PEER_NAME) ) || + (!this.status.isSet(AttributeStatus.NET_PEER_IP) ) ; if (flag) { logger.info("Constraint not respected!"); } @@ -183,11 +171,10 @@ public void 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.. + * @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) { @@ -198,9 +185,8 @@ public DbRedisSemanticConvention setDbSystem(String dbSystem) { /** * Sets db.connection_string. - * - * @param dbConnectionString The connection string used to connect to the database.. - *

It is recommended to remove embedded credentials. + * @param dbConnectionString The connection string used to connect to the database. + *

It is recommended to remove embedded credentials. */ @Override public DbRedisSemanticConvention setDbConnectionString(String dbConnectionString) { @@ -211,8 +197,7 @@ public DbRedisSemanticConvention setDbConnectionString(String dbConnectionString /** * Sets db.user. - * - * @param dbUser Username for accessing the database.. + * @param dbUser Username for accessing the database. */ @Override public DbRedisSemanticConvention setDbUser(String dbUser) { @@ -221,42 +206,10 @@ public DbRedisSemanticConvention setDbUser(String dbUser) { 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 DbRedisSemanticConvention setDbMssqlInstanceName(String dbMssqlInstanceName) { - status.set(AttributeStatus.DB_MSSQL_INSTANCE_NAME); - delegate.setAttribute("db.mssql.instance_name", dbMssqlInstanceName); - return this; - } - - /** - * Sets db.jdbc.driver_classname. - * - * @param dbJdbcDriverClassname The fully-qualified class name of the JDBC driver used to - * connect.. - */ - @Override - public DbRedisSemanticConvention setDbJdbcDriverClassname(String dbJdbcDriverClassname) { - status.set(AttributeStatus.DB_JDBC_DRIVER_CLASSNAME); - 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". + * @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) { @@ -267,9 +220,8 @@ public DbRedisSemanticConvention setDbName(String dbName) { /** * Sets db.statement. - * - * @param dbStatement The database statement being executed.. - *

The value may be sanitized to exclude sensitive information. + * @param dbStatement The database statement being executed. + *

The value may be sanitized to exclude sensitive information. */ @Override public DbRedisSemanticConvention setDbStatement(String dbStatement) { @@ -280,13 +232,8 @@ public DbRedisSemanticConvention setDbStatement(String dbStatement) { /** * 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). + * @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) { @@ -297,8 +244,7 @@ public DbRedisSemanticConvention setDbOperation(String dbOperation) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ @Override public DbRedisSemanticConvention setNetPeerName(String netPeerName) { @@ -309,9 +255,7 @@ public DbRedisSemanticConvention setNetPeerName(String netPeerName) { /** * 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). + * @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) { @@ -322,8 +266,7 @@ public DbRedisSemanticConvention setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ @Override public DbRedisSemanticConvention setNetPeerPort(long netPeerPort) { @@ -334,8 +277,7 @@ public DbRedisSemanticConvention setNetPeerPort(long netPeerPort) { /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ @Override public DbRedisSemanticConvention setNetTransport(String netTransport) { @@ -346,10 +288,7 @@ public DbRedisSemanticConvention setNetTransport(String netTransport) { /** * 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.. + * @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) { @@ -358,39 +297,42 @@ public DbRedisSemanticConvention setDbRedisDatabaseIndex(long dbRedisDatabaseInd return this; } - /** Builder class for {@link DbRedisSpan}. */ - public static class DbRedisSpanBuilder { + + /** + * Builder class for {@link DbRedisSpan}. + */ + public static class DbRedisSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected DbRedisSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public DbRedisSpanBuilder(Builder spanBuilder, long attributes) { + public DbRedisSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public DbRedisSpanBuilder setParent(Span parent) { + public DbRedisSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public DbRedisSpanBuilder setParent(SpanContext remoteParent) { + 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(Kind kind) { + public DbRedisSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -401,11 +343,10 @@ public DbRedisSpan start() { return new DbRedisSpan(this.internalBuilder.startSpan(), status); } + /** * 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.. + * @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) { status.set(AttributeStatus.DB_SYSTEM); @@ -415,9 +356,8 @@ public DbRedisSpanBuilder setDbSystem(String dbSystem) { /** * Sets db.connection_string. - * - * @param dbConnectionString The connection string used to connect to the database.. - *

It is recommended to remove embedded credentials. + * @param dbConnectionString The connection string used to connect to the database. + *

It is recommended to remove embedded credentials. */ public DbRedisSpanBuilder setDbConnectionString(String dbConnectionString) { status.set(AttributeStatus.DB_CONNECTION_STRING); @@ -427,8 +367,7 @@ public DbRedisSpanBuilder setDbConnectionString(String dbConnectionString) { /** * Sets db.user. - * - * @param dbUser Username for accessing the database.. + * @param dbUser Username for accessing the database. */ public DbRedisSpanBuilder setDbUser(String dbUser) { status.set(AttributeStatus.DB_USER); @@ -436,40 +375,10 @@ public DbRedisSpanBuilder setDbUser(String dbUser) { 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 DbRedisSpanBuilder setDbMssqlInstanceName(String dbMssqlInstanceName) { - status.set(AttributeStatus.DB_MSSQL_INSTANCE_NAME); - internalBuilder.setAttribute("db.mssql.instance_name", dbMssqlInstanceName); - return this; - } - - /** - * Sets db.jdbc.driver_classname. - * - * @param dbJdbcDriverClassname The fully-qualified class name of the JDBC driver used to - * connect.. - */ - public DbRedisSpanBuilder setDbJdbcDriverClassname(String dbJdbcDriverClassname) { - status.set(AttributeStatus.DB_JDBC_DRIVER_CLASSNAME); - 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". + * @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) { status.set(AttributeStatus.DB_NAME); @@ -479,9 +388,8 @@ public DbRedisSpanBuilder setDbName(String dbName) { /** * Sets db.statement. - * - * @param dbStatement The database statement being executed.. - *

The value may be sanitized to exclude sensitive information. + * @param dbStatement The database statement being executed. + *

The value may be sanitized to exclude sensitive information. */ public DbRedisSpanBuilder setDbStatement(String dbStatement) { status.set(AttributeStatus.DB_STATEMENT); @@ -491,13 +399,8 @@ public DbRedisSpanBuilder setDbStatement(String dbStatement) { /** * 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). + * @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) { status.set(AttributeStatus.DB_OPERATION); @@ -507,8 +410,7 @@ public DbRedisSpanBuilder setDbOperation(String dbOperation) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ public DbRedisSpanBuilder setNetPeerName(String netPeerName) { status.set(AttributeStatus.NET_PEER_NAME); @@ -518,9 +420,7 @@ public DbRedisSpanBuilder setNetPeerName(String netPeerName) { /** * 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). + * @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) { status.set(AttributeStatus.NET_PEER_IP); @@ -530,8 +430,7 @@ public DbRedisSpanBuilder setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ public DbRedisSpanBuilder setNetPeerPort(long netPeerPort) { status.set(AttributeStatus.NET_PEER_PORT); @@ -541,8 +440,7 @@ public DbRedisSpanBuilder setNetPeerPort(long netPeerPort) { /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ public DbRedisSpanBuilder setNetTransport(String netTransport) { status.set(AttributeStatus.NET_TRANSPORT); @@ -552,15 +450,13 @@ public DbRedisSpanBuilder setNetTransport(String netTransport) { /** * 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.. + * @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) { status.set(AttributeStatus.DB_REDIS_DATABASE_INDEX); internalBuilder.setAttribute("db.redis.database_index", dbRedisDatabaseIndex); return this; } + } -} +} \ No newline at end of file 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 index bcb2f2d40edd..ab6c830fd868 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbSemanticConvention.java @@ -22,104 +22,69 @@ public interface DbSemanticConvention { 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.. + * @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. + *

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.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 DbSemanticConvention setDbMssqlInstanceName(String dbMssqlInstanceName); - - /** - * Sets a value for db.jdbc.driver_classname - * - * @param dbJdbcDriverClassname The fully-qualified class name of the 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". + * @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. + *

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). + * @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). + * @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); -} + +} \ No newline at end of file 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 index af95e0d866fb..17039e8bad22 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DbSpan.java @@ -24,23 +24,17 @@ * Required attributes: * *

* * Conditional attributes: * * @@ -61,8 +55,6 @@ enum AttributeStatus { DB_SYSTEM, DB_CONNECTION_STRING, DB_USER, - DB_MSSQL_INSTANCE_NAME, - DB_JDBC_DRIVER_CLASSNAME, DB_NAME, DB_STATEMENT, DB_OPERATION, @@ -70,6 +62,7 @@ enum AttributeStatus { NET_PEER_IP, NET_PEER_PORT, NET_TRANSPORT; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -97,7 +90,6 @@ public long getValue() { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(DbSpan.class.getName()); - public final AttributeStatus status; protected DbSpan(Span span, AttributeStatus status) { @@ -105,17 +97,18 @@ protected DbSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * 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(Kind.CLIENT); + /** + * 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 createDbSpanBuilder(Tracer tracer, String spanName) { + return new DbSpanBuilder(tracer, spanName).setKind(Span.Kind.CLIENT); } + + /** @return the Span used internally */ @Override public Span getSpan() { @@ -135,8 +128,8 @@ public void end() { // extra constraints. { boolean flag = - (!this.status.isSet(AttributeStatus.NET_PEER_NAME)) - || (!this.status.isSet(AttributeStatus.NET_PEER_IP)); + (!this.status.isSet(AttributeStatus.NET_PEER_NAME) ) || + (!this.status.isSet(AttributeStatus.NET_PEER_IP) ) ; if (flag) { logger.info("Constraint not respected!"); } @@ -165,11 +158,10 @@ public void 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.. + * @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) { @@ -180,9 +172,8 @@ public DbSemanticConvention setDbSystem(String dbSystem) { /** * Sets db.connection_string. - * - * @param dbConnectionString The connection string used to connect to the database.. - *

It is recommended to remove embedded credentials. + * @param dbConnectionString The connection string used to connect to the database. + *

It is recommended to remove embedded credentials. */ @Override public DbSemanticConvention setDbConnectionString(String dbConnectionString) { @@ -193,8 +184,7 @@ public DbSemanticConvention setDbConnectionString(String dbConnectionString) { /** * Sets db.user. - * - * @param dbUser Username for accessing the database.. + * @param dbUser Username for accessing the database. */ @Override public DbSemanticConvention setDbUser(String dbUser) { @@ -203,42 +193,10 @@ public DbSemanticConvention setDbUser(String dbUser) { 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 DbSemanticConvention setDbMssqlInstanceName(String dbMssqlInstanceName) { - status.set(AttributeStatus.DB_MSSQL_INSTANCE_NAME); - delegate.setAttribute("db.mssql.instance_name", dbMssqlInstanceName); - return this; - } - - /** - * Sets db.jdbc.driver_classname. - * - * @param dbJdbcDriverClassname The fully-qualified class name of the JDBC driver used to - * connect.. - */ - @Override - public DbSemanticConvention setDbJdbcDriverClassname(String dbJdbcDriverClassname) { - status.set(AttributeStatus.DB_JDBC_DRIVER_CLASSNAME); - 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". + * @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) { @@ -249,9 +207,8 @@ public DbSemanticConvention setDbName(String dbName) { /** * Sets db.statement. - * - * @param dbStatement The database statement being executed.. - *

The value may be sanitized to exclude sensitive information. + * @param dbStatement The database statement being executed. + *

The value may be sanitized to exclude sensitive information. */ @Override public DbSemanticConvention setDbStatement(String dbStatement) { @@ -262,13 +219,8 @@ public DbSemanticConvention setDbStatement(String dbStatement) { /** * 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). + * @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) { @@ -279,8 +231,7 @@ public DbSemanticConvention setDbOperation(String dbOperation) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ @Override public DbSemanticConvention setNetPeerName(String netPeerName) { @@ -291,9 +242,7 @@ public DbSemanticConvention setNetPeerName(String netPeerName) { /** * 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). + * @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) { @@ -304,8 +253,7 @@ public DbSemanticConvention setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ @Override public DbSemanticConvention setNetPeerPort(long netPeerPort) { @@ -316,8 +264,7 @@ public DbSemanticConvention setNetPeerPort(long netPeerPort) { /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ @Override public DbSemanticConvention setNetTransport(String netTransport) { @@ -326,39 +273,42 @@ public DbSemanticConvention setNetTransport(String netTransport) { return this; } - /** Builder class for {@link DbSpan}. */ - public static class DbSpanBuilder { + + /** + * Builder class for {@link DbSpan}. + */ + public static class DbSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected DbSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public DbSpanBuilder(Builder spanBuilder, long attributes) { + public DbSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public DbSpanBuilder setParent(Span parent) { + public DbSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public DbSpanBuilder setParent(SpanContext remoteParent) { + 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(Kind kind) { + public DbSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -369,11 +319,10 @@ public DbSpan start() { return new DbSpan(this.internalBuilder.startSpan(), status); } + /** * 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.. + * @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) { status.set(AttributeStatus.DB_SYSTEM); @@ -383,9 +332,8 @@ public DbSpanBuilder setDbSystem(String dbSystem) { /** * Sets db.connection_string. - * - * @param dbConnectionString The connection string used to connect to the database.. - *

It is recommended to remove embedded credentials. + * @param dbConnectionString The connection string used to connect to the database. + *

It is recommended to remove embedded credentials. */ public DbSpanBuilder setDbConnectionString(String dbConnectionString) { status.set(AttributeStatus.DB_CONNECTION_STRING); @@ -395,8 +343,7 @@ public DbSpanBuilder setDbConnectionString(String dbConnectionString) { /** * Sets db.user. - * - * @param dbUser Username for accessing the database.. + * @param dbUser Username for accessing the database. */ public DbSpanBuilder setDbUser(String dbUser) { status.set(AttributeStatus.DB_USER); @@ -404,40 +351,10 @@ public DbSpanBuilder setDbUser(String dbUser) { 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 DbSpanBuilder setDbMssqlInstanceName(String dbMssqlInstanceName) { - status.set(AttributeStatus.DB_MSSQL_INSTANCE_NAME); - internalBuilder.setAttribute("db.mssql.instance_name", dbMssqlInstanceName); - return this; - } - - /** - * Sets db.jdbc.driver_classname. - * - * @param dbJdbcDriverClassname The fully-qualified class name of the JDBC driver used to - * connect.. - */ - public DbSpanBuilder setDbJdbcDriverClassname(String dbJdbcDriverClassname) { - status.set(AttributeStatus.DB_JDBC_DRIVER_CLASSNAME); - 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". + * @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) { status.set(AttributeStatus.DB_NAME); @@ -447,9 +364,8 @@ public DbSpanBuilder setDbName(String dbName) { /** * Sets db.statement. - * - * @param dbStatement The database statement being executed.. - *

The value may be sanitized to exclude sensitive information. + * @param dbStatement The database statement being executed. + *

The value may be sanitized to exclude sensitive information. */ public DbSpanBuilder setDbStatement(String dbStatement) { status.set(AttributeStatus.DB_STATEMENT); @@ -459,13 +375,8 @@ public DbSpanBuilder setDbStatement(String dbStatement) { /** * 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). + * @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) { status.set(AttributeStatus.DB_OPERATION); @@ -475,8 +386,7 @@ public DbSpanBuilder setDbOperation(String dbOperation) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ public DbSpanBuilder setNetPeerName(String netPeerName) { status.set(AttributeStatus.NET_PEER_NAME); @@ -486,9 +396,7 @@ public DbSpanBuilder setNetPeerName(String netPeerName) { /** * 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). + * @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) { status.set(AttributeStatus.NET_PEER_IP); @@ -498,8 +406,7 @@ public DbSpanBuilder setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ public DbSpanBuilder setNetPeerPort(long netPeerPort) { status.set(AttributeStatus.NET_PEER_PORT); @@ -509,13 +416,13 @@ public DbSpanBuilder setNetPeerPort(long netPeerPort) { /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ public DbSpanBuilder setNetTransport(String netTransport) { status.set(AttributeStatus.NET_TRANSPORT); internalBuilder.setAttribute("net.transport", netTransport); return this; } + } -} +} \ No newline at end of file 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 index f09e4fb26d46..4e967ed11eff 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DelegatingSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/DelegatingSpan.java @@ -16,6 +16,7 @@ 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; @@ -66,13 +67,12 @@ public void addEvent(final String name, final long timestamp) { } @Override - public void addEvent(final String name, final Map attributes) { + public void addEvent(String name, Attributes attributes) { delegate.addEvent(name, attributes); } @Override - public void addEvent( - final String name, final Map attributes, final long timestamp) { + public void addEvent(String name, Attributes attributes, long timestamp) { delegate.addEvent(name, attributes, timestamp); } diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasDatasourceSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasDatasourceSemanticConvention.java index 5c120c862dfd..7c84e63d91d1 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasDatasourceSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasDatasourceSemanticConvention.java @@ -22,53 +22,43 @@ public interface FaasDatasourceSemanticConvention { Span getSpan(); + /** * Sets a value for faas.trigger - * * @param faasTrigger Type of the trigger on which the function is executed.. */ public FaasDatasourceSemanticConvention setFaasTrigger(String faasTrigger); /** * Sets a value for faas.execution - * * @param faasExecution The execution id of the current function execution.. */ public FaasDatasourceSemanticConvention setFaasExecution(String faasExecution); /** * Sets a value for faas.document.collection - * - * @param faasDocumentCollection The name of the source on which the triggering operation was - * performed.. - *

For example, in Cloud Storage or S3 corresponds to the bucket name, and in Cosmos DB to - * the database name. + * @param faasDocumentCollection The name of the source on which the triggering operation was performed.. + *

For example, in Cloud Storage or S3 corresponds to the bucket name, and in Cosmos DB to the database name. */ public FaasDatasourceSemanticConvention setFaasDocumentCollection(String faasDocumentCollection); /** * Sets a value for faas.document.operation - * - * @param faasDocumentOperation Describes the type of the operation that was performed on the - * data.. + * @param faasDocumentOperation Describes the type of the operation that was performed on the data.. */ public FaasDatasourceSemanticConvention setFaasDocumentOperation(String faasDocumentOperation); /** * Sets a value for faas.document.time - * - * @param faasDocumentTime A string containing the time when the data was accessed in the [ISO - * 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format expressed in - * [UTC](https://www.w3.org/TR/NOTE-datetime).. + * @param faasDocumentTime A string containing the time when the data was accessed in the [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format expressed in [UTC](https://www.w3.org/TR/NOTE-datetime).. */ public FaasDatasourceSemanticConvention setFaasDocumentTime(String faasDocumentTime); /** * Sets a value for faas.document.name - * * @param faasDocumentName The document name/table subjected to the operation.. - *

For example, in Cloud Storage or S3 is the name of the file, and in Cosmos DB the table - * name. + *

For example, in Cloud Storage or S3 is the name of the file, and in Cosmos DB the table name. */ public FaasDatasourceSemanticConvention setFaasDocumentName(String faasDocumentName); -} + +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasDatasourceSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasDatasourceSpan.java index 839aefaf1023..7e09bf56df98 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasDatasourceSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasDatasourceSpan.java @@ -25,19 +25,16 @@ * *

* * Conditional attributes: * * + * */ public class FaasDatasourceSpan extends DelegatingSpan implements FaasDatasourceSemanticConvention { @@ -49,6 +46,7 @@ enum AttributeStatus { FAAS_DOCUMENT_OPERATION, FAAS_DOCUMENT_TIME, FAAS_DOCUMENT_NAME; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -76,7 +74,6 @@ public long getValue() { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(FaasDatasourceSpan.class.getName()); - public final AttributeStatus status; protected FaasDatasourceSpan(Span span, AttributeStatus status) { @@ -84,26 +81,23 @@ protected FaasDatasourceSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * Entry point to generate a {@link FaasDatasourceSpan}. - * - * @param tracer Tracer to use - * @param spanName Name for the {@link Span} - * @return a {@link FaasDatasourceSpan} object. - */ - public static FaasDatasourceSpanBuilder createFaasDatasourceSpan(Tracer tracer, String spanName) { + /** + * Entry point to generate a {@link FaasDatasourceSpan}. + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link FaasDatasourceSpan} object. + */ + public static FaasDatasourceSpanBuilder createFaasDatasourceSpanBuilder(Tracer tracer, String spanName) { return new FaasDatasourceSpanBuilder(tracer, spanName); } /** - * Creates a {@link FaasDatasourceSpan} from a {@link FaasSpan}. - * - * @param builder {@link FaasSpan.FaasSpanBuilder} to use. - * @return a {@link FaasDatasourceSpan} object built from a {@link FaasSpan}. - */ - public static FaasDatasourceSpanBuilder createFaasDatasourceSpan( - FaasSpan.FaasSpanBuilder builder) { - // we accept a builder from Faas since FaasDatasource "extends" Faas + * Creates a {@link FaasDatasourceSpan} from a {@link FaasSpan}. + * @param builder {@link FaasSpan.FaasSpanBuilder} to use. + * @return a {@link FaasDatasourceSpan} object built from a {@link FaasSpan}. + */ + public static FaasDatasourceSpanBuilder createFaasDatasourceSpanBuilder(FaasSpan.FaasSpanBuilder builder) { + // we accept a builder from Faas since FaasDatasource "extends" Faas return new FaasDatasourceSpanBuilder(builder.getSpanBuilder(), builder.status.getValue()); } @@ -136,10 +130,10 @@ public void end() { // conditional attributes } + /** * Sets faas.trigger. - * - * @param faasTrigger Type of the trigger on which the function is executed.. + * @param faasTrigger Type of the trigger on which the function is executed. */ @Override public FaasDatasourceSemanticConvention setFaasTrigger(String faasTrigger) { @@ -150,8 +144,7 @@ public FaasDatasourceSemanticConvention setFaasTrigger(String faasTrigger) { /** * Sets faas.execution. - * - * @param faasExecution The execution id of the current function execution.. + * @param faasExecution The execution id of the current function execution. */ @Override public FaasDatasourceSemanticConvention setFaasExecution(String faasExecution) { @@ -162,11 +155,8 @@ public FaasDatasourceSemanticConvention setFaasExecution(String faasExecution) { /** * Sets faas.document.collection. - * - * @param faasDocumentCollection The name of the source on which the triggering operation was - * performed.. - *

For example, in Cloud Storage or S3 corresponds to the bucket name, and in Cosmos DB to - * the database name. + * @param faasDocumentCollection The name of the source on which the triggering operation was performed. + *

For example, in Cloud Storage or S3 corresponds to the bucket name, and in Cosmos DB to the database name. */ @Override public FaasDatasourceSemanticConvention setFaasDocumentCollection(String faasDocumentCollection) { @@ -177,9 +167,7 @@ public FaasDatasourceSemanticConvention setFaasDocumentCollection(String faasDoc /** * Sets faas.document.operation. - * - * @param faasDocumentOperation Describes the type of the operation that was performed on the - * data.. + * @param faasDocumentOperation Describes the type of the operation that was performed on the data. */ @Override public FaasDatasourceSemanticConvention setFaasDocumentOperation(String faasDocumentOperation) { @@ -190,10 +178,7 @@ public FaasDatasourceSemanticConvention setFaasDocumentOperation(String faasDocu /** * Sets faas.document.time. - * - * @param faasDocumentTime A string containing the time when the data was accessed in the [ISO - * 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format expressed in - * [UTC](https://www.w3.org/TR/NOTE-datetime).. + * @param faasDocumentTime A string containing the time when the data was accessed in the [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format expressed in [UTC](https://www.w3.org/TR/NOTE-datetime). */ @Override public FaasDatasourceSemanticConvention setFaasDocumentTime(String faasDocumentTime) { @@ -204,10 +189,8 @@ public FaasDatasourceSemanticConvention setFaasDocumentTime(String faasDocumentT /** * Sets faas.document.name. - * - * @param faasDocumentName The document name/table subjected to the operation.. - *

For example, in Cloud Storage or S3 is the name of the file, and in Cosmos DB the table - * name. + * @param faasDocumentName The document name/table subjected to the operation. + *

For example, in Cloud Storage or S3 is the name of the file, and in Cosmos DB the table name. */ @Override public FaasDatasourceSemanticConvention setFaasDocumentName(String faasDocumentName) { @@ -216,39 +199,42 @@ public FaasDatasourceSemanticConvention setFaasDocumentName(String faasDocumentN return this; } - /** Builder class for {@link FaasDatasourceSpan}. */ - public static class FaasDatasourceSpanBuilder { + + /** + * Builder class for {@link FaasDatasourceSpan}. + */ + public static class FaasDatasourceSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected FaasDatasourceSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public FaasDatasourceSpanBuilder(Builder spanBuilder, long attributes) { + public FaasDatasourceSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public FaasDatasourceSpanBuilder setParent(Span parent) { + public FaasDatasourceSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public FaasDatasourceSpanBuilder setParent(SpanContext remoteParent) { + public FaasDatasourceSpanBuilder 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 FaasDatasourceSpanBuilder setKind(Kind kind) { + public FaasDatasourceSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -259,10 +245,10 @@ public FaasDatasourceSpan start() { return new FaasDatasourceSpan(this.internalBuilder.startSpan(), status); } + /** * Sets faas.trigger. - * - * @param faasTrigger Type of the trigger on which the function is executed.. + * @param faasTrigger Type of the trigger on which the function is executed. */ public FaasDatasourceSpanBuilder setFaasTrigger(String faasTrigger) { status.set(AttributeStatus.FAAS_TRIGGER); @@ -272,8 +258,7 @@ public FaasDatasourceSpanBuilder setFaasTrigger(String faasTrigger) { /** * Sets faas.execution. - * - * @param faasExecution The execution id of the current function execution.. + * @param faasExecution The execution id of the current function execution. */ public FaasDatasourceSpanBuilder setFaasExecution(String faasExecution) { status.set(AttributeStatus.FAAS_EXECUTION); @@ -283,11 +268,8 @@ public FaasDatasourceSpanBuilder setFaasExecution(String faasExecution) { /** * Sets faas.document.collection. - * - * @param faasDocumentCollection The name of the source on which the triggering operation was - * performed.. - *

For example, in Cloud Storage or S3 corresponds to the bucket name, and in Cosmos DB - * to the database name. + * @param faasDocumentCollection The name of the source on which the triggering operation was performed. + *

For example, in Cloud Storage or S3 corresponds to the bucket name, and in Cosmos DB to the database name. */ public FaasDatasourceSpanBuilder setFaasDocumentCollection(String faasDocumentCollection) { status.set(AttributeStatus.FAAS_DOCUMENT_COLLECTION); @@ -297,9 +279,7 @@ public FaasDatasourceSpanBuilder setFaasDocumentCollection(String faasDocumentCo /** * Sets faas.document.operation. - * - * @param faasDocumentOperation Describes the type of the operation that was performed on the - * data.. + * @param faasDocumentOperation Describes the type of the operation that was performed on the data. */ public FaasDatasourceSpanBuilder setFaasDocumentOperation(String faasDocumentOperation) { status.set(AttributeStatus.FAAS_DOCUMENT_OPERATION); @@ -309,10 +289,7 @@ public FaasDatasourceSpanBuilder setFaasDocumentOperation(String faasDocumentOpe /** * Sets faas.document.time. - * - * @param faasDocumentTime A string containing the time when the data was accessed in the [ISO - * 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format expressed in - * [UTC](https://www.w3.org/TR/NOTE-datetime).. + * @param faasDocumentTime A string containing the time when the data was accessed in the [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format expressed in [UTC](https://www.w3.org/TR/NOTE-datetime). */ public FaasDatasourceSpanBuilder setFaasDocumentTime(String faasDocumentTime) { status.set(AttributeStatus.FAAS_DOCUMENT_TIME); @@ -322,15 +299,14 @@ public FaasDatasourceSpanBuilder setFaasDocumentTime(String faasDocumentTime) { /** * Sets faas.document.name. - * - * @param faasDocumentName The document name/table subjected to the operation.. - *

For example, in Cloud Storage or S3 is the name of the file, and in Cosmos DB the - * table name. + * @param faasDocumentName The document name/table subjected to the operation. + *

For example, in Cloud Storage or S3 is the name of the file, and in Cosmos DB the table name. */ public FaasDatasourceSpanBuilder setFaasDocumentName(String faasDocumentName) { status.set(AttributeStatus.FAAS_DOCUMENT_NAME); internalBuilder.setAttribute("faas.document.name", faasDocumentName); return this; } + } -} +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasHttpSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasHttpSemanticConvention.java index 5d4c420f726b..db8cd0c010dd 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasHttpSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasHttpSemanticConvention.java @@ -22,169 +22,134 @@ public interface FaasHttpSemanticConvention { Span getSpan(); + /** * Sets a value for faas.trigger - * * @param faasTrigger Type of the trigger on which the function is executed.. */ public FaasHttpSemanticConvention setFaasTrigger(String faasTrigger); /** * Sets a value for faas.execution - * * @param faasExecution The execution id of the current function execution.. */ public FaasHttpSemanticConvention setFaasExecution(String faasExecution); /** * Sets a value for http.server_name - * - * @param httpServerName The primary server name of the matched virtual host. This should be - * obtained via configuration. If no such configuration can be obtained, this attribute MUST - * NOT be set ( `net.host.name` should be used instead).. - *

http.url is usually not readily available on the server side but would have to be - * assembled in a cumbersome and sometimes lossy process from other information (see e.g. - * open-telemetry/opentelemetry-python/pull/148). It is thus preferred to supply the raw data - * that is available. + * @param httpServerName The primary server name of the matched virtual host. This should be obtained via configuration. If no such configuration can be obtained, this attribute MUST NOT be set ( `net.host.name` should be used instead).. + *

http.url is usually not readily available on the server side but would have to be assembled in a cumbersome and sometimes lossy process from other information (see e.g. open-telemetry/opentelemetry-python/pull/148). It is thus preferred to supply the raw data that is available. */ public FaasHttpSemanticConvention setHttpServerName(String httpServerName); /** * Sets a value for http.route - * * @param httpRoute The matched route (path template).. */ public FaasHttpSemanticConvention setHttpRoute(String httpRoute); /** * Sets a value for http.client_ip - * - * @param httpClientIp The IP address of the original client behind all proxies, if known (e.g. - * from - * [X-Forwarded-For](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For)).. - *

This is not necessarily the same as `net.peer.ip`, which would identify the - * network-level peer, which may be a proxy. + * @param httpClientIp The IP address of the original client behind all proxies, if known (e.g. from [X-Forwarded-For](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For)).. + *

This is not necessarily the same as `net.peer.ip`, which would identify the network-level peer, which may be a proxy. */ public FaasHttpSemanticConvention setHttpClientIp(String httpClientIp); /** * Sets a value for http.method - * * @param httpMethod HTTP request method.. */ public FaasHttpSemanticConvention setHttpMethod(String httpMethod); /** * Sets a value for http.url - * - * @param httpUrl Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. - * Usually the fragment is not transmitted over HTTP, but if it is known, it should be - * included nevertheless.. + * @param httpUrl Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. Usually the fragment is not transmitted over HTTP, but if it is known, it should be included nevertheless.. */ public FaasHttpSemanticConvention setHttpUrl(String httpUrl); /** * Sets a value for http.target - * * @param httpTarget The full request target as passed in a HTTP request line or equivalent.. */ public FaasHttpSemanticConvention setHttpTarget(String httpTarget); /** * Sets a value for http.host - * - * @param httpHost The value of the [HTTP host - * header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not - * present, this attribute should be the same.. + * @param httpHost The value of the [HTTP host header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not present, this attribute should be the same.. */ public FaasHttpSemanticConvention setHttpHost(String httpHost); /** * Sets a value for http.scheme - * * @param httpScheme The URI scheme identifying the used protocol.. */ public FaasHttpSemanticConvention setHttpScheme(String httpScheme); /** * Sets a value for http.status_code - * - * @param httpStatusCode [HTTP response status - * code](https://tools.ietf.org/html/rfc7231#section-6).. + * @param httpStatusCode [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6).. */ public FaasHttpSemanticConvention setHttpStatusCode(long httpStatusCode); /** * Sets a value for http.status_text - * * @param httpStatusText [HTTP reason phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2).. */ public FaasHttpSemanticConvention setHttpStatusText(String httpStatusText); /** * Sets a value for http.flavor - * * @param httpFlavor Kind of HTTP protocol used. - *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if - * `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. + *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. */ public FaasHttpSemanticConvention setHttpFlavor(String httpFlavor); /** * Sets a value for http.user_agent - * - * @param httpUserAgent Value of the [HTTP - * User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the client.. + * @param httpUserAgent Value of the [HTTP User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the client.. */ public FaasHttpSemanticConvention setHttpUserAgent(String httpUserAgent); /** * Sets a value for net.transport - * * @param netTransport Transport protocol used. See note below.. */ public FaasHttpSemanticConvention setNetTransport(String netTransport); /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public FaasHttpSemanticConvention setNetPeerIp(String netPeerIp); /** * Sets a value for net.peer.port - * * @param netPeerPort Remote port number.. */ public FaasHttpSemanticConvention setNetPeerPort(long netPeerPort); /** * Sets a value for net.peer.name - * * @param netPeerName Remote hostname or similar, see note below.. */ public FaasHttpSemanticConvention setNetPeerName(String netPeerName); /** * Sets a value for net.host.ip - * * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. */ public FaasHttpSemanticConvention setNetHostIp(String netHostIp); /** * Sets a value for net.host.port - * * @param netHostPort Like `net.peer.port` but for the host port.. */ public FaasHttpSemanticConvention setNetHostPort(long netHostPort); /** * Sets a value for net.host.name - * * @param netHostName Local hostname or similar, see note below.. */ public FaasHttpSemanticConvention setNetHostName(String netHostName); -} + +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasHttpSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasHttpSpan.java index 8ef9879b177d..3f0013564da8 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasHttpSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasHttpSpan.java @@ -31,8 +31,7 @@ * Conditional attributes: * *

* * Additional constraints @@ -71,6 +70,7 @@ enum AttributeStatus { NET_HOST_IP, NET_HOST_PORT, NET_HOST_NAME; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -98,7 +98,6 @@ public long getValue() { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(FaasHttpSpan.class.getName()); - public final AttributeStatus status; protected FaasHttpSpan(Span span, AttributeStatus status) { @@ -106,25 +105,23 @@ protected FaasHttpSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * Entry point to generate a {@link FaasHttpSpan}. - * - * @param tracer Tracer to use - * @param spanName Name for the {@link Span} - * @return a {@link FaasHttpSpan} object. - */ - public static FaasHttpSpanBuilder createFaasHttpSpan(Tracer tracer, String spanName) { + /** + * Entry point to generate a {@link FaasHttpSpan}. + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link FaasHttpSpan} object. + */ + public static FaasHttpSpanBuilder createFaasHttpSpanBuilder(Tracer tracer, String spanName) { return new FaasHttpSpanBuilder(tracer, spanName); } /** - * Creates a {@link FaasHttpSpan} from a {@link FaasSpan}. - * - * @param builder {@link FaasSpan.FaasSpanBuilder} to use. - * @return a {@link FaasHttpSpan} object built from a {@link FaasSpan}. - */ - public static FaasHttpSpanBuilder createFaasHttpSpan(FaasSpan.FaasSpanBuilder builder) { - // we accept a builder from Faas since FaasHttp "extends" Faas + * Creates a {@link FaasHttpSpan} from a {@link FaasSpan}. + * @param builder {@link FaasSpan.FaasSpanBuilder} to use. + * @return a {@link FaasHttpSpan} object built from a {@link FaasSpan}. + */ + public static FaasHttpSpanBuilder createFaasHttpSpanBuilder(FaasSpan.FaasSpanBuilder builder) { + // we accept a builder from Faas since FaasHttp "extends" Faas return new FaasHttpSpanBuilder(builder.getSpanBuilder(), builder.status.getValue()); } @@ -150,18 +147,10 @@ public void end() { // extra constraints. { boolean flag = - (!this.status.isSet(AttributeStatus.HTTP_URL)) - || (!this.status.isSet(AttributeStatus.HTTP_SCHEME) - && !this.status.isSet(AttributeStatus.HTTP_HOST) - && !this.status.isSet(AttributeStatus.HTTP_TARGET)) - || (!this.status.isSet(AttributeStatus.HTTP_SCHEME) - && !this.status.isSet(AttributeStatus.HTTP_SERVER_NAME) - && !this.status.isSet(AttributeStatus.NET_HOST_PORT) - && !this.status.isSet(AttributeStatus.HTTP_TARGET)) - || (!this.status.isSet(AttributeStatus.HTTP_SCHEME) - && !this.status.isSet(AttributeStatus.NET_HOST_NAME) - && !this.status.isSet(AttributeStatus.NET_HOST_PORT) - && !this.status.isSet(AttributeStatus.HTTP_TARGET)); + (!this.status.isSet(AttributeStatus.HTTP_URL) ) || + (!this.status.isSet(AttributeStatus.HTTP_SCHEME) &&!this.status.isSet(AttributeStatus.HTTP_HOST) &&!this.status.isSet(AttributeStatus.HTTP_TARGET) ) || + (!this.status.isSet(AttributeStatus.HTTP_SCHEME) &&!this.status.isSet(AttributeStatus.HTTP_SERVER_NAME) &&!this.status.isSet(AttributeStatus.NET_HOST_PORT) &&!this.status.isSet(AttributeStatus.HTTP_TARGET) ) || + (!this.status.isSet(AttributeStatus.HTTP_SCHEME) &&!this.status.isSet(AttributeStatus.NET_HOST_NAME) &&!this.status.isSet(AttributeStatus.NET_HOST_PORT) &&!this.status.isSet(AttributeStatus.HTTP_TARGET) ) ; if (flag) { logger.info("Constraint not respected!"); } @@ -172,10 +161,10 @@ public void end() { } } + /** * Sets faas.trigger. - * - * @param faasTrigger Type of the trigger on which the function is executed.. + * @param faasTrigger Type of the trigger on which the function is executed. */ @Override public FaasHttpSemanticConvention setFaasTrigger(String faasTrigger) { @@ -186,8 +175,7 @@ public FaasHttpSemanticConvention setFaasTrigger(String faasTrigger) { /** * Sets faas.execution. - * - * @param faasExecution The execution id of the current function execution.. + * @param faasExecution The execution id of the current function execution. */ @Override public FaasHttpSemanticConvention setFaasExecution(String faasExecution) { @@ -198,14 +186,8 @@ public FaasHttpSemanticConvention setFaasExecution(String faasExecution) { /** * Sets http.server_name. - * - * @param httpServerName The primary server name of the matched virtual host. This should be - * obtained via configuration. If no such configuration can be obtained, this attribute MUST - * NOT be set ( `net.host.name` should be used instead).. - *

http.url is usually not readily available on the server side but would have to be - * assembled in a cumbersome and sometimes lossy process from other information (see e.g. - * open-telemetry/opentelemetry-python/pull/148). It is thus preferred to supply the raw data - * that is available. + * @param httpServerName The primary server name of the matched virtual host. This should be obtained via configuration. If no such configuration can be obtained, this attribute MUST NOT be set ( `net.host.name` should be used instead). + *

http.url is usually not readily available on the server side but would have to be assembled in a cumbersome and sometimes lossy process from other information (see e.g. open-telemetry/opentelemetry-python/pull/148). It is thus preferred to supply the raw data that is available. */ @Override public FaasHttpSemanticConvention setHttpServerName(String httpServerName) { @@ -216,8 +198,7 @@ public FaasHttpSemanticConvention setHttpServerName(String httpServerName) { /** * Sets http.route. - * - * @param httpRoute The matched route (path template).. + * @param httpRoute The matched route (path template). */ @Override public FaasHttpSemanticConvention setHttpRoute(String httpRoute) { @@ -228,12 +209,8 @@ public FaasHttpSemanticConvention setHttpRoute(String httpRoute) { /** * Sets http.client_ip. - * - * @param httpClientIp The IP address of the original client behind all proxies, if known (e.g. - * from - * [X-Forwarded-For](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For)).. - *

This is not necessarily the same as `net.peer.ip`, which would identify the - * network-level peer, which may be a proxy. + * @param httpClientIp The IP address of the original client behind all proxies, if known (e.g. from [X-Forwarded-For](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For)). + *

This is not necessarily the same as `net.peer.ip`, which would identify the network-level peer, which may be a proxy. */ @Override public FaasHttpSemanticConvention setHttpClientIp(String httpClientIp) { @@ -244,8 +221,7 @@ public FaasHttpSemanticConvention setHttpClientIp(String httpClientIp) { /** * Sets http.method. - * - * @param httpMethod HTTP request method.. + * @param httpMethod HTTP request method. */ @Override public FaasHttpSemanticConvention setHttpMethod(String httpMethod) { @@ -256,10 +232,7 @@ public FaasHttpSemanticConvention setHttpMethod(String httpMethod) { /** * Sets http.url. - * - * @param httpUrl Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. - * Usually the fragment is not transmitted over HTTP, but if it is known, it should be - * included nevertheless.. + * @param httpUrl Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. Usually the fragment is not transmitted over HTTP, but if it is known, it should be included nevertheless. */ @Override public FaasHttpSemanticConvention setHttpUrl(String httpUrl) { @@ -270,8 +243,7 @@ public FaasHttpSemanticConvention setHttpUrl(String httpUrl) { /** * Sets http.target. - * - * @param httpTarget The full request target as passed in a HTTP request line or equivalent.. + * @param httpTarget The full request target as passed in a HTTP request line or equivalent. */ @Override public FaasHttpSemanticConvention setHttpTarget(String httpTarget) { @@ -282,10 +254,7 @@ public FaasHttpSemanticConvention setHttpTarget(String httpTarget) { /** * Sets http.host. - * - * @param httpHost The value of the [HTTP host - * header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not - * present, this attribute should be the same.. + * @param httpHost The value of the [HTTP host header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not present, this attribute should be the same. */ @Override public FaasHttpSemanticConvention setHttpHost(String httpHost) { @@ -296,8 +265,7 @@ public FaasHttpSemanticConvention setHttpHost(String httpHost) { /** * Sets http.scheme. - * - * @param httpScheme The URI scheme identifying the used protocol.. + * @param httpScheme The URI scheme identifying the used protocol. */ @Override public FaasHttpSemanticConvention setHttpScheme(String httpScheme) { @@ -308,9 +276,7 @@ public FaasHttpSemanticConvention setHttpScheme(String httpScheme) { /** * Sets http.status_code. - * - * @param httpStatusCode [HTTP response status - * code](https://tools.ietf.org/html/rfc7231#section-6).. + * @param httpStatusCode [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). */ @Override public FaasHttpSemanticConvention setHttpStatusCode(long httpStatusCode) { @@ -321,8 +287,7 @@ public FaasHttpSemanticConvention setHttpStatusCode(long httpStatusCode) { /** * Sets http.status_text. - * - * @param httpStatusText [HTTP reason phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2).. + * @param httpStatusText [HTTP reason phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2). */ @Override public FaasHttpSemanticConvention setHttpStatusText(String httpStatusText) { @@ -333,10 +298,8 @@ public FaasHttpSemanticConvention setHttpStatusText(String httpStatusText) { /** * Sets http.flavor. - * * @param httpFlavor Kind of HTTP protocol used. - *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if - * `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. + *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. */ @Override public FaasHttpSemanticConvention setHttpFlavor(String httpFlavor) { @@ -347,9 +310,7 @@ public FaasHttpSemanticConvention setHttpFlavor(String httpFlavor) { /** * Sets http.user_agent. - * - * @param httpUserAgent Value of the [HTTP - * User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the client.. + * @param httpUserAgent Value of the [HTTP User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the client. */ @Override public FaasHttpSemanticConvention setHttpUserAgent(String httpUserAgent) { @@ -360,8 +321,7 @@ public FaasHttpSemanticConvention setHttpUserAgent(String httpUserAgent) { /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ @Override public FaasHttpSemanticConvention setNetTransport(String netTransport) { @@ -372,9 +332,7 @@ public FaasHttpSemanticConvention setNetTransport(String netTransport) { /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ @Override public FaasHttpSemanticConvention setNetPeerIp(String netPeerIp) { @@ -385,8 +343,7 @@ public FaasHttpSemanticConvention setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ @Override public FaasHttpSemanticConvention setNetPeerPort(long netPeerPort) { @@ -397,8 +354,7 @@ public FaasHttpSemanticConvention setNetPeerPort(long netPeerPort) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ @Override public FaasHttpSemanticConvention setNetPeerName(String netPeerName) { @@ -409,8 +365,7 @@ public FaasHttpSemanticConvention setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ @Override public FaasHttpSemanticConvention setNetHostIp(String netHostIp) { @@ -421,8 +376,7 @@ public FaasHttpSemanticConvention setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ @Override public FaasHttpSemanticConvention setNetHostPort(long netHostPort) { @@ -433,8 +387,7 @@ public FaasHttpSemanticConvention setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ @Override public FaasHttpSemanticConvention setNetHostName(String netHostName) { @@ -443,39 +396,42 @@ public FaasHttpSemanticConvention setNetHostName(String netHostName) { return this; } - /** Builder class for {@link FaasHttpSpan}. */ - public static class FaasHttpSpanBuilder { + + /** + * Builder class for {@link FaasHttpSpan}. + */ + public static class FaasHttpSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected FaasHttpSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public FaasHttpSpanBuilder(Builder spanBuilder, long attributes) { + public FaasHttpSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public FaasHttpSpanBuilder setParent(Span parent) { + public FaasHttpSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public FaasHttpSpanBuilder setParent(SpanContext remoteParent) { + public FaasHttpSpanBuilder 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 FaasHttpSpanBuilder setKind(Kind kind) { + public FaasHttpSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -486,10 +442,10 @@ public FaasHttpSpan start() { return new FaasHttpSpan(this.internalBuilder.startSpan(), status); } + /** * Sets faas.trigger. - * - * @param faasTrigger Type of the trigger on which the function is executed.. + * @param faasTrigger Type of the trigger on which the function is executed. */ public FaasHttpSpanBuilder setFaasTrigger(String faasTrigger) { status.set(AttributeStatus.FAAS_TRIGGER); @@ -499,8 +455,7 @@ public FaasHttpSpanBuilder setFaasTrigger(String faasTrigger) { /** * Sets faas.execution. - * - * @param faasExecution The execution id of the current function execution.. + * @param faasExecution The execution id of the current function execution. */ public FaasHttpSpanBuilder setFaasExecution(String faasExecution) { status.set(AttributeStatus.FAAS_EXECUTION); @@ -510,14 +465,8 @@ public FaasHttpSpanBuilder setFaasExecution(String faasExecution) { /** * Sets http.server_name. - * - * @param httpServerName The primary server name of the matched virtual host. This should be - * obtained via configuration. If no such configuration can be obtained, this attribute MUST - * NOT be set ( `net.host.name` should be used instead).. - *

http.url is usually not readily available on the server side but would have to be - * assembled in a cumbersome and sometimes lossy process from other information (see e.g. - * open-telemetry/opentelemetry-python/pull/148). It is thus preferred to supply the raw - * data that is available. + * @param httpServerName The primary server name of the matched virtual host. This should be obtained via configuration. If no such configuration can be obtained, this attribute MUST NOT be set ( `net.host.name` should be used instead). + *

http.url is usually not readily available on the server side but would have to be assembled in a cumbersome and sometimes lossy process from other information (see e.g. open-telemetry/opentelemetry-python/pull/148). It is thus preferred to supply the raw data that is available. */ public FaasHttpSpanBuilder setHttpServerName(String httpServerName) { status.set(AttributeStatus.HTTP_SERVER_NAME); @@ -527,8 +476,7 @@ public FaasHttpSpanBuilder setHttpServerName(String httpServerName) { /** * Sets http.route. - * - * @param httpRoute The matched route (path template).. + * @param httpRoute The matched route (path template). */ public FaasHttpSpanBuilder setHttpRoute(String httpRoute) { status.set(AttributeStatus.HTTP_ROUTE); @@ -538,12 +486,8 @@ public FaasHttpSpanBuilder setHttpRoute(String httpRoute) { /** * Sets http.client_ip. - * - * @param httpClientIp The IP address of the original client behind all proxies, if known (e.g. - * from - * [X-Forwarded-For](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For)).. - *

This is not necessarily the same as `net.peer.ip`, which would identify the - * network-level peer, which may be a proxy. + * @param httpClientIp The IP address of the original client behind all proxies, if known (e.g. from [X-Forwarded-For](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For)). + *

This is not necessarily the same as `net.peer.ip`, which would identify the network-level peer, which may be a proxy. */ public FaasHttpSpanBuilder setHttpClientIp(String httpClientIp) { status.set(AttributeStatus.HTTP_CLIENT_IP); @@ -553,8 +497,7 @@ public FaasHttpSpanBuilder setHttpClientIp(String httpClientIp) { /** * Sets http.method. - * - * @param httpMethod HTTP request method.. + * @param httpMethod HTTP request method. */ public FaasHttpSpanBuilder setHttpMethod(String httpMethod) { status.set(AttributeStatus.HTTP_METHOD); @@ -564,10 +507,7 @@ public FaasHttpSpanBuilder setHttpMethod(String httpMethod) { /** * Sets http.url. - * - * @param httpUrl Full HTTP request URL in the form - * `scheme://host[:port]/path?query[#fragment]`. Usually the fragment is not transmitted - * over HTTP, but if it is known, it should be included nevertheless.. + * @param httpUrl Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. Usually the fragment is not transmitted over HTTP, but if it is known, it should be included nevertheless. */ public FaasHttpSpanBuilder setHttpUrl(String httpUrl) { status.set(AttributeStatus.HTTP_URL); @@ -577,8 +517,7 @@ public FaasHttpSpanBuilder setHttpUrl(String httpUrl) { /** * Sets http.target. - * - * @param httpTarget The full request target as passed in a HTTP request line or equivalent.. + * @param httpTarget The full request target as passed in a HTTP request line or equivalent. */ public FaasHttpSpanBuilder setHttpTarget(String httpTarget) { status.set(AttributeStatus.HTTP_TARGET); @@ -588,10 +527,7 @@ public FaasHttpSpanBuilder setHttpTarget(String httpTarget) { /** * Sets http.host. - * - * @param httpHost The value of the [HTTP host - * header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not - * present, this attribute should be the same.. + * @param httpHost The value of the [HTTP host header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not present, this attribute should be the same. */ public FaasHttpSpanBuilder setHttpHost(String httpHost) { status.set(AttributeStatus.HTTP_HOST); @@ -601,8 +537,7 @@ public FaasHttpSpanBuilder setHttpHost(String httpHost) { /** * Sets http.scheme. - * - * @param httpScheme The URI scheme identifying the used protocol.. + * @param httpScheme The URI scheme identifying the used protocol. */ public FaasHttpSpanBuilder setHttpScheme(String httpScheme) { status.set(AttributeStatus.HTTP_SCHEME); @@ -612,9 +547,7 @@ public FaasHttpSpanBuilder setHttpScheme(String httpScheme) { /** * Sets http.status_code. - * - * @param httpStatusCode [HTTP response status - * code](https://tools.ietf.org/html/rfc7231#section-6).. + * @param httpStatusCode [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). */ public FaasHttpSpanBuilder setHttpStatusCode(long httpStatusCode) { status.set(AttributeStatus.HTTP_STATUS_CODE); @@ -624,9 +557,7 @@ public FaasHttpSpanBuilder setHttpStatusCode(long httpStatusCode) { /** * Sets http.status_text. - * - * @param httpStatusText [HTTP reason - * phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2).. + * @param httpStatusText [HTTP reason phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2). */ public FaasHttpSpanBuilder setHttpStatusText(String httpStatusText) { status.set(AttributeStatus.HTTP_STATUS_TEXT); @@ -636,10 +567,8 @@ public FaasHttpSpanBuilder setHttpStatusText(String httpStatusText) { /** * Sets http.flavor. - * * @param httpFlavor Kind of HTTP protocol used. - *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if - * `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. + *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. */ public FaasHttpSpanBuilder setHttpFlavor(String httpFlavor) { status.set(AttributeStatus.HTTP_FLAVOR); @@ -649,10 +578,7 @@ public FaasHttpSpanBuilder setHttpFlavor(String httpFlavor) { /** * Sets http.user_agent. - * - * @param httpUserAgent Value of the [HTTP - * User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the - * client.. + * @param httpUserAgent Value of the [HTTP User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the client. */ public FaasHttpSpanBuilder setHttpUserAgent(String httpUserAgent) { status.set(AttributeStatus.HTTP_USER_AGENT); @@ -662,8 +588,7 @@ public FaasHttpSpanBuilder setHttpUserAgent(String httpUserAgent) { /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ public FaasHttpSpanBuilder setNetTransport(String netTransport) { status.set(AttributeStatus.NET_TRANSPORT); @@ -673,9 +598,7 @@ public FaasHttpSpanBuilder setNetTransport(String netTransport) { /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public FaasHttpSpanBuilder setNetPeerIp(String netPeerIp) { status.set(AttributeStatus.NET_PEER_IP); @@ -685,8 +608,7 @@ public FaasHttpSpanBuilder setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ public FaasHttpSpanBuilder setNetPeerPort(long netPeerPort) { status.set(AttributeStatus.NET_PEER_PORT); @@ -696,8 +618,7 @@ public FaasHttpSpanBuilder setNetPeerPort(long netPeerPort) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ public FaasHttpSpanBuilder setNetPeerName(String netPeerName) { status.set(AttributeStatus.NET_PEER_NAME); @@ -707,8 +628,7 @@ public FaasHttpSpanBuilder setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ public FaasHttpSpanBuilder setNetHostIp(String netHostIp) { status.set(AttributeStatus.NET_HOST_IP); @@ -718,8 +638,7 @@ public FaasHttpSpanBuilder setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ public FaasHttpSpanBuilder setNetHostPort(long netHostPort) { status.set(AttributeStatus.NET_HOST_PORT); @@ -729,13 +648,13 @@ public FaasHttpSpanBuilder setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ public FaasHttpSpanBuilder setNetHostName(String netHostName) { status.set(AttributeStatus.NET_HOST_NAME); internalBuilder.setAttribute("net.host.name", netHostName); return this; } + } -} +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasPubsubSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasPubsubSemanticConvention.java index 591e2ef8b5cc..7921f1f87ef5 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasPubsubSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasPubsubSemanticConvention.java @@ -22,153 +22,125 @@ public interface FaasPubsubSemanticConvention { Span getSpan(); + /** * Sets a value for faas.trigger - * * @param faasTrigger Type of the trigger on which the function is executed.. */ public FaasPubsubSemanticConvention setFaasTrigger(String faasTrigger); /** * Sets a value for faas.execution - * * @param faasExecution The execution id of the current function execution.. */ public FaasPubsubSemanticConvention setFaasExecution(String faasExecution); /** * Sets a value for messaging.system - * * @param messagingSystem A string identifying the messaging system.. */ public FaasPubsubSemanticConvention setMessagingSystem(String messagingSystem); /** * Sets a value for messaging.destination - * - * @param messagingDestination The message destination name. This might be equal to the span name - * but is required nevertheless.. + * @param messagingDestination The message destination name. This might be equal to the span name but is required nevertheless.. */ public FaasPubsubSemanticConvention setMessagingDestination(String messagingDestination); /** * Sets a value for messaging.destination_kind - * * @param messagingDestinationKind The kind of message destination. */ public FaasPubsubSemanticConvention setMessagingDestinationKind(String messagingDestinationKind); /** * Sets a value for messaging.temp_destination - * - * @param messagingTempDestination A boolean that is true if the message destination is - * temporary.. + * @param messagingTempDestination A boolean that is true if the message destination is temporary.. */ public FaasPubsubSemanticConvention setMessagingTempDestination(boolean messagingTempDestination); /** * Sets a value for messaging.protocol - * * @param messagingProtocol The name of the transport protocol.. */ public FaasPubsubSemanticConvention setMessagingProtocol(String messagingProtocol); /** * Sets a value for messaging.protocol_version - * * @param messagingProtocolVersion The version of the transport protocol.. */ public FaasPubsubSemanticConvention setMessagingProtocolVersion(String messagingProtocolVersion); /** * Sets a value for messaging.url - * * @param messagingUrl Connection string.. */ public FaasPubsubSemanticConvention setMessagingUrl(String messagingUrl); /** * Sets a value for messaging.message_id - * - * @param messagingMessageId A value used by the messaging system as an identifier for the - * message, represented as a string.. + * @param messagingMessageId A value used by the messaging system as an identifier for the message, represented as a string.. */ public FaasPubsubSemanticConvention setMessagingMessageId(String messagingMessageId); /** * Sets a value for messaging.conversation_id - * - * @param messagingConversationId A value identifying the conversation to which the message - * belongs, represented as a string. Sometimes called "Correlation ID".. + * @param messagingConversationId A value identifying the conversation to which the message belongs, represented as a string. Sometimes called "Correlation ID".. */ public FaasPubsubSemanticConvention setMessagingConversationId(String messagingConversationId); /** * Sets a value for messaging.message_payload_size_bytes - * - * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in - * bytes. Also use this attribute if it is unknown whether the compressed or uncompressed - * payload size is reported.. + * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in bytes. Also use this attribute if it is unknown whether the compressed or uncompressed payload size is reported.. */ - public FaasPubsubSemanticConvention setMessagingMessagePayloadSizeBytes( - long messagingMessagePayloadSizeBytes); + public FaasPubsubSemanticConvention setMessagingMessagePayloadSizeBytes(long messagingMessagePayloadSizeBytes); /** * Sets a value for messaging.message_payload_compressed_size_bytes - * - * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in - * bytes.. + * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in bytes.. */ - public FaasPubsubSemanticConvention setMessagingMessagePayloadCompressedSizeBytes( - long messagingMessagePayloadCompressedSizeBytes); + public FaasPubsubSemanticConvention setMessagingMessagePayloadCompressedSizeBytes(long messagingMessagePayloadCompressedSizeBytes); /** * Sets a value for net.peer.port - * * @param netPeerPort Remote port number.. */ public FaasPubsubSemanticConvention setNetPeerPort(long netPeerPort); /** * Sets a value for net.transport - * * @param netTransport Strongly recommended for in-process queueing systems. */ public FaasPubsubSemanticConvention setNetTransport(String netTransport); /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public FaasPubsubSemanticConvention setNetPeerIp(String netPeerIp); /** * Sets a value for net.peer.name - * * @param netPeerName Remote hostname or similar, see note below.. */ public FaasPubsubSemanticConvention setNetPeerName(String netPeerName); /** * Sets a value for net.host.ip - * * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. */ public FaasPubsubSemanticConvention setNetHostIp(String netHostIp); /** * Sets a value for net.host.port - * * @param netHostPort Like `net.peer.port` but for the host port.. */ public FaasPubsubSemanticConvention setNetHostPort(long netHostPort); /** * Sets a value for net.host.name - * * @param netHostName Local hostname or similar, see note below.. */ public FaasPubsubSemanticConvention setNetHostName(String netHostName); -} + +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasPubsubSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasPubsubSpan.java index 3e355fb721dc..259234d0d739 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasPubsubSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasPubsubSpan.java @@ -26,8 +26,7 @@ *

* * Conditional attributes: @@ -70,6 +69,7 @@ enum AttributeStatus { NET_HOST_IP, NET_HOST_PORT, NET_HOST_NAME; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -97,7 +97,6 @@ public long getValue() { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(FaasPubsubSpan.class.getName()); - public final AttributeStatus status; protected FaasPubsubSpan(Span span, AttributeStatus status) { @@ -105,25 +104,23 @@ protected FaasPubsubSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * Entry point to generate a {@link FaasPubsubSpan}. - * - * @param tracer Tracer to use - * @param spanName Name for the {@link Span} - * @return a {@link FaasPubsubSpan} object. - */ - public static FaasPubsubSpanBuilder createFaasPubsubSpan(Tracer tracer, String spanName) { + /** + * Entry point to generate a {@link FaasPubsubSpan}. + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link FaasPubsubSpan} object. + */ + public static FaasPubsubSpanBuilder createFaasPubsubSpanBuilder(Tracer tracer, String spanName) { return new FaasPubsubSpanBuilder(tracer, spanName); } /** - * Creates a {@link FaasPubsubSpan} from a {@link FaasSpan}. - * - * @param builder {@link FaasSpan.FaasSpanBuilder} to use. - * @return a {@link FaasPubsubSpan} object built from a {@link FaasSpan}. - */ - public static FaasPubsubSpanBuilder createFaasPubsubSpan(FaasSpan.FaasSpanBuilder builder) { - // we accept a builder from Faas since FaasPubsub "extends" Faas + * Creates a {@link FaasPubsubSpan} from a {@link FaasSpan}. + * @param builder {@link FaasSpan.FaasSpanBuilder} to use. + * @return a {@link FaasPubsubSpan} object built from a {@link FaasSpan}. + */ + public static FaasPubsubSpanBuilder createFaasPubsubSpanBuilder(FaasSpan.FaasSpanBuilder builder) { + // we accept a builder from Faas since FaasPubsub "extends" Faas return new FaasPubsubSpanBuilder(builder.getSpanBuilder(), builder.status.getValue()); } @@ -152,8 +149,8 @@ public void end() { // extra constraints. { boolean flag = - (!this.status.isSet(AttributeStatus.NET_PEER_NAME)) - || (!this.status.isSet(AttributeStatus.NET_PEER_IP)); + (!this.status.isSet(AttributeStatus.NET_PEER_NAME) ) || + (!this.status.isSet(AttributeStatus.NET_PEER_IP) ) ; if (flag) { logger.info("Constraint not respected!"); } @@ -167,10 +164,10 @@ public void end() { } } + /** * Sets faas.trigger. - * - * @param faasTrigger Type of the trigger on which the function is executed.. + * @param faasTrigger Type of the trigger on which the function is executed. */ @Override public FaasPubsubSemanticConvention setFaasTrigger(String faasTrigger) { @@ -181,8 +178,7 @@ public FaasPubsubSemanticConvention setFaasTrigger(String faasTrigger) { /** * Sets faas.execution. - * - * @param faasExecution The execution id of the current function execution.. + * @param faasExecution The execution id of the current function execution. */ @Override public FaasPubsubSemanticConvention setFaasExecution(String faasExecution) { @@ -193,8 +189,7 @@ public FaasPubsubSemanticConvention setFaasExecution(String faasExecution) { /** * Sets messaging.system. - * - * @param messagingSystem A string identifying the messaging system.. + * @param messagingSystem A string identifying the messaging system. */ @Override public FaasPubsubSemanticConvention setMessagingSystem(String messagingSystem) { @@ -205,9 +200,7 @@ public FaasPubsubSemanticConvention setMessagingSystem(String messagingSystem) { /** * Sets messaging.destination. - * - * @param messagingDestination The message destination name. This might be equal to the span name - * but is required nevertheless.. + * @param messagingDestination The message destination name. This might be equal to the span name but is required nevertheless. */ @Override public FaasPubsubSemanticConvention setMessagingDestination(String messagingDestination) { @@ -218,7 +211,6 @@ public FaasPubsubSemanticConvention setMessagingDestination(String messagingDest /** * Sets messaging.destination_kind. - * * @param messagingDestinationKind The kind of message destination. */ @Override @@ -230,13 +222,10 @@ public FaasPubsubSemanticConvention setMessagingDestinationKind(String messaging /** * Sets messaging.temp_destination. - * - * @param messagingTempDestination A boolean that is true if the message destination is - * temporary.. + * @param messagingTempDestination A boolean that is true if the message destination is temporary. */ @Override - public FaasPubsubSemanticConvention setMessagingTempDestination( - boolean messagingTempDestination) { + public FaasPubsubSemanticConvention setMessagingTempDestination(boolean messagingTempDestination) { status.set(AttributeStatus.MESSAGING_TEMP_DESTINATION); delegate.setAttribute("messaging.temp_destination", messagingTempDestination); return this; @@ -244,8 +233,7 @@ public FaasPubsubSemanticConvention setMessagingTempDestination( /** * Sets messaging.protocol. - * - * @param messagingProtocol The name of the transport protocol.. + * @param messagingProtocol The name of the transport protocol. */ @Override public FaasPubsubSemanticConvention setMessagingProtocol(String messagingProtocol) { @@ -256,8 +244,7 @@ public FaasPubsubSemanticConvention setMessagingProtocol(String messagingProtoco /** * Sets messaging.protocol_version. - * - * @param messagingProtocolVersion The version of the transport protocol.. + * @param messagingProtocolVersion The version of the transport protocol. */ @Override public FaasPubsubSemanticConvention setMessagingProtocolVersion(String messagingProtocolVersion) { @@ -268,8 +255,7 @@ public FaasPubsubSemanticConvention setMessagingProtocolVersion(String messaging /** * Sets messaging.url. - * - * @param messagingUrl Connection string.. + * @param messagingUrl Connection string. */ @Override public FaasPubsubSemanticConvention setMessagingUrl(String messagingUrl) { @@ -280,9 +266,7 @@ public FaasPubsubSemanticConvention setMessagingUrl(String messagingUrl) { /** * Sets messaging.message_id. - * - * @param messagingMessageId A value used by the messaging system as an identifier for the - * message, represented as a string.. + * @param messagingMessageId A value used by the messaging system as an identifier for the message, represented as a string. */ @Override public FaasPubsubSemanticConvention setMessagingMessageId(String messagingMessageId) { @@ -293,9 +277,7 @@ public FaasPubsubSemanticConvention setMessagingMessageId(String messagingMessag /** * Sets messaging.conversation_id. - * - * @param messagingConversationId A value identifying the conversation to which the message - * belongs, represented as a string. Sometimes called "Correlation ID".. + * @param messagingConversationId A value identifying the conversation to which the message belongs, represented as a string. Sometimes called "Correlation ID". */ @Override public FaasPubsubSemanticConvention setMessagingConversationId(String messagingConversationId) { @@ -306,14 +288,10 @@ public FaasPubsubSemanticConvention setMessagingConversationId(String messagingC /** * Sets messaging.message_payload_size_bytes. - * - * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in - * bytes. Also use this attribute if it is unknown whether the compressed or uncompressed - * payload size is reported.. + * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in bytes. Also use this attribute if it is unknown whether the compressed or uncompressed payload size is reported. */ @Override - public FaasPubsubSemanticConvention setMessagingMessagePayloadSizeBytes( - long messagingMessagePayloadSizeBytes) { + public FaasPubsubSemanticConvention setMessagingMessagePayloadSizeBytes(long messagingMessagePayloadSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES); delegate.setAttribute("messaging.message_payload_size_bytes", messagingMessagePayloadSizeBytes); return this; @@ -321,24 +299,18 @@ public FaasPubsubSemanticConvention setMessagingMessagePayloadSizeBytes( /** * Sets messaging.message_payload_compressed_size_bytes. - * - * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in - * bytes.. + * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in bytes. */ @Override - public FaasPubsubSemanticConvention setMessagingMessagePayloadCompressedSizeBytes( - long messagingMessagePayloadCompressedSizeBytes) { + public FaasPubsubSemanticConvention setMessagingMessagePayloadCompressedSizeBytes(long messagingMessagePayloadCompressedSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_COMPRESSED_SIZE_BYTES); - delegate.setAttribute( - "messaging.message_payload_compressed_size_bytes", - messagingMessagePayloadCompressedSizeBytes); + delegate.setAttribute("messaging.message_payload_compressed_size_bytes", messagingMessagePayloadCompressedSizeBytes); return this; } /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ @Override public FaasPubsubSemanticConvention setNetPeerPort(long netPeerPort) { @@ -349,7 +321,6 @@ public FaasPubsubSemanticConvention setNetPeerPort(long netPeerPort) { /** * Sets net.transport. - * * @param netTransport Strongly recommended for in-process queueing systems. */ @Override @@ -361,9 +332,7 @@ public FaasPubsubSemanticConvention setNetTransport(String netTransport) { /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ @Override public FaasPubsubSemanticConvention setNetPeerIp(String netPeerIp) { @@ -374,8 +343,7 @@ public FaasPubsubSemanticConvention setNetPeerIp(String netPeerIp) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ @Override public FaasPubsubSemanticConvention setNetPeerName(String netPeerName) { @@ -386,8 +354,7 @@ public FaasPubsubSemanticConvention setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ @Override public FaasPubsubSemanticConvention setNetHostIp(String netHostIp) { @@ -398,8 +365,7 @@ public FaasPubsubSemanticConvention setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ @Override public FaasPubsubSemanticConvention setNetHostPort(long netHostPort) { @@ -410,8 +376,7 @@ public FaasPubsubSemanticConvention setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ @Override public FaasPubsubSemanticConvention setNetHostName(String netHostName) { @@ -420,39 +385,42 @@ public FaasPubsubSemanticConvention setNetHostName(String netHostName) { return this; } - /** Builder class for {@link FaasPubsubSpan}. */ - public static class FaasPubsubSpanBuilder { + + /** + * Builder class for {@link FaasPubsubSpan}. + */ + public static class FaasPubsubSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected FaasPubsubSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public FaasPubsubSpanBuilder(Builder spanBuilder, long attributes) { + public FaasPubsubSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public FaasPubsubSpanBuilder setParent(Span parent) { + public FaasPubsubSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public FaasPubsubSpanBuilder setParent(SpanContext remoteParent) { + public FaasPubsubSpanBuilder 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 FaasPubsubSpanBuilder setKind(Kind kind) { + public FaasPubsubSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -463,10 +431,10 @@ public FaasPubsubSpan start() { return new FaasPubsubSpan(this.internalBuilder.startSpan(), status); } + /** * Sets faas.trigger. - * - * @param faasTrigger Type of the trigger on which the function is executed.. + * @param faasTrigger Type of the trigger on which the function is executed. */ public FaasPubsubSpanBuilder setFaasTrigger(String faasTrigger) { status.set(AttributeStatus.FAAS_TRIGGER); @@ -476,8 +444,7 @@ public FaasPubsubSpanBuilder setFaasTrigger(String faasTrigger) { /** * Sets faas.execution. - * - * @param faasExecution The execution id of the current function execution.. + * @param faasExecution The execution id of the current function execution. */ public FaasPubsubSpanBuilder setFaasExecution(String faasExecution) { status.set(AttributeStatus.FAAS_EXECUTION); @@ -487,8 +454,7 @@ public FaasPubsubSpanBuilder setFaasExecution(String faasExecution) { /** * Sets messaging.system. - * - * @param messagingSystem A string identifying the messaging system.. + * @param messagingSystem A string identifying the messaging system. */ public FaasPubsubSpanBuilder setMessagingSystem(String messagingSystem) { status.set(AttributeStatus.MESSAGING_SYSTEM); @@ -498,9 +464,7 @@ public FaasPubsubSpanBuilder setMessagingSystem(String messagingSystem) { /** * Sets messaging.destination. - * - * @param messagingDestination The message destination name. This might be equal to the span - * name but is required nevertheless.. + * @param messagingDestination The message destination name. This might be equal to the span name but is required nevertheless. */ public FaasPubsubSpanBuilder setMessagingDestination(String messagingDestination) { status.set(AttributeStatus.MESSAGING_DESTINATION); @@ -510,7 +474,6 @@ public FaasPubsubSpanBuilder setMessagingDestination(String messagingDestination /** * Sets messaging.destination_kind. - * * @param messagingDestinationKind The kind of message destination. */ public FaasPubsubSpanBuilder setMessagingDestinationKind(String messagingDestinationKind) { @@ -521,9 +484,7 @@ public FaasPubsubSpanBuilder setMessagingDestinationKind(String messagingDestina /** * Sets messaging.temp_destination. - * - * @param messagingTempDestination A boolean that is true if the message destination is - * temporary.. + * @param messagingTempDestination A boolean that is true if the message destination is temporary. */ public FaasPubsubSpanBuilder setMessagingTempDestination(boolean messagingTempDestination) { status.set(AttributeStatus.MESSAGING_TEMP_DESTINATION); @@ -533,8 +494,7 @@ public FaasPubsubSpanBuilder setMessagingTempDestination(boolean messagingTempDe /** * Sets messaging.protocol. - * - * @param messagingProtocol The name of the transport protocol.. + * @param messagingProtocol The name of the transport protocol. */ public FaasPubsubSpanBuilder setMessagingProtocol(String messagingProtocol) { status.set(AttributeStatus.MESSAGING_PROTOCOL); @@ -544,8 +504,7 @@ public FaasPubsubSpanBuilder setMessagingProtocol(String messagingProtocol) { /** * Sets messaging.protocol_version. - * - * @param messagingProtocolVersion The version of the transport protocol.. + * @param messagingProtocolVersion The version of the transport protocol. */ public FaasPubsubSpanBuilder setMessagingProtocolVersion(String messagingProtocolVersion) { status.set(AttributeStatus.MESSAGING_PROTOCOL_VERSION); @@ -555,8 +514,7 @@ public FaasPubsubSpanBuilder setMessagingProtocolVersion(String messagingProtoco /** * Sets messaging.url. - * - * @param messagingUrl Connection string.. + * @param messagingUrl Connection string. */ public FaasPubsubSpanBuilder setMessagingUrl(String messagingUrl) { status.set(AttributeStatus.MESSAGING_URL); @@ -566,9 +524,7 @@ public FaasPubsubSpanBuilder setMessagingUrl(String messagingUrl) { /** * Sets messaging.message_id. - * - * @param messagingMessageId A value used by the messaging system as an identifier for the - * message, represented as a string.. + * @param messagingMessageId A value used by the messaging system as an identifier for the message, represented as a string. */ public FaasPubsubSpanBuilder setMessagingMessageId(String messagingMessageId) { status.set(AttributeStatus.MESSAGING_MESSAGE_ID); @@ -578,9 +534,7 @@ public FaasPubsubSpanBuilder setMessagingMessageId(String messagingMessageId) { /** * Sets messaging.conversation_id. - * - * @param messagingConversationId A value identifying the conversation to which the message - * belongs, represented as a string. Sometimes called "Correlation ID".. + * @param messagingConversationId A value identifying the conversation to which the message belongs, represented as a string. Sometimes called "Correlation ID". */ public FaasPubsubSpanBuilder setMessagingConversationId(String messagingConversationId) { status.set(AttributeStatus.MESSAGING_CONVERSATION_ID); @@ -590,38 +544,27 @@ public FaasPubsubSpanBuilder setMessagingConversationId(String messagingConversa /** * Sets messaging.message_payload_size_bytes. - * - * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in - * bytes. Also use this attribute if it is unknown whether the compressed or uncompressed - * payload size is reported.. + * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in bytes. Also use this attribute if it is unknown whether the compressed or uncompressed payload size is reported. */ - public FaasPubsubSpanBuilder setMessagingMessagePayloadSizeBytes( - long messagingMessagePayloadSizeBytes) { + public FaasPubsubSpanBuilder setMessagingMessagePayloadSizeBytes(long messagingMessagePayloadSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES); - internalBuilder.setAttribute( - "messaging.message_payload_size_bytes", messagingMessagePayloadSizeBytes); + internalBuilder.setAttribute("messaging.message_payload_size_bytes", messagingMessagePayloadSizeBytes); return this; } /** * Sets messaging.message_payload_compressed_size_bytes. - * - * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload - * in bytes.. + * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in bytes. */ - public FaasPubsubSpanBuilder setMessagingMessagePayloadCompressedSizeBytes( - long messagingMessagePayloadCompressedSizeBytes) { + public FaasPubsubSpanBuilder setMessagingMessagePayloadCompressedSizeBytes(long messagingMessagePayloadCompressedSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_COMPRESSED_SIZE_BYTES); - internalBuilder.setAttribute( - "messaging.message_payload_compressed_size_bytes", - messagingMessagePayloadCompressedSizeBytes); + internalBuilder.setAttribute("messaging.message_payload_compressed_size_bytes", messagingMessagePayloadCompressedSizeBytes); return this; } /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ public FaasPubsubSpanBuilder setNetPeerPort(long netPeerPort) { status.set(AttributeStatus.NET_PEER_PORT); @@ -631,7 +574,6 @@ public FaasPubsubSpanBuilder setNetPeerPort(long netPeerPort) { /** * Sets net.transport. - * * @param netTransport Strongly recommended for in-process queueing systems. */ public FaasPubsubSpanBuilder setNetTransport(String netTransport) { @@ -642,9 +584,7 @@ public FaasPubsubSpanBuilder setNetTransport(String netTransport) { /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public FaasPubsubSpanBuilder setNetPeerIp(String netPeerIp) { status.set(AttributeStatus.NET_PEER_IP); @@ -654,8 +594,7 @@ public FaasPubsubSpanBuilder setNetPeerIp(String netPeerIp) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ public FaasPubsubSpanBuilder setNetPeerName(String netPeerName) { status.set(AttributeStatus.NET_PEER_NAME); @@ -665,8 +604,7 @@ public FaasPubsubSpanBuilder setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ public FaasPubsubSpanBuilder setNetHostIp(String netHostIp) { status.set(AttributeStatus.NET_HOST_IP); @@ -676,8 +614,7 @@ public FaasPubsubSpanBuilder setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ public FaasPubsubSpanBuilder setNetHostPort(long netHostPort) { status.set(AttributeStatus.NET_HOST_PORT); @@ -687,13 +624,13 @@ public FaasPubsubSpanBuilder setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ public FaasPubsubSpanBuilder setNetHostName(String netHostName) { status.set(AttributeStatus.NET_HOST_NAME); internalBuilder.setAttribute("net.host.name", netHostName); return this; } + } -} +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasSemanticConvention.java index 655cc1133137..2e9021c7181d 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasSemanticConvention.java @@ -22,17 +22,17 @@ public interface FaasSemanticConvention { Span getSpan(); + /** * Sets a value for faas.trigger - * * @param faasTrigger Type of the trigger on which the function is executed.. */ public FaasSemanticConvention setFaasTrigger(String faasTrigger); /** * Sets a value for faas.execution - * * @param faasExecution The execution id of the current function execution.. */ public FaasSemanticConvention setFaasExecution(String faasExecution); -} + +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasSpan.java index 3f4a632690d9..37a170c44f4c 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasSpan.java @@ -31,6 +31,7 @@ * * + * */ public class FaasSpan extends DelegatingSpan implements FaasSemanticConvention { @@ -38,6 +39,7 @@ enum AttributeStatus { EMPTY, FAAS_TRIGGER, FAAS_EXECUTION; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -65,7 +67,6 @@ public long getValue() { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(FaasSpan.class.getName()); - public final AttributeStatus status; protected FaasSpan(Span span, AttributeStatus status) { @@ -73,17 +74,18 @@ protected FaasSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * Entry point to generate a {@link FaasSpan}. - * - * @param tracer Tracer to use - * @param spanName Name for the {@link Span} - * @return a {@link FaasSpan} object. - */ - public static FaasSpanBuilder createFaasSpan(Tracer tracer, String spanName) { + /** + * Entry point to generate a {@link FaasSpan}. + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link FaasSpan} object. + */ + public static FaasSpanBuilder createFaasSpanBuilder(Tracer tracer, String spanName) { return new FaasSpanBuilder(tracer, spanName); } + + /** @return the Span used internally */ @Override public Span getSpan() { @@ -104,10 +106,10 @@ public void end() { // conditional attributes } + /** * Sets faas.trigger. - * - * @param faasTrigger Type of the trigger on which the function is executed.. + * @param faasTrigger Type of the trigger on which the function is executed. */ @Override public FaasSemanticConvention setFaasTrigger(String faasTrigger) { @@ -118,8 +120,7 @@ public FaasSemanticConvention setFaasTrigger(String faasTrigger) { /** * Sets faas.execution. - * - * @param faasExecution The execution id of the current function execution.. + * @param faasExecution The execution id of the current function execution. */ @Override public FaasSemanticConvention setFaasExecution(String faasExecution) { @@ -128,39 +129,42 @@ public FaasSemanticConvention setFaasExecution(String faasExecution) { return this; } - /** Builder class for {@link FaasSpan}. */ - public static class FaasSpanBuilder { + + /** + * Builder class for {@link FaasSpan}. + */ + public static class FaasSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected FaasSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public FaasSpanBuilder(Builder spanBuilder, long attributes) { + public FaasSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public FaasSpanBuilder setParent(Span parent) { + public FaasSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public FaasSpanBuilder setParent(SpanContext remoteParent) { + public FaasSpanBuilder 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 FaasSpanBuilder setKind(Kind kind) { + public FaasSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -171,10 +175,10 @@ public FaasSpan start() { return new FaasSpan(this.internalBuilder.startSpan(), status); } + /** * Sets faas.trigger. - * - * @param faasTrigger Type of the trigger on which the function is executed.. + * @param faasTrigger Type of the trigger on which the function is executed. */ public FaasSpanBuilder setFaasTrigger(String faasTrigger) { status.set(AttributeStatus.FAAS_TRIGGER); @@ -184,13 +188,13 @@ public FaasSpanBuilder setFaasTrigger(String faasTrigger) { /** * Sets faas.execution. - * - * @param faasExecution The execution id of the current function execution.. + * @param faasExecution The execution id of the current function execution. */ public FaasSpanBuilder setFaasExecution(String faasExecution) { status.set(AttributeStatus.FAAS_EXECUTION); internalBuilder.setAttribute("faas.execution", faasExecution); return this; } + } -} +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasTimerSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasTimerSemanticConvention.java index c9fece60bfc3..de91accdd011 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasTimerSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasTimerSemanticConvention.java @@ -22,34 +22,29 @@ public interface FaasTimerSemanticConvention { Span getSpan(); + /** * Sets a value for faas.trigger - * * @param faasTrigger Type of the trigger on which the function is executed.. */ public FaasTimerSemanticConvention setFaasTrigger(String faasTrigger); /** * Sets a value for faas.execution - * * @param faasExecution The execution id of the current function execution.. */ public FaasTimerSemanticConvention setFaasExecution(String faasExecution); /** * Sets a value for faas.time - * - * @param faasTime A string containing the function invocation time in the [ISO - * 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format expressed in - * [UTC](https://www.w3.org/TR/NOTE-datetime).. + * @param faasTime A string containing the function invocation time in the [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format expressed in [UTC](https://www.w3.org/TR/NOTE-datetime).. */ public FaasTimerSemanticConvention setFaasTime(String faasTime); /** * Sets a value for faas.cron - * - * @param faasCron A string containing the schedule period as [Cron - * Expression](https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm).. + * @param faasCron A string containing the schedule period as [Cron Expression](https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm).. */ public FaasTimerSemanticConvention setFaasCron(String faasCron); -} + +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasTimerSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasTimerSpan.java index 22ece484edd9..1bff144307f5 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasTimerSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/FaasTimerSpan.java @@ -25,15 +25,14 @@ * * * * Conditional attributes: * * + * */ public class FaasTimerSpan extends DelegatingSpan implements FaasTimerSemanticConvention { @@ -43,6 +42,7 @@ enum AttributeStatus { FAAS_EXECUTION, FAAS_TIME, FAAS_CRON; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -70,7 +70,6 @@ public long getValue() { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(FaasTimerSpan.class.getName()); - public final AttributeStatus status; protected FaasTimerSpan(Span span, AttributeStatus status) { @@ -78,25 +77,23 @@ protected FaasTimerSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * Entry point to generate a {@link FaasTimerSpan}. - * - * @param tracer Tracer to use - * @param spanName Name for the {@link Span} - * @return a {@link FaasTimerSpan} object. - */ - public static FaasTimerSpanBuilder createFaasTimerSpan(Tracer tracer, String spanName) { + /** + * Entry point to generate a {@link FaasTimerSpan}. + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link FaasTimerSpan} object. + */ + public static FaasTimerSpanBuilder createFaasTimerSpanBuilder(Tracer tracer, String spanName) { return new FaasTimerSpanBuilder(tracer, spanName); } /** - * Creates a {@link FaasTimerSpan} from a {@link FaasSpan}. - * - * @param builder {@link FaasSpan.FaasSpanBuilder} to use. - * @return a {@link FaasTimerSpan} object built from a {@link FaasSpan}. - */ - public static FaasTimerSpanBuilder createFaasTimerSpan(FaasSpan.FaasSpanBuilder builder) { - // we accept a builder from Faas since FaasTimer "extends" Faas + * Creates a {@link FaasTimerSpan} from a {@link FaasSpan}. + * @param builder {@link FaasSpan.FaasSpanBuilder} to use. + * @return a {@link FaasTimerSpan} object built from a {@link FaasSpan}. + */ + public static FaasTimerSpanBuilder createFaasTimerSpanBuilder(FaasSpan.FaasSpanBuilder builder) { + // we accept a builder from Faas since FaasTimer "extends" Faas return new FaasTimerSpanBuilder(builder.getSpanBuilder(), builder.status.getValue()); } @@ -123,10 +120,10 @@ public void end() { // conditional attributes } + /** * Sets faas.trigger. - * - * @param faasTrigger Type of the trigger on which the function is executed.. + * @param faasTrigger Type of the trigger on which the function is executed. */ @Override public FaasTimerSemanticConvention setFaasTrigger(String faasTrigger) { @@ -137,8 +134,7 @@ public FaasTimerSemanticConvention setFaasTrigger(String faasTrigger) { /** * Sets faas.execution. - * - * @param faasExecution The execution id of the current function execution.. + * @param faasExecution The execution id of the current function execution. */ @Override public FaasTimerSemanticConvention setFaasExecution(String faasExecution) { @@ -149,10 +145,7 @@ public FaasTimerSemanticConvention setFaasExecution(String faasExecution) { /** * Sets faas.time. - * - * @param faasTime A string containing the function invocation time in the [ISO - * 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format expressed in - * [UTC](https://www.w3.org/TR/NOTE-datetime).. + * @param faasTime A string containing the function invocation time in the [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format expressed in [UTC](https://www.w3.org/TR/NOTE-datetime). */ @Override public FaasTimerSemanticConvention setFaasTime(String faasTime) { @@ -163,9 +156,7 @@ public FaasTimerSemanticConvention setFaasTime(String faasTime) { /** * Sets faas.cron. - * - * @param faasCron A string containing the schedule period as [Cron - * Expression](https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm).. + * @param faasCron A string containing the schedule period as [Cron Expression](https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm). */ @Override public FaasTimerSemanticConvention setFaasCron(String faasCron) { @@ -174,39 +165,42 @@ public FaasTimerSemanticConvention setFaasCron(String faasCron) { return this; } - /** Builder class for {@link FaasTimerSpan}. */ - public static class FaasTimerSpanBuilder { + + /** + * Builder class for {@link FaasTimerSpan}. + */ + public static class FaasTimerSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected FaasTimerSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public FaasTimerSpanBuilder(Builder spanBuilder, long attributes) { + public FaasTimerSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public FaasTimerSpanBuilder setParent(Span parent) { + public FaasTimerSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public FaasTimerSpanBuilder setParent(SpanContext remoteParent) { + public FaasTimerSpanBuilder 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 FaasTimerSpanBuilder setKind(Kind kind) { + public FaasTimerSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -217,10 +211,10 @@ public FaasTimerSpan start() { return new FaasTimerSpan(this.internalBuilder.startSpan(), status); } + /** * Sets faas.trigger. - * - * @param faasTrigger Type of the trigger on which the function is executed.. + * @param faasTrigger Type of the trigger on which the function is executed. */ public FaasTimerSpanBuilder setFaasTrigger(String faasTrigger) { status.set(AttributeStatus.FAAS_TRIGGER); @@ -230,8 +224,7 @@ public FaasTimerSpanBuilder setFaasTrigger(String faasTrigger) { /** * Sets faas.execution. - * - * @param faasExecution The execution id of the current function execution.. + * @param faasExecution The execution id of the current function execution. */ public FaasTimerSpanBuilder setFaasExecution(String faasExecution) { status.set(AttributeStatus.FAAS_EXECUTION); @@ -241,10 +234,7 @@ public FaasTimerSpanBuilder setFaasExecution(String faasExecution) { /** * Sets faas.time. - * - * @param faasTime A string containing the function invocation time in the [ISO - * 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format expressed in - * [UTC](https://www.w3.org/TR/NOTE-datetime).. + * @param faasTime A string containing the function invocation time in the [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format expressed in [UTC](https://www.w3.org/TR/NOTE-datetime). */ public FaasTimerSpanBuilder setFaasTime(String faasTime) { status.set(AttributeStatus.FAAS_TIME); @@ -254,14 +244,13 @@ public FaasTimerSpanBuilder setFaasTime(String faasTime) { /** * Sets faas.cron. - * - * @param faasCron A string containing the schedule period as [Cron - * Expression](https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm).. + * @param faasCron A string containing the schedule period as [Cron Expression](https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm). */ public FaasTimerSpanBuilder setFaasCron(String faasCron) { status.set(AttributeStatus.FAAS_CRON); internalBuilder.setAttribute("faas.cron", faasCron); return this; } + } -} +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/GrpcClientSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/GrpcClientSemanticConvention.java index e9f3fa2af65f..6ab0a425a3a0 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/GrpcClientSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/GrpcClientSemanticConvention.java @@ -22,60 +22,53 @@ public interface GrpcClientSemanticConvention { Span getSpan(); + /** * Sets a value for rpc.service - * * @param rpcService The service name, must be equal to the $service part in the span name.. */ public GrpcClientSemanticConvention setRpcService(String rpcService); /** * Sets a value for net.transport - * * @param netTransport Transport protocol used. See note below.. */ public GrpcClientSemanticConvention setNetTransport(String netTransport); /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public GrpcClientSemanticConvention setNetPeerIp(String netPeerIp); /** * Sets a value for net.peer.name - * * @param netPeerName Remote hostname or similar, see note below.. */ public GrpcClientSemanticConvention setNetPeerName(String netPeerName); /** * Sets a value for net.host.ip - * * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. */ public GrpcClientSemanticConvention setNetHostIp(String netHostIp); /** * Sets a value for net.host.port - * * @param netHostPort Like `net.peer.port` but for the host port.. */ public GrpcClientSemanticConvention setNetHostPort(long netHostPort); /** * Sets a value for net.host.name - * * @param netHostName Local hostname or similar, see note below.. */ public GrpcClientSemanticConvention setNetHostName(String netHostName); /** * Sets a value for net.peer.port - * * @param netPeerPort It describes the server port the client is connecting to. */ public GrpcClientSemanticConvention setNetPeerPort(long netPeerPort); -} + +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/GrpcClientSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/GrpcClientSpan.java index 46059c9b5479..b93b624c1f2a 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/GrpcClientSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/GrpcClientSpan.java @@ -54,6 +54,7 @@ enum AttributeStatus { NET_HOST_PORT, NET_HOST_NAME, NET_PEER_PORT; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -81,7 +82,6 @@ public long getValue() { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(GrpcClientSpan.class.getName()); - public final AttributeStatus status; protected GrpcClientSpan(Span span, AttributeStatus status) { @@ -89,25 +89,23 @@ protected GrpcClientSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * Entry point to generate a {@link GrpcClientSpan}. - * - * @param tracer Tracer to use - * @param spanName Name for the {@link Span} - * @return a {@link GrpcClientSpan} object. - */ - public static GrpcClientSpanBuilder createGrpcClientSpan(Tracer tracer, String spanName) { - return new GrpcClientSpanBuilder(tracer, spanName).setKind(Kind.CLIENT); + /** + * Entry point to generate a {@link GrpcClientSpan}. + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link GrpcClientSpan} object. + */ + public static GrpcClientSpanBuilder createGrpcClientSpanBuilder(Tracer tracer, String spanName) { + return new GrpcClientSpanBuilder(tracer, spanName).setKind(Span.Kind.CLIENT); } /** - * Creates a {@link GrpcClientSpan} from a {@link RpcSpan}. - * - * @param builder {@link RpcSpan.RpcSpanBuilder} to use. - * @return a {@link GrpcClientSpan} object built from a {@link RpcSpan}. - */ - public static GrpcClientSpanBuilder createGrpcClientSpan(RpcSpan.RpcSpanBuilder builder) { - // we accept a builder from Rpc since GrpcClient "extends" Rpc + * Creates a {@link GrpcClientSpan} from a {@link RpcSpan}. + * @param builder {@link RpcSpan.RpcSpanBuilder} to use. + * @return a {@link GrpcClientSpan} object built from a {@link RpcSpan}. + */ + public static GrpcClientSpanBuilder createGrpcClientSpanBuilder(RpcSpan.RpcSpanBuilder builder) { + // we accept a builder from Rpc since GrpcClient "extends" Rpc return new GrpcClientSpanBuilder(builder.getSpanBuilder(), builder.status.getValue()); } @@ -133,8 +131,8 @@ public void end() { // extra constraints. { boolean flag = - (!this.status.isSet(AttributeStatus.NET_PEER_IP)) - || (!this.status.isSet(AttributeStatus.NET_PEER_NAME)); + (!this.status.isSet(AttributeStatus.NET_PEER_IP) ) || + (!this.status.isSet(AttributeStatus.NET_PEER_NAME) ) ; if (flag) { logger.info("Constraint not respected!"); } @@ -142,10 +140,10 @@ public void end() { // conditional attributes } + /** * Sets rpc.service. - * - * @param rpcService The service name, must be equal to the $service part in the span name.. + * @param rpcService The service name, must be equal to the $service part in the span name. */ @Override public GrpcClientSemanticConvention setRpcService(String rpcService) { @@ -156,8 +154,7 @@ public GrpcClientSemanticConvention setRpcService(String rpcService) { /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ @Override public GrpcClientSemanticConvention setNetTransport(String netTransport) { @@ -168,9 +165,7 @@ public GrpcClientSemanticConvention setNetTransport(String netTransport) { /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ @Override public GrpcClientSemanticConvention setNetPeerIp(String netPeerIp) { @@ -181,8 +176,7 @@ public GrpcClientSemanticConvention setNetPeerIp(String netPeerIp) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ @Override public GrpcClientSemanticConvention setNetPeerName(String netPeerName) { @@ -193,8 +187,7 @@ public GrpcClientSemanticConvention setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ @Override public GrpcClientSemanticConvention setNetHostIp(String netHostIp) { @@ -205,8 +198,7 @@ public GrpcClientSemanticConvention setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ @Override public GrpcClientSemanticConvention setNetHostPort(long netHostPort) { @@ -217,8 +209,7 @@ public GrpcClientSemanticConvention setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ @Override public GrpcClientSemanticConvention setNetHostName(String netHostName) { @@ -229,7 +220,6 @@ public GrpcClientSemanticConvention setNetHostName(String netHostName) { /** * Sets net.peer.port. - * * @param netPeerPort It describes the server port the client is connecting to. */ @Override @@ -239,39 +229,42 @@ public GrpcClientSemanticConvention setNetPeerPort(long netPeerPort) { return this; } - /** Builder class for {@link GrpcClientSpan}. */ - public static class GrpcClientSpanBuilder { + + /** + * Builder class for {@link GrpcClientSpan}. + */ + public static class GrpcClientSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected GrpcClientSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public GrpcClientSpanBuilder(Builder spanBuilder, long attributes) { + public GrpcClientSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public GrpcClientSpanBuilder setParent(Span parent) { + public GrpcClientSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public GrpcClientSpanBuilder setParent(SpanContext remoteParent) { + public GrpcClientSpanBuilder 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 GrpcClientSpanBuilder setKind(Kind kind) { + public GrpcClientSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -282,10 +275,10 @@ public GrpcClientSpan start() { return new GrpcClientSpan(this.internalBuilder.startSpan(), status); } + /** * Sets rpc.service. - * - * @param rpcService The service name, must be equal to the $service part in the span name.. + * @param rpcService The service name, must be equal to the $service part in the span name. */ public GrpcClientSpanBuilder setRpcService(String rpcService) { status.set(AttributeStatus.RPC_SERVICE); @@ -295,8 +288,7 @@ public GrpcClientSpanBuilder setRpcService(String rpcService) { /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ public GrpcClientSpanBuilder setNetTransport(String netTransport) { status.set(AttributeStatus.NET_TRANSPORT); @@ -306,9 +298,7 @@ public GrpcClientSpanBuilder setNetTransport(String netTransport) { /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public GrpcClientSpanBuilder setNetPeerIp(String netPeerIp) { status.set(AttributeStatus.NET_PEER_IP); @@ -318,8 +308,7 @@ public GrpcClientSpanBuilder setNetPeerIp(String netPeerIp) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ public GrpcClientSpanBuilder setNetPeerName(String netPeerName) { status.set(AttributeStatus.NET_PEER_NAME); @@ -329,8 +318,7 @@ public GrpcClientSpanBuilder setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ public GrpcClientSpanBuilder setNetHostIp(String netHostIp) { status.set(AttributeStatus.NET_HOST_IP); @@ -340,8 +328,7 @@ public GrpcClientSpanBuilder setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ public GrpcClientSpanBuilder setNetHostPort(long netHostPort) { status.set(AttributeStatus.NET_HOST_PORT); @@ -351,8 +338,7 @@ public GrpcClientSpanBuilder setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ public GrpcClientSpanBuilder setNetHostName(String netHostName) { status.set(AttributeStatus.NET_HOST_NAME); @@ -362,7 +348,6 @@ public GrpcClientSpanBuilder setNetHostName(String netHostName) { /** * Sets net.peer.port. - * * @param netPeerPort It describes the server port the client is connecting to. */ public GrpcClientSpanBuilder setNetPeerPort(long netPeerPort) { @@ -370,5 +355,6 @@ public GrpcClientSpanBuilder setNetPeerPort(long netPeerPort) { internalBuilder.setAttribute("net.peer.port", netPeerPort); return this; } + } -} +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/GrpcServerSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/GrpcServerSemanticConvention.java index e05fe45b307e..8d991f04ca63 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/GrpcServerSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/GrpcServerSemanticConvention.java @@ -22,60 +22,53 @@ public interface GrpcServerSemanticConvention { Span getSpan(); + /** * Sets a value for rpc.service - * * @param rpcService The service name, must be equal to the $service part in the span name.. */ public GrpcServerSemanticConvention setRpcService(String rpcService); /** * Sets a value for net.transport - * * @param netTransport Transport protocol used. See note below.. */ public GrpcServerSemanticConvention setNetTransport(String netTransport); /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public GrpcServerSemanticConvention setNetPeerIp(String netPeerIp); /** * Sets a value for net.peer.name - * * @param netPeerName Remote hostname or similar, see note below.. */ public GrpcServerSemanticConvention setNetPeerName(String netPeerName); /** * Sets a value for net.host.ip - * * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. */ public GrpcServerSemanticConvention setNetHostIp(String netHostIp); /** * Sets a value for net.host.port - * * @param netHostPort Like `net.peer.port` but for the host port.. */ public GrpcServerSemanticConvention setNetHostPort(long netHostPort); /** * Sets a value for net.host.name - * * @param netHostName Local hostname or similar, see note below.. */ public GrpcServerSemanticConvention setNetHostName(String netHostName); /** * Sets a value for net.peer.port - * * @param netPeerPort It describes the port the client is connecting from. */ public GrpcServerSemanticConvention setNetPeerPort(long netPeerPort); -} + +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/GrpcServerSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/GrpcServerSpan.java index ec4899c95aad..1e7ad47debd6 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/GrpcServerSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/GrpcServerSpan.java @@ -53,6 +53,7 @@ enum AttributeStatus { NET_HOST_PORT, NET_HOST_NAME, NET_PEER_PORT; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -80,7 +81,6 @@ public long getValue() { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(GrpcServerSpan.class.getName()); - public final AttributeStatus status; protected GrpcServerSpan(Span span, AttributeStatus status) { @@ -88,25 +88,23 @@ protected GrpcServerSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * Entry point to generate a {@link GrpcServerSpan}. - * - * @param tracer Tracer to use - * @param spanName Name for the {@link Span} - * @return a {@link GrpcServerSpan} object. - */ - public static GrpcServerSpanBuilder createGrpcServerSpan(Tracer tracer, String spanName) { - return new GrpcServerSpanBuilder(tracer, spanName).setKind(Kind.SERVER); + /** + * Entry point to generate a {@link GrpcServerSpan}. + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link GrpcServerSpan} object. + */ + public static GrpcServerSpanBuilder createGrpcServerSpanBuilder(Tracer tracer, String spanName) { + return new GrpcServerSpanBuilder(tracer, spanName).setKind(Span.Kind.SERVER); } /** - * Creates a {@link GrpcServerSpan} from a {@link RpcSpan}. - * - * @param builder {@link RpcSpan.RpcSpanBuilder} to use. - * @return a {@link GrpcServerSpan} object built from a {@link RpcSpan}. - */ - public static GrpcServerSpanBuilder createGrpcServerSpan(RpcSpan.RpcSpanBuilder builder) { - // we accept a builder from Rpc since GrpcServer "extends" Rpc + * Creates a {@link GrpcServerSpan} from a {@link RpcSpan}. + * @param builder {@link RpcSpan.RpcSpanBuilder} to use. + * @return a {@link GrpcServerSpan} object built from a {@link RpcSpan}. + */ + public static GrpcServerSpanBuilder createGrpcServerSpanBuilder(RpcSpan.RpcSpanBuilder builder) { + // we accept a builder from Rpc since GrpcServer "extends" Rpc return new GrpcServerSpanBuilder(builder.getSpanBuilder(), builder.status.getValue()); } @@ -129,8 +127,8 @@ public void end() { // extra constraints. { boolean flag = - (!this.status.isSet(AttributeStatus.NET_PEER_IP)) - || (!this.status.isSet(AttributeStatus.NET_PEER_NAME)); + (!this.status.isSet(AttributeStatus.NET_PEER_IP) ) || + (!this.status.isSet(AttributeStatus.NET_PEER_NAME) ) ; if (flag) { logger.info("Constraint not respected!"); } @@ -138,10 +136,10 @@ public void end() { // conditional attributes } + /** * Sets rpc.service. - * - * @param rpcService The service name, must be equal to the $service part in the span name.. + * @param rpcService The service name, must be equal to the $service part in the span name. */ @Override public GrpcServerSemanticConvention setRpcService(String rpcService) { @@ -152,8 +150,7 @@ public GrpcServerSemanticConvention setRpcService(String rpcService) { /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ @Override public GrpcServerSemanticConvention setNetTransport(String netTransport) { @@ -164,9 +161,7 @@ public GrpcServerSemanticConvention setNetTransport(String netTransport) { /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ @Override public GrpcServerSemanticConvention setNetPeerIp(String netPeerIp) { @@ -177,8 +172,7 @@ public GrpcServerSemanticConvention setNetPeerIp(String netPeerIp) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ @Override public GrpcServerSemanticConvention setNetPeerName(String netPeerName) { @@ -189,8 +183,7 @@ public GrpcServerSemanticConvention setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ @Override public GrpcServerSemanticConvention setNetHostIp(String netHostIp) { @@ -201,8 +194,7 @@ public GrpcServerSemanticConvention setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ @Override public GrpcServerSemanticConvention setNetHostPort(long netHostPort) { @@ -213,8 +205,7 @@ public GrpcServerSemanticConvention setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ @Override public GrpcServerSemanticConvention setNetHostName(String netHostName) { @@ -225,7 +216,6 @@ public GrpcServerSemanticConvention setNetHostName(String netHostName) { /** * Sets net.peer.port. - * * @param netPeerPort It describes the port the client is connecting from. */ @Override @@ -235,39 +225,42 @@ public GrpcServerSemanticConvention setNetPeerPort(long netPeerPort) { return this; } - /** Builder class for {@link GrpcServerSpan}. */ - public static class GrpcServerSpanBuilder { + + /** + * Builder class for {@link GrpcServerSpan}. + */ + public static class GrpcServerSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected GrpcServerSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public GrpcServerSpanBuilder(Builder spanBuilder, long attributes) { + public GrpcServerSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public GrpcServerSpanBuilder setParent(Span parent) { + public GrpcServerSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public GrpcServerSpanBuilder setParent(SpanContext remoteParent) { + public GrpcServerSpanBuilder 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 GrpcServerSpanBuilder setKind(Kind kind) { + public GrpcServerSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -278,10 +271,10 @@ public GrpcServerSpan start() { return new GrpcServerSpan(this.internalBuilder.startSpan(), status); } + /** * Sets rpc.service. - * - * @param rpcService The service name, must be equal to the $service part in the span name.. + * @param rpcService The service name, must be equal to the $service part in the span name. */ public GrpcServerSpanBuilder setRpcService(String rpcService) { status.set(AttributeStatus.RPC_SERVICE); @@ -291,8 +284,7 @@ public GrpcServerSpanBuilder setRpcService(String rpcService) { /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ public GrpcServerSpanBuilder setNetTransport(String netTransport) { status.set(AttributeStatus.NET_TRANSPORT); @@ -302,9 +294,7 @@ public GrpcServerSpanBuilder setNetTransport(String netTransport) { /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public GrpcServerSpanBuilder setNetPeerIp(String netPeerIp) { status.set(AttributeStatus.NET_PEER_IP); @@ -314,8 +304,7 @@ public GrpcServerSpanBuilder setNetPeerIp(String netPeerIp) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ public GrpcServerSpanBuilder setNetPeerName(String netPeerName) { status.set(AttributeStatus.NET_PEER_NAME); @@ -325,8 +314,7 @@ public GrpcServerSpanBuilder setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ public GrpcServerSpanBuilder setNetHostIp(String netHostIp) { status.set(AttributeStatus.NET_HOST_IP); @@ -336,8 +324,7 @@ public GrpcServerSpanBuilder setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ public GrpcServerSpanBuilder setNetHostPort(long netHostPort) { status.set(AttributeStatus.NET_HOST_PORT); @@ -347,8 +334,7 @@ public GrpcServerSpanBuilder setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ public GrpcServerSpanBuilder setNetHostName(String netHostName) { status.set(AttributeStatus.NET_HOST_NAME); @@ -358,7 +344,6 @@ public GrpcServerSpanBuilder setNetHostName(String netHostName) { /** * Sets net.peer.port. - * * @param netPeerPort It describes the port the client is connecting from. */ public GrpcServerSpanBuilder setNetPeerPort(long netPeerPort) { @@ -366,5 +351,6 @@ public GrpcServerSpanBuilder setNetPeerPort(long netPeerPort) { internalBuilder.setAttribute("net.peer.port", netPeerPort); return this; } + } -} +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpClientSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpClientSemanticConvention.java index 6514ccc74e7a..4382d34a77a3 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpClientSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpClientSemanticConvention.java @@ -22,124 +22,102 @@ public interface HttpClientSemanticConvention { Span getSpan(); + /** * Sets a value for http.method - * * @param httpMethod HTTP request method.. */ public HttpClientSemanticConvention setHttpMethod(String httpMethod); /** * Sets a value for http.url - * - * @param httpUrl Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. - * Usually the fragment is not transmitted over HTTP, but if it is known, it should be - * included nevertheless.. + * @param httpUrl Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. Usually the fragment is not transmitted over HTTP, but if it is known, it should be included nevertheless.. */ public HttpClientSemanticConvention setHttpUrl(String httpUrl); /** * Sets a value for http.target - * * @param httpTarget The full request target as passed in a HTTP request line or equivalent.. */ public HttpClientSemanticConvention setHttpTarget(String httpTarget); /** * Sets a value for http.host - * - * @param httpHost The value of the [HTTP host - * header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not - * present, this attribute should be the same.. + * @param httpHost The value of the [HTTP host header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not present, this attribute should be the same.. */ public HttpClientSemanticConvention setHttpHost(String httpHost); /** * Sets a value for http.scheme - * * @param httpScheme The URI scheme identifying the used protocol.. */ public HttpClientSemanticConvention setHttpScheme(String httpScheme); /** * Sets a value for http.status_code - * - * @param httpStatusCode [HTTP response status - * code](https://tools.ietf.org/html/rfc7231#section-6).. + * @param httpStatusCode [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6).. */ public HttpClientSemanticConvention setHttpStatusCode(long httpStatusCode); /** * Sets a value for http.status_text - * * @param httpStatusText [HTTP reason phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2).. */ public HttpClientSemanticConvention setHttpStatusText(String httpStatusText); /** * Sets a value for http.flavor - * * @param httpFlavor Kind of HTTP protocol used. - *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if - * `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. + *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. */ public HttpClientSemanticConvention setHttpFlavor(String httpFlavor); /** * Sets a value for http.user_agent - * - * @param httpUserAgent Value of the [HTTP - * User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the client.. + * @param httpUserAgent Value of the [HTTP User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the client.. */ public HttpClientSemanticConvention setHttpUserAgent(String httpUserAgent); /** * Sets a value for net.transport - * * @param netTransport Transport protocol used. See note below.. */ public HttpClientSemanticConvention setNetTransport(String netTransport); /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public HttpClientSemanticConvention setNetPeerIp(String netPeerIp); /** * Sets a value for net.peer.port - * * @param netPeerPort Remote port number.. */ public HttpClientSemanticConvention setNetPeerPort(long netPeerPort); /** * Sets a value for net.peer.name - * * @param netPeerName Remote hostname or similar, see note below.. */ public HttpClientSemanticConvention setNetPeerName(String netPeerName); /** * Sets a value for net.host.ip - * * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. */ public HttpClientSemanticConvention setNetHostIp(String netHostIp); /** * Sets a value for net.host.port - * * @param netHostPort Like `net.peer.port` but for the host port.. */ public HttpClientSemanticConvention setNetHostPort(long netHostPort); /** * Sets a value for net.host.name - * * @param netHostName Local hostname or similar, see note below.. */ public HttpClientSemanticConvention setNetHostName(String netHostName); -} + +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpClientSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpClientSpan.java index cd6397038cf3..e4bea9bab3b4 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpClientSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpClientSpan.java @@ -30,8 +30,7 @@ * Conditional attributes: * *

* * Additional constraints @@ -65,6 +64,7 @@ enum AttributeStatus { NET_HOST_IP, NET_HOST_PORT, NET_HOST_NAME; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -92,7 +92,6 @@ public long getValue() { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(HttpClientSpan.class.getName()); - public final AttributeStatus status; protected HttpClientSpan(Span span, AttributeStatus status) { @@ -100,25 +99,23 @@ protected HttpClientSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * Entry point to generate a {@link HttpClientSpan}. - * - * @param tracer Tracer to use - * @param spanName Name for the {@link Span} - * @return a {@link HttpClientSpan} object. - */ - public static HttpClientSpanBuilder createHttpClientSpan(Tracer tracer, String spanName) { - return new HttpClientSpanBuilder(tracer, spanName).setKind(Kind.CLIENT); + /** + * Entry point to generate a {@link HttpClientSpan}. + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link HttpClientSpan} object. + */ + public static HttpClientSpanBuilder createHttpClientSpanBuilder(Tracer tracer, String spanName) { + return new HttpClientSpanBuilder(tracer, spanName).setKind(Span.Kind.CLIENT); } /** - * Creates a {@link HttpClientSpan} from a {@link HttpSpan}. - * - * @param builder {@link HttpSpan.HttpSpanBuilder} to use. - * @return a {@link HttpClientSpan} object built from a {@link HttpSpan}. - */ - public static HttpClientSpanBuilder createHttpClientSpan(HttpSpan.HttpSpanBuilder builder) { - // we accept a builder from Http since HttpClient "extends" Http + * Creates a {@link HttpClientSpan} from a {@link HttpSpan}. + * @param builder {@link HttpSpan.HttpSpanBuilder} to use. + * @return a {@link HttpClientSpan} object built from a {@link HttpSpan}. + */ + public static HttpClientSpanBuilder createHttpClientSpanBuilder(HttpSpan.HttpSpanBuilder builder) { + // we accept a builder from Http since HttpClient "extends" Http return new HttpClientSpanBuilder(builder.getSpanBuilder(), builder.status.getValue()); } @@ -141,18 +138,10 @@ public void end() { // extra constraints. { boolean flag = - (!this.status.isSet(AttributeStatus.HTTP_URL)) - || (!this.status.isSet(AttributeStatus.HTTP_SCHEME) - && !this.status.isSet(AttributeStatus.HTTP_HOST) - && !this.status.isSet(AttributeStatus.HTTP_TARGET)) - || (!this.status.isSet(AttributeStatus.HTTP_SCHEME) - && !this.status.isSet(AttributeStatus.NET_PEER_NAME) - && !this.status.isSet(AttributeStatus.NET_PEER_PORT) - && !this.status.isSet(AttributeStatus.HTTP_TARGET)) - || (!this.status.isSet(AttributeStatus.HTTP_SCHEME) - && !this.status.isSet(AttributeStatus.NET_PEER_IP) - && !this.status.isSet(AttributeStatus.NET_PEER_PORT) - && !this.status.isSet(AttributeStatus.HTTP_TARGET)); + (!this.status.isSet(AttributeStatus.HTTP_URL) ) || + (!this.status.isSet(AttributeStatus.HTTP_SCHEME) &&!this.status.isSet(AttributeStatus.HTTP_HOST) &&!this.status.isSet(AttributeStatus.HTTP_TARGET) ) || + (!this.status.isSet(AttributeStatus.HTTP_SCHEME) &&!this.status.isSet(AttributeStatus.NET_PEER_NAME) &&!this.status.isSet(AttributeStatus.NET_PEER_PORT) &&!this.status.isSet(AttributeStatus.HTTP_TARGET) ) || + (!this.status.isSet(AttributeStatus.HTTP_SCHEME) &&!this.status.isSet(AttributeStatus.NET_PEER_IP) &&!this.status.isSet(AttributeStatus.NET_PEER_PORT) &&!this.status.isSet(AttributeStatus.HTTP_TARGET) ) ; if (flag) { logger.info("Constraint not respected!"); } @@ -163,10 +152,10 @@ public void end() { } } + /** * Sets http.method. - * - * @param httpMethod HTTP request method.. + * @param httpMethod HTTP request method. */ @Override public HttpClientSemanticConvention setHttpMethod(String httpMethod) { @@ -177,10 +166,7 @@ public HttpClientSemanticConvention setHttpMethod(String httpMethod) { /** * Sets http.url. - * - * @param httpUrl Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. - * Usually the fragment is not transmitted over HTTP, but if it is known, it should be - * included nevertheless.. + * @param httpUrl Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. Usually the fragment is not transmitted over HTTP, but if it is known, it should be included nevertheless. */ @Override public HttpClientSemanticConvention setHttpUrl(String httpUrl) { @@ -191,8 +177,7 @@ public HttpClientSemanticConvention setHttpUrl(String httpUrl) { /** * Sets http.target. - * - * @param httpTarget The full request target as passed in a HTTP request line or equivalent.. + * @param httpTarget The full request target as passed in a HTTP request line or equivalent. */ @Override public HttpClientSemanticConvention setHttpTarget(String httpTarget) { @@ -203,10 +188,7 @@ public HttpClientSemanticConvention setHttpTarget(String httpTarget) { /** * Sets http.host. - * - * @param httpHost The value of the [HTTP host - * header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not - * present, this attribute should be the same.. + * @param httpHost The value of the [HTTP host header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not present, this attribute should be the same. */ @Override public HttpClientSemanticConvention setHttpHost(String httpHost) { @@ -217,8 +199,7 @@ public HttpClientSemanticConvention setHttpHost(String httpHost) { /** * Sets http.scheme. - * - * @param httpScheme The URI scheme identifying the used protocol.. + * @param httpScheme The URI scheme identifying the used protocol. */ @Override public HttpClientSemanticConvention setHttpScheme(String httpScheme) { @@ -229,9 +210,7 @@ public HttpClientSemanticConvention setHttpScheme(String httpScheme) { /** * Sets http.status_code. - * - * @param httpStatusCode [HTTP response status - * code](https://tools.ietf.org/html/rfc7231#section-6).. + * @param httpStatusCode [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). */ @Override public HttpClientSemanticConvention setHttpStatusCode(long httpStatusCode) { @@ -242,8 +221,7 @@ public HttpClientSemanticConvention setHttpStatusCode(long httpStatusCode) { /** * Sets http.status_text. - * - * @param httpStatusText [HTTP reason phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2).. + * @param httpStatusText [HTTP reason phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2). */ @Override public HttpClientSemanticConvention setHttpStatusText(String httpStatusText) { @@ -254,10 +232,8 @@ public HttpClientSemanticConvention setHttpStatusText(String httpStatusText) { /** * Sets http.flavor. - * * @param httpFlavor Kind of HTTP protocol used. - *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if - * `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. + *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. */ @Override public HttpClientSemanticConvention setHttpFlavor(String httpFlavor) { @@ -268,9 +244,7 @@ public HttpClientSemanticConvention setHttpFlavor(String httpFlavor) { /** * Sets http.user_agent. - * - * @param httpUserAgent Value of the [HTTP - * User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the client.. + * @param httpUserAgent Value of the [HTTP User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the client. */ @Override public HttpClientSemanticConvention setHttpUserAgent(String httpUserAgent) { @@ -281,8 +255,7 @@ public HttpClientSemanticConvention setHttpUserAgent(String httpUserAgent) { /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ @Override public HttpClientSemanticConvention setNetTransport(String netTransport) { @@ -293,9 +266,7 @@ public HttpClientSemanticConvention setNetTransport(String netTransport) { /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ @Override public HttpClientSemanticConvention setNetPeerIp(String netPeerIp) { @@ -306,8 +277,7 @@ public HttpClientSemanticConvention setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ @Override public HttpClientSemanticConvention setNetPeerPort(long netPeerPort) { @@ -318,8 +288,7 @@ public HttpClientSemanticConvention setNetPeerPort(long netPeerPort) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ @Override public HttpClientSemanticConvention setNetPeerName(String netPeerName) { @@ -330,8 +299,7 @@ public HttpClientSemanticConvention setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ @Override public HttpClientSemanticConvention setNetHostIp(String netHostIp) { @@ -342,8 +310,7 @@ public HttpClientSemanticConvention setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ @Override public HttpClientSemanticConvention setNetHostPort(long netHostPort) { @@ -354,8 +321,7 @@ public HttpClientSemanticConvention setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ @Override public HttpClientSemanticConvention setNetHostName(String netHostName) { @@ -364,39 +330,42 @@ public HttpClientSemanticConvention setNetHostName(String netHostName) { return this; } - /** Builder class for {@link HttpClientSpan}. */ - public static class HttpClientSpanBuilder { + + /** + * Builder class for {@link HttpClientSpan}. + */ + public static class HttpClientSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected HttpClientSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public HttpClientSpanBuilder(Builder spanBuilder, long attributes) { + public HttpClientSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public HttpClientSpanBuilder setParent(Span parent) { + public HttpClientSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public HttpClientSpanBuilder setParent(SpanContext remoteParent) { + public HttpClientSpanBuilder 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 HttpClientSpanBuilder setKind(Kind kind) { + public HttpClientSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -407,10 +376,10 @@ public HttpClientSpan start() { return new HttpClientSpan(this.internalBuilder.startSpan(), status); } + /** * Sets http.method. - * - * @param httpMethod HTTP request method.. + * @param httpMethod HTTP request method. */ public HttpClientSpanBuilder setHttpMethod(String httpMethod) { status.set(AttributeStatus.HTTP_METHOD); @@ -420,10 +389,7 @@ public HttpClientSpanBuilder setHttpMethod(String httpMethod) { /** * Sets http.url. - * - * @param httpUrl Full HTTP request URL in the form - * `scheme://host[:port]/path?query[#fragment]`. Usually the fragment is not transmitted - * over HTTP, but if it is known, it should be included nevertheless.. + * @param httpUrl Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. Usually the fragment is not transmitted over HTTP, but if it is known, it should be included nevertheless. */ public HttpClientSpanBuilder setHttpUrl(String httpUrl) { status.set(AttributeStatus.HTTP_URL); @@ -433,8 +399,7 @@ public HttpClientSpanBuilder setHttpUrl(String httpUrl) { /** * Sets http.target. - * - * @param httpTarget The full request target as passed in a HTTP request line or equivalent.. + * @param httpTarget The full request target as passed in a HTTP request line or equivalent. */ public HttpClientSpanBuilder setHttpTarget(String httpTarget) { status.set(AttributeStatus.HTTP_TARGET); @@ -444,10 +409,7 @@ public HttpClientSpanBuilder setHttpTarget(String httpTarget) { /** * Sets http.host. - * - * @param httpHost The value of the [HTTP host - * header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not - * present, this attribute should be the same.. + * @param httpHost The value of the [HTTP host header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not present, this attribute should be the same. */ public HttpClientSpanBuilder setHttpHost(String httpHost) { status.set(AttributeStatus.HTTP_HOST); @@ -457,8 +419,7 @@ public HttpClientSpanBuilder setHttpHost(String httpHost) { /** * Sets http.scheme. - * - * @param httpScheme The URI scheme identifying the used protocol.. + * @param httpScheme The URI scheme identifying the used protocol. */ public HttpClientSpanBuilder setHttpScheme(String httpScheme) { status.set(AttributeStatus.HTTP_SCHEME); @@ -468,9 +429,7 @@ public HttpClientSpanBuilder setHttpScheme(String httpScheme) { /** * Sets http.status_code. - * - * @param httpStatusCode [HTTP response status - * code](https://tools.ietf.org/html/rfc7231#section-6).. + * @param httpStatusCode [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). */ public HttpClientSpanBuilder setHttpStatusCode(long httpStatusCode) { status.set(AttributeStatus.HTTP_STATUS_CODE); @@ -480,9 +439,7 @@ public HttpClientSpanBuilder setHttpStatusCode(long httpStatusCode) { /** * Sets http.status_text. - * - * @param httpStatusText [HTTP reason - * phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2).. + * @param httpStatusText [HTTP reason phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2). */ public HttpClientSpanBuilder setHttpStatusText(String httpStatusText) { status.set(AttributeStatus.HTTP_STATUS_TEXT); @@ -492,10 +449,8 @@ public HttpClientSpanBuilder setHttpStatusText(String httpStatusText) { /** * Sets http.flavor. - * * @param httpFlavor Kind of HTTP protocol used. - *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if - * `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. + *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. */ public HttpClientSpanBuilder setHttpFlavor(String httpFlavor) { status.set(AttributeStatus.HTTP_FLAVOR); @@ -505,10 +460,7 @@ public HttpClientSpanBuilder setHttpFlavor(String httpFlavor) { /** * Sets http.user_agent. - * - * @param httpUserAgent Value of the [HTTP - * User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the - * client.. + * @param httpUserAgent Value of the [HTTP User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the client. */ public HttpClientSpanBuilder setHttpUserAgent(String httpUserAgent) { status.set(AttributeStatus.HTTP_USER_AGENT); @@ -518,8 +470,7 @@ public HttpClientSpanBuilder setHttpUserAgent(String httpUserAgent) { /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ public HttpClientSpanBuilder setNetTransport(String netTransport) { status.set(AttributeStatus.NET_TRANSPORT); @@ -529,9 +480,7 @@ public HttpClientSpanBuilder setNetTransport(String netTransport) { /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public HttpClientSpanBuilder setNetPeerIp(String netPeerIp) { status.set(AttributeStatus.NET_PEER_IP); @@ -541,8 +490,7 @@ public HttpClientSpanBuilder setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ public HttpClientSpanBuilder setNetPeerPort(long netPeerPort) { status.set(AttributeStatus.NET_PEER_PORT); @@ -552,8 +500,7 @@ public HttpClientSpanBuilder setNetPeerPort(long netPeerPort) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ public HttpClientSpanBuilder setNetPeerName(String netPeerName) { status.set(AttributeStatus.NET_PEER_NAME); @@ -563,8 +510,7 @@ public HttpClientSpanBuilder setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ public HttpClientSpanBuilder setNetHostIp(String netHostIp) { status.set(AttributeStatus.NET_HOST_IP); @@ -574,8 +520,7 @@ public HttpClientSpanBuilder setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ public HttpClientSpanBuilder setNetHostPort(long netHostPort) { status.set(AttributeStatus.NET_HOST_PORT); @@ -585,13 +530,13 @@ public HttpClientSpanBuilder setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ public HttpClientSpanBuilder setNetHostName(String netHostName) { status.set(AttributeStatus.NET_HOST_NAME); internalBuilder.setAttribute("net.host.name", netHostName); return this; } + } -} +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpSemanticConvention.java index 29b41006438e..c7aafae550b4 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpSemanticConvention.java @@ -22,124 +22,102 @@ public interface HttpSemanticConvention { Span getSpan(); + /** * Sets a value for net.transport - * * @param netTransport Transport protocol used. See note below.. */ public HttpSemanticConvention setNetTransport(String netTransport); /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public HttpSemanticConvention setNetPeerIp(String netPeerIp); /** * Sets a value for net.peer.port - * * @param netPeerPort Remote port number.. */ public HttpSemanticConvention setNetPeerPort(long netPeerPort); /** * Sets a value for net.peer.name - * * @param netPeerName Remote hostname or similar, see note below.. */ public HttpSemanticConvention setNetPeerName(String netPeerName); /** * Sets a value for net.host.ip - * * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. */ public HttpSemanticConvention setNetHostIp(String netHostIp); /** * Sets a value for net.host.port - * * @param netHostPort Like `net.peer.port` but for the host port.. */ public HttpSemanticConvention setNetHostPort(long netHostPort); /** * Sets a value for net.host.name - * * @param netHostName Local hostname or similar, see note below.. */ public HttpSemanticConvention setNetHostName(String netHostName); /** * Sets a value for http.method - * * @param httpMethod HTTP request method.. */ public HttpSemanticConvention setHttpMethod(String httpMethod); /** * Sets a value for http.url - * - * @param httpUrl Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. - * Usually the fragment is not transmitted over HTTP, but if it is known, it should be - * included nevertheless.. + * @param httpUrl Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. Usually the fragment is not transmitted over HTTP, but if it is known, it should be included nevertheless.. */ public HttpSemanticConvention setHttpUrl(String httpUrl); /** * Sets a value for http.target - * * @param httpTarget The full request target as passed in a HTTP request line or equivalent.. */ public HttpSemanticConvention setHttpTarget(String httpTarget); /** * Sets a value for http.host - * - * @param httpHost The value of the [HTTP host - * header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not - * present, this attribute should be the same.. + * @param httpHost The value of the [HTTP host header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not present, this attribute should be the same.. */ public HttpSemanticConvention setHttpHost(String httpHost); /** * Sets a value for http.scheme - * * @param httpScheme The URI scheme identifying the used protocol.. */ public HttpSemanticConvention setHttpScheme(String httpScheme); /** * Sets a value for http.status_code - * - * @param httpStatusCode [HTTP response status - * code](https://tools.ietf.org/html/rfc7231#section-6).. + * @param httpStatusCode [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6).. */ public HttpSemanticConvention setHttpStatusCode(long httpStatusCode); /** * Sets a value for http.status_text - * * @param httpStatusText [HTTP reason phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2).. */ public HttpSemanticConvention setHttpStatusText(String httpStatusText); /** * Sets a value for http.flavor - * * @param httpFlavor Kind of HTTP protocol used. - *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if - * `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. + *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. */ public HttpSemanticConvention setHttpFlavor(String httpFlavor); /** * Sets a value for http.user_agent - * - * @param httpUserAgent Value of the [HTTP - * User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the client.. + * @param httpUserAgent Value of the [HTTP User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the client.. */ public HttpSemanticConvention setHttpUserAgent(String httpUserAgent); -} + +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpServerSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpServerSemanticConvention.java index a87dbfb6116f..8871cd362003 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpServerSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpServerSemanticConvention.java @@ -22,155 +22,122 @@ public interface HttpServerSemanticConvention { Span getSpan(); + /** * Sets a value for http.method - * * @param httpMethod HTTP request method.. */ public HttpServerSemanticConvention setHttpMethod(String httpMethod); /** * Sets a value for http.url - * - * @param httpUrl Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. - * Usually the fragment is not transmitted over HTTP, but if it is known, it should be - * included nevertheless.. + * @param httpUrl Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. Usually the fragment is not transmitted over HTTP, but if it is known, it should be included nevertheless.. */ public HttpServerSemanticConvention setHttpUrl(String httpUrl); /** * Sets a value for http.target - * * @param httpTarget The full request target as passed in a HTTP request line or equivalent.. */ public HttpServerSemanticConvention setHttpTarget(String httpTarget); /** * Sets a value for http.host - * - * @param httpHost The value of the [HTTP host - * header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not - * present, this attribute should be the same.. + * @param httpHost The value of the [HTTP host header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not present, this attribute should be the same.. */ public HttpServerSemanticConvention setHttpHost(String httpHost); /** * Sets a value for http.scheme - * * @param httpScheme The URI scheme identifying the used protocol.. */ public HttpServerSemanticConvention setHttpScheme(String httpScheme); /** * Sets a value for http.status_code - * - * @param httpStatusCode [HTTP response status - * code](https://tools.ietf.org/html/rfc7231#section-6).. + * @param httpStatusCode [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6).. */ public HttpServerSemanticConvention setHttpStatusCode(long httpStatusCode); /** * Sets a value for http.status_text - * * @param httpStatusText [HTTP reason phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2).. */ public HttpServerSemanticConvention setHttpStatusText(String httpStatusText); /** * Sets a value for http.flavor - * * @param httpFlavor Kind of HTTP protocol used. - *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if - * `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. + *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. */ public HttpServerSemanticConvention setHttpFlavor(String httpFlavor); /** * Sets a value for http.user_agent - * - * @param httpUserAgent Value of the [HTTP - * User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the client.. + * @param httpUserAgent Value of the [HTTP User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the client.. */ public HttpServerSemanticConvention setHttpUserAgent(String httpUserAgent); /** * Sets a value for net.transport - * * @param netTransport Transport protocol used. See note below.. */ public HttpServerSemanticConvention setNetTransport(String netTransport); /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public HttpServerSemanticConvention setNetPeerIp(String netPeerIp); /** * Sets a value for net.peer.port - * * @param netPeerPort Remote port number.. */ public HttpServerSemanticConvention setNetPeerPort(long netPeerPort); /** * Sets a value for net.peer.name - * * @param netPeerName Remote hostname or similar, see note below.. */ public HttpServerSemanticConvention setNetPeerName(String netPeerName); /** * Sets a value for net.host.ip - * * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. */ public HttpServerSemanticConvention setNetHostIp(String netHostIp); /** * Sets a value for net.host.port - * * @param netHostPort Like `net.peer.port` but for the host port.. */ public HttpServerSemanticConvention setNetHostPort(long netHostPort); /** * Sets a value for net.host.name - * * @param netHostName Local hostname or similar, see note below.. */ public HttpServerSemanticConvention setNetHostName(String netHostName); /** * Sets a value for http.server_name - * - * @param httpServerName The primary server name of the matched virtual host. This should be - * obtained via configuration. If no such configuration can be obtained, this attribute MUST - * NOT be set ( `net.host.name` should be used instead).. - *

http.url is usually not readily available on the server side but would have to be - * assembled in a cumbersome and sometimes lossy process from other information (see e.g. - * open-telemetry/opentelemetry-python/pull/148). It is thus preferred to supply the raw data - * that is available. + * @param httpServerName The primary server name of the matched virtual host. This should be obtained via configuration. If no such configuration can be obtained, this attribute MUST NOT be set ( `net.host.name` should be used instead).. + *

http.url is usually not readily available on the server side but would have to be assembled in a cumbersome and sometimes lossy process from other information (see e.g. open-telemetry/opentelemetry-python/pull/148). It is thus preferred to supply the raw data that is available. */ public HttpServerSemanticConvention setHttpServerName(String httpServerName); /** * Sets a value for http.route - * * @param httpRoute The matched route (path template).. */ public HttpServerSemanticConvention setHttpRoute(String httpRoute); /** * Sets a value for http.client_ip - * - * @param httpClientIp The IP address of the original client behind all proxies, if known (e.g. - * from - * [X-Forwarded-For](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For)).. - *

This is not necessarily the same as `net.peer.ip`, which would identify the - * network-level peer, which may be a proxy. + * @param httpClientIp The IP address of the original client behind all proxies, if known (e.g. from [X-Forwarded-For](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For)).. + *

This is not necessarily the same as `net.peer.ip`, which would identify the network-level peer, which may be a proxy. */ public HttpServerSemanticConvention setHttpClientIp(String httpClientIp); -} + +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpServerSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpServerSpan.java index fc979a990660..7b989af208ca 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpServerSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpServerSpan.java @@ -30,8 +30,7 @@ * Conditional attributes: * *

* * Additional constraints @@ -68,6 +67,7 @@ enum AttributeStatus { HTTP_SERVER_NAME, HTTP_ROUTE, HTTP_CLIENT_IP; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -95,7 +95,6 @@ public long getValue() { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(HttpServerSpan.class.getName()); - public final AttributeStatus status; protected HttpServerSpan(Span span, AttributeStatus status) { @@ -103,25 +102,23 @@ protected HttpServerSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * Entry point to generate a {@link HttpServerSpan}. - * - * @param tracer Tracer to use - * @param spanName Name for the {@link Span} - * @return a {@link HttpServerSpan} object. - */ - public static HttpServerSpanBuilder createHttpServerSpan(Tracer tracer, String spanName) { - return new HttpServerSpanBuilder(tracer, spanName).setKind(Kind.SERVER); + /** + * Entry point to generate a {@link HttpServerSpan}. + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link HttpServerSpan} object. + */ + public static HttpServerSpanBuilder createHttpServerSpanBuilder(Tracer tracer, String spanName) { + return new HttpServerSpanBuilder(tracer, spanName).setKind(Span.Kind.SERVER); } /** - * Creates a {@link HttpServerSpan} from a {@link HttpSpan}. - * - * @param builder {@link HttpSpan.HttpSpanBuilder} to use. - * @return a {@link HttpServerSpan} object built from a {@link HttpSpan}. - */ - public static HttpServerSpanBuilder createHttpServerSpan(HttpSpan.HttpSpanBuilder builder) { - // we accept a builder from Http since HttpServer "extends" Http + * Creates a {@link HttpServerSpan} from a {@link HttpSpan}. + * @param builder {@link HttpSpan.HttpSpanBuilder} to use. + * @return a {@link HttpServerSpan} object built from a {@link HttpSpan}. + */ + public static HttpServerSpanBuilder createHttpServerSpanBuilder(HttpSpan.HttpSpanBuilder builder) { + // we accept a builder from Http since HttpServer "extends" Http return new HttpServerSpanBuilder(builder.getSpanBuilder(), builder.status.getValue()); } @@ -144,18 +141,10 @@ public void end() { // extra constraints. { boolean flag = - (!this.status.isSet(AttributeStatus.HTTP_URL)) - || (!this.status.isSet(AttributeStatus.HTTP_SCHEME) - && !this.status.isSet(AttributeStatus.HTTP_HOST) - && !this.status.isSet(AttributeStatus.HTTP_TARGET)) - || (!this.status.isSet(AttributeStatus.HTTP_SCHEME) - && !this.status.isSet(AttributeStatus.HTTP_SERVER_NAME) - && !this.status.isSet(AttributeStatus.NET_HOST_PORT) - && !this.status.isSet(AttributeStatus.HTTP_TARGET)) - || (!this.status.isSet(AttributeStatus.HTTP_SCHEME) - && !this.status.isSet(AttributeStatus.NET_HOST_NAME) - && !this.status.isSet(AttributeStatus.NET_HOST_PORT) - && !this.status.isSet(AttributeStatus.HTTP_TARGET)); + (!this.status.isSet(AttributeStatus.HTTP_URL) ) || + (!this.status.isSet(AttributeStatus.HTTP_SCHEME) &&!this.status.isSet(AttributeStatus.HTTP_HOST) &&!this.status.isSet(AttributeStatus.HTTP_TARGET) ) || + (!this.status.isSet(AttributeStatus.HTTP_SCHEME) &&!this.status.isSet(AttributeStatus.HTTP_SERVER_NAME) &&!this.status.isSet(AttributeStatus.NET_HOST_PORT) &&!this.status.isSet(AttributeStatus.HTTP_TARGET) ) || + (!this.status.isSet(AttributeStatus.HTTP_SCHEME) &&!this.status.isSet(AttributeStatus.NET_HOST_NAME) &&!this.status.isSet(AttributeStatus.NET_HOST_PORT) &&!this.status.isSet(AttributeStatus.HTTP_TARGET) ) ; if (flag) { logger.info("Constraint not respected!"); } @@ -166,10 +155,10 @@ public void end() { } } + /** * Sets http.method. - * - * @param httpMethod HTTP request method.. + * @param httpMethod HTTP request method. */ @Override public HttpServerSemanticConvention setHttpMethod(String httpMethod) { @@ -180,10 +169,7 @@ public HttpServerSemanticConvention setHttpMethod(String httpMethod) { /** * Sets http.url. - * - * @param httpUrl Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. - * Usually the fragment is not transmitted over HTTP, but if it is known, it should be - * included nevertheless.. + * @param httpUrl Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. Usually the fragment is not transmitted over HTTP, but if it is known, it should be included nevertheless. */ @Override public HttpServerSemanticConvention setHttpUrl(String httpUrl) { @@ -194,8 +180,7 @@ public HttpServerSemanticConvention setHttpUrl(String httpUrl) { /** * Sets http.target. - * - * @param httpTarget The full request target as passed in a HTTP request line or equivalent.. + * @param httpTarget The full request target as passed in a HTTP request line or equivalent. */ @Override public HttpServerSemanticConvention setHttpTarget(String httpTarget) { @@ -206,10 +191,7 @@ public HttpServerSemanticConvention setHttpTarget(String httpTarget) { /** * Sets http.host. - * - * @param httpHost The value of the [HTTP host - * header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not - * present, this attribute should be the same.. + * @param httpHost The value of the [HTTP host header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not present, this attribute should be the same. */ @Override public HttpServerSemanticConvention setHttpHost(String httpHost) { @@ -220,8 +202,7 @@ public HttpServerSemanticConvention setHttpHost(String httpHost) { /** * Sets http.scheme. - * - * @param httpScheme The URI scheme identifying the used protocol.. + * @param httpScheme The URI scheme identifying the used protocol. */ @Override public HttpServerSemanticConvention setHttpScheme(String httpScheme) { @@ -232,9 +213,7 @@ public HttpServerSemanticConvention setHttpScheme(String httpScheme) { /** * Sets http.status_code. - * - * @param httpStatusCode [HTTP response status - * code](https://tools.ietf.org/html/rfc7231#section-6).. + * @param httpStatusCode [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). */ @Override public HttpServerSemanticConvention setHttpStatusCode(long httpStatusCode) { @@ -245,8 +224,7 @@ public HttpServerSemanticConvention setHttpStatusCode(long httpStatusCode) { /** * Sets http.status_text. - * - * @param httpStatusText [HTTP reason phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2).. + * @param httpStatusText [HTTP reason phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2). */ @Override public HttpServerSemanticConvention setHttpStatusText(String httpStatusText) { @@ -257,10 +235,8 @@ public HttpServerSemanticConvention setHttpStatusText(String httpStatusText) { /** * Sets http.flavor. - * * @param httpFlavor Kind of HTTP protocol used. - *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if - * `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. + *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. */ @Override public HttpServerSemanticConvention setHttpFlavor(String httpFlavor) { @@ -271,9 +247,7 @@ public HttpServerSemanticConvention setHttpFlavor(String httpFlavor) { /** * Sets http.user_agent. - * - * @param httpUserAgent Value of the [HTTP - * User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the client.. + * @param httpUserAgent Value of the [HTTP User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the client. */ @Override public HttpServerSemanticConvention setHttpUserAgent(String httpUserAgent) { @@ -284,8 +258,7 @@ public HttpServerSemanticConvention setHttpUserAgent(String httpUserAgent) { /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ @Override public HttpServerSemanticConvention setNetTransport(String netTransport) { @@ -296,9 +269,7 @@ public HttpServerSemanticConvention setNetTransport(String netTransport) { /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ @Override public HttpServerSemanticConvention setNetPeerIp(String netPeerIp) { @@ -309,8 +280,7 @@ public HttpServerSemanticConvention setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ @Override public HttpServerSemanticConvention setNetPeerPort(long netPeerPort) { @@ -321,8 +291,7 @@ public HttpServerSemanticConvention setNetPeerPort(long netPeerPort) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ @Override public HttpServerSemanticConvention setNetPeerName(String netPeerName) { @@ -333,8 +302,7 @@ public HttpServerSemanticConvention setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ @Override public HttpServerSemanticConvention setNetHostIp(String netHostIp) { @@ -345,8 +313,7 @@ public HttpServerSemanticConvention setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ @Override public HttpServerSemanticConvention setNetHostPort(long netHostPort) { @@ -357,8 +324,7 @@ public HttpServerSemanticConvention setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ @Override public HttpServerSemanticConvention setNetHostName(String netHostName) { @@ -369,14 +335,8 @@ public HttpServerSemanticConvention setNetHostName(String netHostName) { /** * Sets http.server_name. - * - * @param httpServerName The primary server name of the matched virtual host. This should be - * obtained via configuration. If no such configuration can be obtained, this attribute MUST - * NOT be set ( `net.host.name` should be used instead).. - *

http.url is usually not readily available on the server side but would have to be - * assembled in a cumbersome and sometimes lossy process from other information (see e.g. - * open-telemetry/opentelemetry-python/pull/148). It is thus preferred to supply the raw data - * that is available. + * @param httpServerName The primary server name of the matched virtual host. This should be obtained via configuration. If no such configuration can be obtained, this attribute MUST NOT be set ( `net.host.name` should be used instead). + *

http.url is usually not readily available on the server side but would have to be assembled in a cumbersome and sometimes lossy process from other information (see e.g. open-telemetry/opentelemetry-python/pull/148). It is thus preferred to supply the raw data that is available. */ @Override public HttpServerSemanticConvention setHttpServerName(String httpServerName) { @@ -387,8 +347,7 @@ public HttpServerSemanticConvention setHttpServerName(String httpServerName) { /** * Sets http.route. - * - * @param httpRoute The matched route (path template).. + * @param httpRoute The matched route (path template). */ @Override public HttpServerSemanticConvention setHttpRoute(String httpRoute) { @@ -399,12 +358,8 @@ public HttpServerSemanticConvention setHttpRoute(String httpRoute) { /** * Sets http.client_ip. - * - * @param httpClientIp The IP address of the original client behind all proxies, if known (e.g. - * from - * [X-Forwarded-For](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For)).. - *

This is not necessarily the same as `net.peer.ip`, which would identify the - * network-level peer, which may be a proxy. + * @param httpClientIp The IP address of the original client behind all proxies, if known (e.g. from [X-Forwarded-For](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For)). + *

This is not necessarily the same as `net.peer.ip`, which would identify the network-level peer, which may be a proxy. */ @Override public HttpServerSemanticConvention setHttpClientIp(String httpClientIp) { @@ -413,39 +368,42 @@ public HttpServerSemanticConvention setHttpClientIp(String httpClientIp) { return this; } - /** Builder class for {@link HttpServerSpan}. */ - public static class HttpServerSpanBuilder { + + /** + * Builder class for {@link HttpServerSpan}. + */ + public static class HttpServerSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected HttpServerSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public HttpServerSpanBuilder(Builder spanBuilder, long attributes) { + public HttpServerSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public HttpServerSpanBuilder setParent(Span parent) { + public HttpServerSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public HttpServerSpanBuilder setParent(SpanContext remoteParent) { + public HttpServerSpanBuilder 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 HttpServerSpanBuilder setKind(Kind kind) { + public HttpServerSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -456,10 +414,10 @@ public HttpServerSpan start() { return new HttpServerSpan(this.internalBuilder.startSpan(), status); } + /** * Sets http.method. - * - * @param httpMethod HTTP request method.. + * @param httpMethod HTTP request method. */ public HttpServerSpanBuilder setHttpMethod(String httpMethod) { status.set(AttributeStatus.HTTP_METHOD); @@ -469,10 +427,7 @@ public HttpServerSpanBuilder setHttpMethod(String httpMethod) { /** * Sets http.url. - * - * @param httpUrl Full HTTP request URL in the form - * `scheme://host[:port]/path?query[#fragment]`. Usually the fragment is not transmitted - * over HTTP, but if it is known, it should be included nevertheless.. + * @param httpUrl Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. Usually the fragment is not transmitted over HTTP, but if it is known, it should be included nevertheless. */ public HttpServerSpanBuilder setHttpUrl(String httpUrl) { status.set(AttributeStatus.HTTP_URL); @@ -482,8 +437,7 @@ public HttpServerSpanBuilder setHttpUrl(String httpUrl) { /** * Sets http.target. - * - * @param httpTarget The full request target as passed in a HTTP request line or equivalent.. + * @param httpTarget The full request target as passed in a HTTP request line or equivalent. */ public HttpServerSpanBuilder setHttpTarget(String httpTarget) { status.set(AttributeStatus.HTTP_TARGET); @@ -493,10 +447,7 @@ public HttpServerSpanBuilder setHttpTarget(String httpTarget) { /** * Sets http.host. - * - * @param httpHost The value of the [HTTP host - * header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not - * present, this attribute should be the same.. + * @param httpHost The value of the [HTTP host header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not present, this attribute should be the same. */ public HttpServerSpanBuilder setHttpHost(String httpHost) { status.set(AttributeStatus.HTTP_HOST); @@ -506,8 +457,7 @@ public HttpServerSpanBuilder setHttpHost(String httpHost) { /** * Sets http.scheme. - * - * @param httpScheme The URI scheme identifying the used protocol.. + * @param httpScheme The URI scheme identifying the used protocol. */ public HttpServerSpanBuilder setHttpScheme(String httpScheme) { status.set(AttributeStatus.HTTP_SCHEME); @@ -517,9 +467,7 @@ public HttpServerSpanBuilder setHttpScheme(String httpScheme) { /** * Sets http.status_code. - * - * @param httpStatusCode [HTTP response status - * code](https://tools.ietf.org/html/rfc7231#section-6).. + * @param httpStatusCode [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). */ public HttpServerSpanBuilder setHttpStatusCode(long httpStatusCode) { status.set(AttributeStatus.HTTP_STATUS_CODE); @@ -529,9 +477,7 @@ public HttpServerSpanBuilder setHttpStatusCode(long httpStatusCode) { /** * Sets http.status_text. - * - * @param httpStatusText [HTTP reason - * phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2).. + * @param httpStatusText [HTTP reason phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2). */ public HttpServerSpanBuilder setHttpStatusText(String httpStatusText) { status.set(AttributeStatus.HTTP_STATUS_TEXT); @@ -541,10 +487,8 @@ public HttpServerSpanBuilder setHttpStatusText(String httpStatusText) { /** * Sets http.flavor. - * * @param httpFlavor Kind of HTTP protocol used. - *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if - * `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. + *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. */ public HttpServerSpanBuilder setHttpFlavor(String httpFlavor) { status.set(AttributeStatus.HTTP_FLAVOR); @@ -554,10 +498,7 @@ public HttpServerSpanBuilder setHttpFlavor(String httpFlavor) { /** * Sets http.user_agent. - * - * @param httpUserAgent Value of the [HTTP - * User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the - * client.. + * @param httpUserAgent Value of the [HTTP User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the client. */ public HttpServerSpanBuilder setHttpUserAgent(String httpUserAgent) { status.set(AttributeStatus.HTTP_USER_AGENT); @@ -567,8 +508,7 @@ public HttpServerSpanBuilder setHttpUserAgent(String httpUserAgent) { /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ public HttpServerSpanBuilder setNetTransport(String netTransport) { status.set(AttributeStatus.NET_TRANSPORT); @@ -578,9 +518,7 @@ public HttpServerSpanBuilder setNetTransport(String netTransport) { /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public HttpServerSpanBuilder setNetPeerIp(String netPeerIp) { status.set(AttributeStatus.NET_PEER_IP); @@ -590,8 +528,7 @@ public HttpServerSpanBuilder setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ public HttpServerSpanBuilder setNetPeerPort(long netPeerPort) { status.set(AttributeStatus.NET_PEER_PORT); @@ -601,8 +538,7 @@ public HttpServerSpanBuilder setNetPeerPort(long netPeerPort) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ public HttpServerSpanBuilder setNetPeerName(String netPeerName) { status.set(AttributeStatus.NET_PEER_NAME); @@ -612,8 +548,7 @@ public HttpServerSpanBuilder setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ public HttpServerSpanBuilder setNetHostIp(String netHostIp) { status.set(AttributeStatus.NET_HOST_IP); @@ -623,8 +558,7 @@ public HttpServerSpanBuilder setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ public HttpServerSpanBuilder setNetHostPort(long netHostPort) { status.set(AttributeStatus.NET_HOST_PORT); @@ -634,8 +568,7 @@ public HttpServerSpanBuilder setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ public HttpServerSpanBuilder setNetHostName(String netHostName) { status.set(AttributeStatus.NET_HOST_NAME); @@ -645,14 +578,8 @@ public HttpServerSpanBuilder setNetHostName(String netHostName) { /** * Sets http.server_name. - * - * @param httpServerName The primary server name of the matched virtual host. This should be - * obtained via configuration. If no such configuration can be obtained, this attribute MUST - * NOT be set ( `net.host.name` should be used instead).. - *

http.url is usually not readily available on the server side but would have to be - * assembled in a cumbersome and sometimes lossy process from other information (see e.g. - * open-telemetry/opentelemetry-python/pull/148). It is thus preferred to supply the raw - * data that is available. + * @param httpServerName The primary server name of the matched virtual host. This should be obtained via configuration. If no such configuration can be obtained, this attribute MUST NOT be set ( `net.host.name` should be used instead). + *

http.url is usually not readily available on the server side but would have to be assembled in a cumbersome and sometimes lossy process from other information (see e.g. open-telemetry/opentelemetry-python/pull/148). It is thus preferred to supply the raw data that is available. */ public HttpServerSpanBuilder setHttpServerName(String httpServerName) { status.set(AttributeStatus.HTTP_SERVER_NAME); @@ -662,8 +589,7 @@ public HttpServerSpanBuilder setHttpServerName(String httpServerName) { /** * Sets http.route. - * - * @param httpRoute The matched route (path template).. + * @param httpRoute The matched route (path template). */ public HttpServerSpanBuilder setHttpRoute(String httpRoute) { status.set(AttributeStatus.HTTP_ROUTE); @@ -673,17 +599,14 @@ public HttpServerSpanBuilder setHttpRoute(String httpRoute) { /** * Sets http.client_ip. - * - * @param httpClientIp The IP address of the original client behind all proxies, if known (e.g. - * from - * [X-Forwarded-For](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For)).. - *

This is not necessarily the same as `net.peer.ip`, which would identify the - * network-level peer, which may be a proxy. + * @param httpClientIp The IP address of the original client behind all proxies, if known (e.g. from [X-Forwarded-For](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For)). + *

This is not necessarily the same as `net.peer.ip`, which would identify the network-level peer, which may be a proxy. */ public HttpServerSpanBuilder setHttpClientIp(String httpClientIp) { status.set(AttributeStatus.HTTP_CLIENT_IP); internalBuilder.setAttribute("http.client_ip", httpClientIp); return this; } + } -} +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpSpan.java index da3814179a76..2768b82b7635 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/HttpSpan.java @@ -30,9 +30,9 @@ * Conditional attributes: * *

+ * */ public class HttpSpan extends DelegatingSpan implements HttpSemanticConvention { @@ -54,6 +54,7 @@ enum AttributeStatus { HTTP_STATUS_TEXT, HTTP_FLAVOR, HTTP_USER_AGENT; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -81,7 +82,6 @@ public long getValue() { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(HttpSpan.class.getName()); - public final AttributeStatus status; protected HttpSpan(Span span, AttributeStatus status) { @@ -89,17 +89,18 @@ protected HttpSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * Entry point to generate a {@link HttpSpan}. - * - * @param tracer Tracer to use - * @param spanName Name for the {@link Span} - * @return a {@link HttpSpan} object. - */ - public static HttpSpanBuilder createHttpSpan(Tracer tracer, String spanName) { + /** + * Entry point to generate a {@link HttpSpan}. + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link HttpSpan} object. + */ + public static HttpSpanBuilder createHttpSpanBuilder(Tracer tracer, String spanName) { return new HttpSpanBuilder(tracer, spanName); } + + /** @return the Span used internally */ @Override public Span getSpan() { @@ -123,10 +124,10 @@ public void end() { } } + /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ @Override public HttpSemanticConvention setNetTransport(String netTransport) { @@ -137,9 +138,7 @@ public HttpSemanticConvention setNetTransport(String netTransport) { /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ @Override public HttpSemanticConvention setNetPeerIp(String netPeerIp) { @@ -150,8 +149,7 @@ public HttpSemanticConvention setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ @Override public HttpSemanticConvention setNetPeerPort(long netPeerPort) { @@ -162,8 +160,7 @@ public HttpSemanticConvention setNetPeerPort(long netPeerPort) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ @Override public HttpSemanticConvention setNetPeerName(String netPeerName) { @@ -174,8 +171,7 @@ public HttpSemanticConvention setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ @Override public HttpSemanticConvention setNetHostIp(String netHostIp) { @@ -186,8 +182,7 @@ public HttpSemanticConvention setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ @Override public HttpSemanticConvention setNetHostPort(long netHostPort) { @@ -198,8 +193,7 @@ public HttpSemanticConvention setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ @Override public HttpSemanticConvention setNetHostName(String netHostName) { @@ -210,8 +204,7 @@ public HttpSemanticConvention setNetHostName(String netHostName) { /** * Sets http.method. - * - * @param httpMethod HTTP request method.. + * @param httpMethod HTTP request method. */ @Override public HttpSemanticConvention setHttpMethod(String httpMethod) { @@ -222,10 +215,7 @@ public HttpSemanticConvention setHttpMethod(String httpMethod) { /** * Sets http.url. - * - * @param httpUrl Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. - * Usually the fragment is not transmitted over HTTP, but if it is known, it should be - * included nevertheless.. + * @param httpUrl Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. Usually the fragment is not transmitted over HTTP, but if it is known, it should be included nevertheless. */ @Override public HttpSemanticConvention setHttpUrl(String httpUrl) { @@ -236,8 +226,7 @@ public HttpSemanticConvention setHttpUrl(String httpUrl) { /** * Sets http.target. - * - * @param httpTarget The full request target as passed in a HTTP request line or equivalent.. + * @param httpTarget The full request target as passed in a HTTP request line or equivalent. */ @Override public HttpSemanticConvention setHttpTarget(String httpTarget) { @@ -248,10 +237,7 @@ public HttpSemanticConvention setHttpTarget(String httpTarget) { /** * Sets http.host. - * - * @param httpHost The value of the [HTTP host - * header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not - * present, this attribute should be the same.. + * @param httpHost The value of the [HTTP host header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not present, this attribute should be the same. */ @Override public HttpSemanticConvention setHttpHost(String httpHost) { @@ -262,8 +248,7 @@ public HttpSemanticConvention setHttpHost(String httpHost) { /** * Sets http.scheme. - * - * @param httpScheme The URI scheme identifying the used protocol.. + * @param httpScheme The URI scheme identifying the used protocol. */ @Override public HttpSemanticConvention setHttpScheme(String httpScheme) { @@ -274,9 +259,7 @@ public HttpSemanticConvention setHttpScheme(String httpScheme) { /** * Sets http.status_code. - * - * @param httpStatusCode [HTTP response status - * code](https://tools.ietf.org/html/rfc7231#section-6).. + * @param httpStatusCode [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). */ @Override public HttpSemanticConvention setHttpStatusCode(long httpStatusCode) { @@ -287,8 +270,7 @@ public HttpSemanticConvention setHttpStatusCode(long httpStatusCode) { /** * Sets http.status_text. - * - * @param httpStatusText [HTTP reason phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2).. + * @param httpStatusText [HTTP reason phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2). */ @Override public HttpSemanticConvention setHttpStatusText(String httpStatusText) { @@ -299,10 +281,8 @@ public HttpSemanticConvention setHttpStatusText(String httpStatusText) { /** * Sets http.flavor. - * * @param httpFlavor Kind of HTTP protocol used. - *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if - * `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. + *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. */ @Override public HttpSemanticConvention setHttpFlavor(String httpFlavor) { @@ -313,9 +293,7 @@ public HttpSemanticConvention setHttpFlavor(String httpFlavor) { /** * Sets http.user_agent. - * - * @param httpUserAgent Value of the [HTTP - * User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the client.. + * @param httpUserAgent Value of the [HTTP User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the client. */ @Override public HttpSemanticConvention setHttpUserAgent(String httpUserAgent) { @@ -324,39 +302,42 @@ public HttpSemanticConvention setHttpUserAgent(String httpUserAgent) { return this; } - /** Builder class for {@link HttpSpan}. */ - public static class HttpSpanBuilder { + + /** + * Builder class for {@link HttpSpan}. + */ + public static class HttpSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected HttpSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public HttpSpanBuilder(Builder spanBuilder, long attributes) { + public HttpSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public HttpSpanBuilder setParent(Span parent) { + public HttpSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public HttpSpanBuilder setParent(SpanContext remoteParent) { + public HttpSpanBuilder 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 HttpSpanBuilder setKind(Kind kind) { + public HttpSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -367,10 +348,10 @@ public HttpSpan start() { return new HttpSpan(this.internalBuilder.startSpan(), status); } + /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ public HttpSpanBuilder setNetTransport(String netTransport) { status.set(AttributeStatus.NET_TRANSPORT); @@ -380,9 +361,7 @@ public HttpSpanBuilder setNetTransport(String netTransport) { /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public HttpSpanBuilder setNetPeerIp(String netPeerIp) { status.set(AttributeStatus.NET_PEER_IP); @@ -392,8 +371,7 @@ public HttpSpanBuilder setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ public HttpSpanBuilder setNetPeerPort(long netPeerPort) { status.set(AttributeStatus.NET_PEER_PORT); @@ -403,8 +381,7 @@ public HttpSpanBuilder setNetPeerPort(long netPeerPort) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ public HttpSpanBuilder setNetPeerName(String netPeerName) { status.set(AttributeStatus.NET_PEER_NAME); @@ -414,8 +391,7 @@ public HttpSpanBuilder setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ public HttpSpanBuilder setNetHostIp(String netHostIp) { status.set(AttributeStatus.NET_HOST_IP); @@ -425,8 +401,7 @@ public HttpSpanBuilder setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ public HttpSpanBuilder setNetHostPort(long netHostPort) { status.set(AttributeStatus.NET_HOST_PORT); @@ -436,8 +411,7 @@ public HttpSpanBuilder setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ public HttpSpanBuilder setNetHostName(String netHostName) { status.set(AttributeStatus.NET_HOST_NAME); @@ -447,8 +421,7 @@ public HttpSpanBuilder setNetHostName(String netHostName) { /** * Sets http.method. - * - * @param httpMethod HTTP request method.. + * @param httpMethod HTTP request method. */ public HttpSpanBuilder setHttpMethod(String httpMethod) { status.set(AttributeStatus.HTTP_METHOD); @@ -458,10 +431,7 @@ public HttpSpanBuilder setHttpMethod(String httpMethod) { /** * Sets http.url. - * - * @param httpUrl Full HTTP request URL in the form - * `scheme://host[:port]/path?query[#fragment]`. Usually the fragment is not transmitted - * over HTTP, but if it is known, it should be included nevertheless.. + * @param httpUrl Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. Usually the fragment is not transmitted over HTTP, but if it is known, it should be included nevertheless. */ public HttpSpanBuilder setHttpUrl(String httpUrl) { status.set(AttributeStatus.HTTP_URL); @@ -471,8 +441,7 @@ public HttpSpanBuilder setHttpUrl(String httpUrl) { /** * Sets http.target. - * - * @param httpTarget The full request target as passed in a HTTP request line or equivalent.. + * @param httpTarget The full request target as passed in a HTTP request line or equivalent. */ public HttpSpanBuilder setHttpTarget(String httpTarget) { status.set(AttributeStatus.HTTP_TARGET); @@ -482,10 +451,7 @@ public HttpSpanBuilder setHttpTarget(String httpTarget) { /** * Sets http.host. - * - * @param httpHost The value of the [HTTP host - * header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not - * present, this attribute should be the same.. + * @param httpHost The value of the [HTTP host header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not present, this attribute should be the same. */ public HttpSpanBuilder setHttpHost(String httpHost) { status.set(AttributeStatus.HTTP_HOST); @@ -495,8 +461,7 @@ public HttpSpanBuilder setHttpHost(String httpHost) { /** * Sets http.scheme. - * - * @param httpScheme The URI scheme identifying the used protocol.. + * @param httpScheme The URI scheme identifying the used protocol. */ public HttpSpanBuilder setHttpScheme(String httpScheme) { status.set(AttributeStatus.HTTP_SCHEME); @@ -506,9 +471,7 @@ public HttpSpanBuilder setHttpScheme(String httpScheme) { /** * Sets http.status_code. - * - * @param httpStatusCode [HTTP response status - * code](https://tools.ietf.org/html/rfc7231#section-6).. + * @param httpStatusCode [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). */ public HttpSpanBuilder setHttpStatusCode(long httpStatusCode) { status.set(AttributeStatus.HTTP_STATUS_CODE); @@ -518,9 +481,7 @@ public HttpSpanBuilder setHttpStatusCode(long httpStatusCode) { /** * Sets http.status_text. - * - * @param httpStatusText [HTTP reason - * phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2).. + * @param httpStatusText [HTTP reason phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2). */ public HttpSpanBuilder setHttpStatusText(String httpStatusText) { status.set(AttributeStatus.HTTP_STATUS_TEXT); @@ -530,10 +491,8 @@ public HttpSpanBuilder setHttpStatusText(String httpStatusText) { /** * Sets http.flavor. - * * @param httpFlavor Kind of HTTP protocol used. - *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if - * `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. + *

If `net.transport` is not specified, it can be assumed to be `IP.TCP` except if `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. */ public HttpSpanBuilder setHttpFlavor(String httpFlavor) { status.set(AttributeStatus.HTTP_FLAVOR); @@ -543,15 +502,13 @@ public HttpSpanBuilder setHttpFlavor(String httpFlavor) { /** * Sets http.user_agent. - * - * @param httpUserAgent Value of the [HTTP - * User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the - * client.. + * @param httpUserAgent Value of the [HTTP User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the client. */ public HttpSpanBuilder setHttpUserAgent(String httpUserAgent) { status.set(AttributeStatus.HTTP_USER_AGENT); internalBuilder.setAttribute("http.user_agent", httpUserAgent); return this; } + } -} +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/IdentitySemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/IdentitySemanticConvention.java index 37b4116bb5b3..3ac2ade4c2f3 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/IdentitySemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/IdentitySemanticConvention.java @@ -22,28 +22,23 @@ public interface IdentitySemanticConvention { Span getSpan(); + /** * Sets a value for enduser.id - * - * @param enduserId Username or client_id extracted from the access token or Authorization header - * in the inbound request from outside the system.. + * @param enduserId Username or client_id extracted from the access token or Authorization header in the inbound request from outside the system.. */ public IdentitySemanticConvention setEnduserId(String enduserId); /** * Sets a value for enduser.role - * - * @param enduserRole Actual/assumed role the client is making the request under extracted from - * token or application security context.. + * @param enduserRole Actual/assumed role the client is making the request under extracted from token or application security context.. */ public IdentitySemanticConvention setEnduserRole(String enduserRole); /** * Sets a value for enduser.scope - * - * @param enduserScope Scopes or granted authorities the client currently possesses extracted from - * token or application security context. The value would come from the scope associated with - * an OAuth 2.0 Access Token or an attribute value in a SAML 2.0 Assertion.. + * @param enduserScope Scopes or granted authorities the client currently possesses extracted from token or application security context. The value would come from the scope associated with an OAuth 2.0 Access Token or an attribute value in a SAML 2.0 Assertion.. */ public IdentitySemanticConvention setEnduserScope(String enduserScope); -} + +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/IdentitySpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/IdentitySpan.java index eee8b10592c6..6f15277fbdac 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/IdentitySpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/IdentitySpan.java @@ -30,6 +30,7 @@ * *

+ * */ public class IdentitySpan extends DelegatingSpan implements IdentitySemanticConvention { @@ -38,6 +39,7 @@ enum AttributeStatus { ENDUSER_ID, ENDUSER_ROLE, ENDUSER_SCOPE; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -65,7 +67,6 @@ public long getValue() { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(IdentitySpan.class.getName()); - public final AttributeStatus status; protected IdentitySpan(Span span, AttributeStatus status) { @@ -73,17 +74,18 @@ protected IdentitySpan(Span span, AttributeStatus status) { this.status = status; } - /** - * Entry point to generate a {@link IdentitySpan}. - * - * @param tracer Tracer to use - * @param spanName Name for the {@link Span} - * @return a {@link IdentitySpan} object. - */ - public static IdentitySpanBuilder createIdentitySpan(Tracer tracer, String spanName) { + /** + * Entry point to generate a {@link IdentitySpan}. + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link IdentitySpan} object. + */ + public static IdentitySpanBuilder createIdentitySpanBuilder(Tracer tracer, String spanName) { return new IdentitySpanBuilder(tracer, spanName); } + + /** @return the Span used internally */ @Override public Span getSpan() { @@ -101,11 +103,10 @@ public void end() { // conditional attributes } + /** * Sets enduser.id. - * - * @param enduserId Username or client_id extracted from the access token or Authorization header - * in the inbound request from outside the system.. + * @param enduserId Username or client_id extracted from the access token or Authorization header in the inbound request from outside the system. */ @Override public IdentitySemanticConvention setEnduserId(String enduserId) { @@ -116,9 +117,7 @@ public IdentitySemanticConvention setEnduserId(String enduserId) { /** * Sets enduser.role. - * - * @param enduserRole Actual/assumed role the client is making the request under extracted from - * token or application security context.. + * @param enduserRole Actual/assumed role the client is making the request under extracted from token or application security context. */ @Override public IdentitySemanticConvention setEnduserRole(String enduserRole) { @@ -129,10 +128,7 @@ public IdentitySemanticConvention setEnduserRole(String enduserRole) { /** * Sets enduser.scope. - * - * @param enduserScope Scopes or granted authorities the client currently possesses extracted from - * token or application security context. The value would come from the scope associated with - * an OAuth 2.0 Access Token or an attribute value in a SAML 2.0 Assertion.. + * @param enduserScope Scopes or granted authorities the client currently possesses extracted from token or application security context. The value would come from the scope associated with an OAuth 2.0 Access Token or an attribute value in a SAML 2.0 Assertion. */ @Override public IdentitySemanticConvention setEnduserScope(String enduserScope) { @@ -141,39 +137,42 @@ public IdentitySemanticConvention setEnduserScope(String enduserScope) { return this; } - /** Builder class for {@link IdentitySpan}. */ - public static class IdentitySpanBuilder { + + /** + * Builder class for {@link IdentitySpan}. + */ + public static class IdentitySpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected IdentitySpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public IdentitySpanBuilder(Builder spanBuilder, long attributes) { + public IdentitySpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public IdentitySpanBuilder setParent(Span parent) { + public IdentitySpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public IdentitySpanBuilder setParent(SpanContext remoteParent) { + public IdentitySpanBuilder 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 IdentitySpanBuilder setKind(Kind kind) { + public IdentitySpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -184,11 +183,10 @@ public IdentitySpan start() { return new IdentitySpan(this.internalBuilder.startSpan(), status); } + /** * Sets enduser.id. - * - * @param enduserId Username or client_id extracted from the access token or Authorization - * header in the inbound request from outside the system.. + * @param enduserId Username or client_id extracted from the access token or Authorization header in the inbound request from outside the system. */ public IdentitySpanBuilder setEnduserId(String enduserId) { status.set(AttributeStatus.ENDUSER_ID); @@ -198,9 +196,7 @@ public IdentitySpanBuilder setEnduserId(String enduserId) { /** * Sets enduser.role. - * - * @param enduserRole Actual/assumed role the client is making the request under extracted from - * token or application security context.. + * @param enduserRole Actual/assumed role the client is making the request under extracted from token or application security context. */ public IdentitySpanBuilder setEnduserRole(String enduserRole) { status.set(AttributeStatus.ENDUSER_ROLE); @@ -210,15 +206,13 @@ public IdentitySpanBuilder setEnduserRole(String enduserRole) { /** * Sets enduser.scope. - * - * @param enduserScope Scopes or granted authorities the client currently possesses extracted - * from token or application security context. The value would come from the scope - * associated with an OAuth 2.0 Access Token or an attribute value in a SAML 2.0 Assertion.. + * @param enduserScope Scopes or granted authorities the client currently possesses extracted from token or application security context. The value would come from the scope associated with an OAuth 2.0 Access Token or an attribute value in a SAML 2.0 Assertion. */ public IdentitySpanBuilder setEnduserScope(String enduserScope) { status.set(AttributeStatus.ENDUSER_SCOPE); internalBuilder.setAttribute("enduser.scope", enduserScope); return this; } + } -} +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingConsumerSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingConsumerSemanticConvention.java index 49ca15233df4..ba178b7c02b3 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingConsumerSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingConsumerSemanticConvention.java @@ -22,151 +22,119 @@ public interface MessagingConsumerSemanticConvention { Span getSpan(); + /** * Sets a value for messaging.system - * * @param messagingSystem A string identifying the messaging system.. */ public MessagingConsumerSemanticConvention setMessagingSystem(String messagingSystem); /** * Sets a value for messaging.destination - * - * @param messagingDestination The message destination name. This might be equal to the span name - * but is required nevertheless.. + * @param messagingDestination The message destination name. This might be equal to the span name but is required nevertheless.. */ public MessagingConsumerSemanticConvention setMessagingDestination(String messagingDestination); /** * Sets a value for messaging.destination_kind - * * @param messagingDestinationKind The kind of message destination. */ - public MessagingConsumerSemanticConvention setMessagingDestinationKind( - String messagingDestinationKind); + public MessagingConsumerSemanticConvention setMessagingDestinationKind(String messagingDestinationKind); /** * Sets a value for messaging.temp_destination - * - * @param messagingTempDestination A boolean that is true if the message destination is - * temporary.. + * @param messagingTempDestination A boolean that is true if the message destination is temporary.. */ - public MessagingConsumerSemanticConvention setMessagingTempDestination( - boolean messagingTempDestination); + public MessagingConsumerSemanticConvention setMessagingTempDestination(boolean messagingTempDestination); /** * Sets a value for messaging.protocol - * * @param messagingProtocol The name of the transport protocol.. */ public MessagingConsumerSemanticConvention setMessagingProtocol(String messagingProtocol); /** * Sets a value for messaging.protocol_version - * * @param messagingProtocolVersion The version of the transport protocol.. */ - public MessagingConsumerSemanticConvention setMessagingProtocolVersion( - String messagingProtocolVersion); + public MessagingConsumerSemanticConvention setMessagingProtocolVersion(String messagingProtocolVersion); /** * Sets a value for messaging.url - * * @param messagingUrl Connection string.. */ public MessagingConsumerSemanticConvention setMessagingUrl(String messagingUrl); /** * Sets a value for messaging.message_id - * - * @param messagingMessageId A value used by the messaging system as an identifier for the - * message, represented as a string.. + * @param messagingMessageId A value used by the messaging system as an identifier for the message, represented as a string.. */ public MessagingConsumerSemanticConvention setMessagingMessageId(String messagingMessageId); /** * Sets a value for messaging.conversation_id - * - * @param messagingConversationId A value identifying the conversation to which the message - * belongs, represented as a string. Sometimes called "Correlation ID".. + * @param messagingConversationId A value identifying the conversation to which the message belongs, represented as a string. Sometimes called "Correlation ID".. */ - public MessagingConsumerSemanticConvention setMessagingConversationId( - String messagingConversationId); + public MessagingConsumerSemanticConvention setMessagingConversationId(String messagingConversationId); /** * Sets a value for messaging.message_payload_size_bytes - * - * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in - * bytes. Also use this attribute if it is unknown whether the compressed or uncompressed - * payload size is reported.. + * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in bytes. Also use this attribute if it is unknown whether the compressed or uncompressed payload size is reported.. */ - public MessagingConsumerSemanticConvention setMessagingMessagePayloadSizeBytes( - long messagingMessagePayloadSizeBytes); + public MessagingConsumerSemanticConvention setMessagingMessagePayloadSizeBytes(long messagingMessagePayloadSizeBytes); /** * Sets a value for messaging.message_payload_compressed_size_bytes - * - * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in - * bytes.. + * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in bytes.. */ - public MessagingConsumerSemanticConvention setMessagingMessagePayloadCompressedSizeBytes( - long messagingMessagePayloadCompressedSizeBytes); + public MessagingConsumerSemanticConvention setMessagingMessagePayloadCompressedSizeBytes(long messagingMessagePayloadCompressedSizeBytes); /** * Sets a value for net.peer.port - * * @param netPeerPort Remote port number.. */ public MessagingConsumerSemanticConvention setNetPeerPort(long netPeerPort); /** * Sets a value for net.transport - * * @param netTransport Strongly recommended for in-process queueing systems. */ public MessagingConsumerSemanticConvention setNetTransport(String netTransport); /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public MessagingConsumerSemanticConvention setNetPeerIp(String netPeerIp); /** * Sets a value for net.peer.name - * * @param netPeerName Remote hostname or similar, see note below.. */ public MessagingConsumerSemanticConvention setNetPeerName(String netPeerName); /** * Sets a value for net.host.ip - * * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. */ public MessagingConsumerSemanticConvention setNetHostIp(String netHostIp); /** * Sets a value for net.host.port - * * @param netHostPort Like `net.peer.port` but for the host port.. */ public MessagingConsumerSemanticConvention setNetHostPort(long netHostPort); /** * Sets a value for net.host.name - * * @param netHostName Local hostname or similar, see note below.. */ public MessagingConsumerSemanticConvention setNetHostName(String netHostName); /** * Sets a value for messaging.operation - * - * @param messagingOperation A string identifying which part and kind of message consumption this - * span describes.. + * @param messagingOperation A string identifying which part and kind of message consumption this span describes.. */ public MessagingConsumerSemanticConvention setMessagingOperation(String messagingOperation); -} + +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingConsumerSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingConsumerSpan.java index f46ce2881ef8..c6c5b86a208a 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingConsumerSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingConsumerSpan.java @@ -25,8 +25,7 @@ * * * * Conditional attributes: @@ -45,8 +44,7 @@ *
  • net.peer.ip * */ -public class MessagingConsumerSpan extends DelegatingSpan - implements MessagingConsumerSemanticConvention { +public class MessagingConsumerSpan extends DelegatingSpan implements MessagingConsumerSemanticConvention { enum AttributeStatus { EMPTY, @@ -69,6 +67,7 @@ enum AttributeStatus { NET_HOST_PORT, NET_HOST_NAME, MESSAGING_OPERATION; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -96,7 +95,6 @@ public long getValue() { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(MessagingConsumerSpan.class.getName()); - public final AttributeStatus status; protected MessagingConsumerSpan(Span span, AttributeStatus status) { @@ -104,27 +102,23 @@ protected MessagingConsumerSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * Entry point to generate a {@link MessagingConsumerSpan}. - * - * @param tracer Tracer to use - * @param spanName Name for the {@link Span} - * @return a {@link MessagingConsumerSpan} object. - */ - public static MessagingConsumerSpanBuilder createMessagingConsumerSpan( - Tracer tracer, String spanName) { - return new MessagingConsumerSpanBuilder(tracer, spanName).setKind(Kind.CONSUMER); + /** + * Entry point to generate a {@link MessagingConsumerSpan}. + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link MessagingConsumerSpan} object. + */ + public static MessagingConsumerSpanBuilder createMessagingConsumerSpanBuilder(Tracer tracer, String spanName) { + return new MessagingConsumerSpanBuilder(tracer, spanName).setKind(Span.Kind.CONSUMER); } /** - * Creates a {@link MessagingConsumerSpan} from a {@link MessagingSpan}. - * - * @param builder {@link MessagingSpan.MessagingSpanBuilder} to use. - * @return a {@link MessagingConsumerSpan} object built from a {@link MessagingSpan}. - */ - public static MessagingConsumerSpanBuilder createMessagingConsumerSpan( - MessagingSpan.MessagingSpanBuilder builder) { - // we accept a builder from Messaging since MessagingConsumer "extends" Messaging + * Creates a {@link MessagingConsumerSpan} from a {@link MessagingSpan}. + * @param builder {@link MessagingSpan.MessagingSpanBuilder} to use. + * @return a {@link MessagingConsumerSpan} object built from a {@link MessagingSpan}. + */ + public static MessagingConsumerSpanBuilder createMessagingConsumerSpanBuilder(MessagingSpan.MessagingSpanBuilder builder) { + // we accept a builder from Messaging since MessagingConsumer "extends" Messaging return new MessagingConsumerSpanBuilder(builder.getSpanBuilder(), builder.status.getValue()); } @@ -150,8 +144,8 @@ public void end() { // extra constraints. { boolean flag = - (!this.status.isSet(AttributeStatus.NET_PEER_NAME)) - || (!this.status.isSet(AttributeStatus.NET_PEER_IP)); + (!this.status.isSet(AttributeStatus.NET_PEER_NAME) ) || + (!this.status.isSet(AttributeStatus.NET_PEER_IP) ) ; if (flag) { logger.info("Constraint not respected!"); } @@ -165,10 +159,10 @@ public void end() { } } + /** * Sets messaging.system. - * - * @param messagingSystem A string identifying the messaging system.. + * @param messagingSystem A string identifying the messaging system. */ @Override public MessagingConsumerSemanticConvention setMessagingSystem(String messagingSystem) { @@ -179,9 +173,7 @@ public MessagingConsumerSemanticConvention setMessagingSystem(String messagingSy /** * Sets messaging.destination. - * - * @param messagingDestination The message destination name. This might be equal to the span name - * but is required nevertheless.. + * @param messagingDestination The message destination name. This might be equal to the span name but is required nevertheless. */ @Override public MessagingConsumerSemanticConvention setMessagingDestination(String messagingDestination) { @@ -192,12 +184,10 @@ public MessagingConsumerSemanticConvention setMessagingDestination(String messag /** * Sets messaging.destination_kind. - * * @param messagingDestinationKind The kind of message destination. */ @Override - public MessagingConsumerSemanticConvention setMessagingDestinationKind( - String messagingDestinationKind) { + public MessagingConsumerSemanticConvention setMessagingDestinationKind(String messagingDestinationKind) { status.set(AttributeStatus.MESSAGING_DESTINATION_KIND); delegate.setAttribute("messaging.destination_kind", messagingDestinationKind); return this; @@ -205,13 +195,10 @@ public MessagingConsumerSemanticConvention setMessagingDestinationKind( /** * Sets messaging.temp_destination. - * - * @param messagingTempDestination A boolean that is true if the message destination is - * temporary.. + * @param messagingTempDestination A boolean that is true if the message destination is temporary. */ @Override - public MessagingConsumerSemanticConvention setMessagingTempDestination( - boolean messagingTempDestination) { + public MessagingConsumerSemanticConvention setMessagingTempDestination(boolean messagingTempDestination) { status.set(AttributeStatus.MESSAGING_TEMP_DESTINATION); delegate.setAttribute("messaging.temp_destination", messagingTempDestination); return this; @@ -219,8 +206,7 @@ public MessagingConsumerSemanticConvention setMessagingTempDestination( /** * Sets messaging.protocol. - * - * @param messagingProtocol The name of the transport protocol.. + * @param messagingProtocol The name of the transport protocol. */ @Override public MessagingConsumerSemanticConvention setMessagingProtocol(String messagingProtocol) { @@ -231,12 +217,10 @@ public MessagingConsumerSemanticConvention setMessagingProtocol(String messaging /** * Sets messaging.protocol_version. - * - * @param messagingProtocolVersion The version of the transport protocol.. + * @param messagingProtocolVersion The version of the transport protocol. */ @Override - public MessagingConsumerSemanticConvention setMessagingProtocolVersion( - String messagingProtocolVersion) { + public MessagingConsumerSemanticConvention setMessagingProtocolVersion(String messagingProtocolVersion) { status.set(AttributeStatus.MESSAGING_PROTOCOL_VERSION); delegate.setAttribute("messaging.protocol_version", messagingProtocolVersion); return this; @@ -244,8 +228,7 @@ public MessagingConsumerSemanticConvention setMessagingProtocolVersion( /** * Sets messaging.url. - * - * @param messagingUrl Connection string.. + * @param messagingUrl Connection string. */ @Override public MessagingConsumerSemanticConvention setMessagingUrl(String messagingUrl) { @@ -256,9 +239,7 @@ public MessagingConsumerSemanticConvention setMessagingUrl(String messagingUrl) /** * Sets messaging.message_id. - * - * @param messagingMessageId A value used by the messaging system as an identifier for the - * message, represented as a string.. + * @param messagingMessageId A value used by the messaging system as an identifier for the message, represented as a string. */ @Override public MessagingConsumerSemanticConvention setMessagingMessageId(String messagingMessageId) { @@ -269,13 +250,10 @@ public MessagingConsumerSemanticConvention setMessagingMessageId(String messagin /** * Sets messaging.conversation_id. - * - * @param messagingConversationId A value identifying the conversation to which the message - * belongs, represented as a string. Sometimes called "Correlation ID".. + * @param messagingConversationId A value identifying the conversation to which the message belongs, represented as a string. Sometimes called "Correlation ID". */ @Override - public MessagingConsumerSemanticConvention setMessagingConversationId( - String messagingConversationId) { + public MessagingConsumerSemanticConvention setMessagingConversationId(String messagingConversationId) { status.set(AttributeStatus.MESSAGING_CONVERSATION_ID); delegate.setAttribute("messaging.conversation_id", messagingConversationId); return this; @@ -283,14 +261,10 @@ public MessagingConsumerSemanticConvention setMessagingConversationId( /** * Sets messaging.message_payload_size_bytes. - * - * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in - * bytes. Also use this attribute if it is unknown whether the compressed or uncompressed - * payload size is reported.. + * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in bytes. Also use this attribute if it is unknown whether the compressed or uncompressed payload size is reported. */ @Override - public MessagingConsumerSemanticConvention setMessagingMessagePayloadSizeBytes( - long messagingMessagePayloadSizeBytes) { + public MessagingConsumerSemanticConvention setMessagingMessagePayloadSizeBytes(long messagingMessagePayloadSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES); delegate.setAttribute("messaging.message_payload_size_bytes", messagingMessagePayloadSizeBytes); return this; @@ -298,24 +272,18 @@ public MessagingConsumerSemanticConvention setMessagingMessagePayloadSizeBytes( /** * Sets messaging.message_payload_compressed_size_bytes. - * - * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in - * bytes.. + * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in bytes. */ @Override - public MessagingConsumerSemanticConvention setMessagingMessagePayloadCompressedSizeBytes( - long messagingMessagePayloadCompressedSizeBytes) { + public MessagingConsumerSemanticConvention setMessagingMessagePayloadCompressedSizeBytes(long messagingMessagePayloadCompressedSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_COMPRESSED_SIZE_BYTES); - delegate.setAttribute( - "messaging.message_payload_compressed_size_bytes", - messagingMessagePayloadCompressedSizeBytes); + delegate.setAttribute("messaging.message_payload_compressed_size_bytes", messagingMessagePayloadCompressedSizeBytes); return this; } /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ @Override public MessagingConsumerSemanticConvention setNetPeerPort(long netPeerPort) { @@ -326,7 +294,6 @@ public MessagingConsumerSemanticConvention setNetPeerPort(long netPeerPort) { /** * Sets net.transport. - * * @param netTransport Strongly recommended for in-process queueing systems. */ @Override @@ -338,9 +305,7 @@ public MessagingConsumerSemanticConvention setNetTransport(String netTransport) /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ @Override public MessagingConsumerSemanticConvention setNetPeerIp(String netPeerIp) { @@ -351,8 +316,7 @@ public MessagingConsumerSemanticConvention setNetPeerIp(String netPeerIp) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ @Override public MessagingConsumerSemanticConvention setNetPeerName(String netPeerName) { @@ -363,8 +327,7 @@ public MessagingConsumerSemanticConvention setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ @Override public MessagingConsumerSemanticConvention setNetHostIp(String netHostIp) { @@ -375,8 +338,7 @@ public MessagingConsumerSemanticConvention setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ @Override public MessagingConsumerSemanticConvention setNetHostPort(long netHostPort) { @@ -387,8 +349,7 @@ public MessagingConsumerSemanticConvention setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ @Override public MessagingConsumerSemanticConvention setNetHostName(String netHostName) { @@ -399,9 +360,7 @@ public MessagingConsumerSemanticConvention setNetHostName(String netHostName) { /** * Sets messaging.operation. - * - * @param messagingOperation A string identifying which part and kind of message consumption this - * span describes.. + * @param messagingOperation A string identifying which part and kind of message consumption this span describes. */ @Override public MessagingConsumerSemanticConvention setMessagingOperation(String messagingOperation) { @@ -410,39 +369,42 @@ public MessagingConsumerSemanticConvention setMessagingOperation(String messagin return this; } - /** Builder class for {@link MessagingConsumerSpan}. */ - public static class MessagingConsumerSpanBuilder { + + /** + * Builder class for {@link MessagingConsumerSpan}. + */ + public static class MessagingConsumerSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected MessagingConsumerSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public MessagingConsumerSpanBuilder(Builder spanBuilder, long attributes) { + public MessagingConsumerSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public MessagingConsumerSpanBuilder setParent(Span parent) { + public MessagingConsumerSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public MessagingConsumerSpanBuilder setParent(SpanContext remoteParent) { + public MessagingConsumerSpanBuilder 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 MessagingConsumerSpanBuilder setKind(Kind kind) { + public MessagingConsumerSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -453,10 +415,10 @@ public MessagingConsumerSpan start() { return new MessagingConsumerSpan(this.internalBuilder.startSpan(), status); } + /** * Sets messaging.system. - * - * @param messagingSystem A string identifying the messaging system.. + * @param messagingSystem A string identifying the messaging system. */ public MessagingConsumerSpanBuilder setMessagingSystem(String messagingSystem) { status.set(AttributeStatus.MESSAGING_SYSTEM); @@ -466,9 +428,7 @@ public MessagingConsumerSpanBuilder setMessagingSystem(String messagingSystem) { /** * Sets messaging.destination. - * - * @param messagingDestination The message destination name. This might be equal to the span - * name but is required nevertheless.. + * @param messagingDestination The message destination name. This might be equal to the span name but is required nevertheless. */ public MessagingConsumerSpanBuilder setMessagingDestination(String messagingDestination) { status.set(AttributeStatus.MESSAGING_DESTINATION); @@ -478,11 +438,9 @@ public MessagingConsumerSpanBuilder setMessagingDestination(String messagingDest /** * Sets messaging.destination_kind. - * * @param messagingDestinationKind The kind of message destination. */ - public MessagingConsumerSpanBuilder setMessagingDestinationKind( - String messagingDestinationKind) { + public MessagingConsumerSpanBuilder setMessagingDestinationKind(String messagingDestinationKind) { status.set(AttributeStatus.MESSAGING_DESTINATION_KIND); internalBuilder.setAttribute("messaging.destination_kind", messagingDestinationKind); return this; @@ -490,12 +448,9 @@ public MessagingConsumerSpanBuilder setMessagingDestinationKind( /** * Sets messaging.temp_destination. - * - * @param messagingTempDestination A boolean that is true if the message destination is - * temporary.. + * @param messagingTempDestination A boolean that is true if the message destination is temporary. */ - public MessagingConsumerSpanBuilder setMessagingTempDestination( - boolean messagingTempDestination) { + public MessagingConsumerSpanBuilder setMessagingTempDestination(boolean messagingTempDestination) { status.set(AttributeStatus.MESSAGING_TEMP_DESTINATION); internalBuilder.setAttribute("messaging.temp_destination", messagingTempDestination); return this; @@ -503,8 +458,7 @@ public MessagingConsumerSpanBuilder setMessagingTempDestination( /** * Sets messaging.protocol. - * - * @param messagingProtocol The name of the transport protocol.. + * @param messagingProtocol The name of the transport protocol. */ public MessagingConsumerSpanBuilder setMessagingProtocol(String messagingProtocol) { status.set(AttributeStatus.MESSAGING_PROTOCOL); @@ -514,11 +468,9 @@ public MessagingConsumerSpanBuilder setMessagingProtocol(String messagingProtoco /** * Sets messaging.protocol_version. - * - * @param messagingProtocolVersion The version of the transport protocol.. + * @param messagingProtocolVersion The version of the transport protocol. */ - public MessagingConsumerSpanBuilder setMessagingProtocolVersion( - String messagingProtocolVersion) { + public MessagingConsumerSpanBuilder setMessagingProtocolVersion(String messagingProtocolVersion) { status.set(AttributeStatus.MESSAGING_PROTOCOL_VERSION); internalBuilder.setAttribute("messaging.protocol_version", messagingProtocolVersion); return this; @@ -526,8 +478,7 @@ public MessagingConsumerSpanBuilder setMessagingProtocolVersion( /** * Sets messaging.url. - * - * @param messagingUrl Connection string.. + * @param messagingUrl Connection string. */ public MessagingConsumerSpanBuilder setMessagingUrl(String messagingUrl) { status.set(AttributeStatus.MESSAGING_URL); @@ -537,9 +488,7 @@ public MessagingConsumerSpanBuilder setMessagingUrl(String messagingUrl) { /** * Sets messaging.message_id. - * - * @param messagingMessageId A value used by the messaging system as an identifier for the - * message, represented as a string.. + * @param messagingMessageId A value used by the messaging system as an identifier for the message, represented as a string. */ public MessagingConsumerSpanBuilder setMessagingMessageId(String messagingMessageId) { status.set(AttributeStatus.MESSAGING_MESSAGE_ID); @@ -549,9 +498,7 @@ public MessagingConsumerSpanBuilder setMessagingMessageId(String messagingMessag /** * Sets messaging.conversation_id. - * - * @param messagingConversationId A value identifying the conversation to which the message - * belongs, represented as a string. Sometimes called "Correlation ID".. + * @param messagingConversationId A value identifying the conversation to which the message belongs, represented as a string. Sometimes called "Correlation ID". */ public MessagingConsumerSpanBuilder setMessagingConversationId(String messagingConversationId) { status.set(AttributeStatus.MESSAGING_CONVERSATION_ID); @@ -561,38 +508,27 @@ public MessagingConsumerSpanBuilder setMessagingConversationId(String messagingC /** * Sets messaging.message_payload_size_bytes. - * - * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in - * bytes. Also use this attribute if it is unknown whether the compressed or uncompressed - * payload size is reported.. + * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in bytes. Also use this attribute if it is unknown whether the compressed or uncompressed payload size is reported. */ - public MessagingConsumerSpanBuilder setMessagingMessagePayloadSizeBytes( - long messagingMessagePayloadSizeBytes) { + public MessagingConsumerSpanBuilder setMessagingMessagePayloadSizeBytes(long messagingMessagePayloadSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES); - internalBuilder.setAttribute( - "messaging.message_payload_size_bytes", messagingMessagePayloadSizeBytes); + internalBuilder.setAttribute("messaging.message_payload_size_bytes", messagingMessagePayloadSizeBytes); return this; } /** * Sets messaging.message_payload_compressed_size_bytes. - * - * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload - * in bytes.. + * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in bytes. */ - public MessagingConsumerSpanBuilder setMessagingMessagePayloadCompressedSizeBytes( - long messagingMessagePayloadCompressedSizeBytes) { + public MessagingConsumerSpanBuilder setMessagingMessagePayloadCompressedSizeBytes(long messagingMessagePayloadCompressedSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_COMPRESSED_SIZE_BYTES); - internalBuilder.setAttribute( - "messaging.message_payload_compressed_size_bytes", - messagingMessagePayloadCompressedSizeBytes); + internalBuilder.setAttribute("messaging.message_payload_compressed_size_bytes", messagingMessagePayloadCompressedSizeBytes); return this; } /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ public MessagingConsumerSpanBuilder setNetPeerPort(long netPeerPort) { status.set(AttributeStatus.NET_PEER_PORT); @@ -602,7 +538,6 @@ public MessagingConsumerSpanBuilder setNetPeerPort(long netPeerPort) { /** * Sets net.transport. - * * @param netTransport Strongly recommended for in-process queueing systems. */ public MessagingConsumerSpanBuilder setNetTransport(String netTransport) { @@ -613,9 +548,7 @@ public MessagingConsumerSpanBuilder setNetTransport(String netTransport) { /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public MessagingConsumerSpanBuilder setNetPeerIp(String netPeerIp) { status.set(AttributeStatus.NET_PEER_IP); @@ -625,8 +558,7 @@ public MessagingConsumerSpanBuilder setNetPeerIp(String netPeerIp) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ public MessagingConsumerSpanBuilder setNetPeerName(String netPeerName) { status.set(AttributeStatus.NET_PEER_NAME); @@ -636,8 +568,7 @@ public MessagingConsumerSpanBuilder setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ public MessagingConsumerSpanBuilder setNetHostIp(String netHostIp) { status.set(AttributeStatus.NET_HOST_IP); @@ -647,8 +578,7 @@ public MessagingConsumerSpanBuilder setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ public MessagingConsumerSpanBuilder setNetHostPort(long netHostPort) { status.set(AttributeStatus.NET_HOST_PORT); @@ -658,8 +588,7 @@ public MessagingConsumerSpanBuilder setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ public MessagingConsumerSpanBuilder setNetHostName(String netHostName) { status.set(AttributeStatus.NET_HOST_NAME); @@ -669,14 +598,13 @@ public MessagingConsumerSpanBuilder setNetHostName(String netHostName) { /** * Sets messaging.operation. - * - * @param messagingOperation A string identifying which part and kind of message consumption - * this span describes.. + * @param messagingOperation A string identifying which part and kind of message consumption this span describes. */ public MessagingConsumerSpanBuilder setMessagingOperation(String messagingOperation) { status.set(AttributeStatus.MESSAGING_OPERATION); internalBuilder.setAttribute("messaging.operation", messagingOperation); return this; } + } -} +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingConsumerSynchronousSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingConsumerSynchronousSemanticConvention.java index cb61fa0ca996..140539db14e5 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingConsumerSynchronousSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingConsumerSynchronousSemanticConvention.java @@ -22,156 +22,119 @@ public interface MessagingConsumerSynchronousSemanticConvention { Span getSpan(); + /** * Sets a value for messaging.operation - * - * @param messagingOperation A string identifying which part and kind of message consumption this - * span describes.. + * @param messagingOperation A string identifying which part and kind of message consumption this span describes.. */ - public MessagingConsumerSynchronousSemanticConvention setMessagingOperation( - String messagingOperation); + public MessagingConsumerSynchronousSemanticConvention setMessagingOperation(String messagingOperation); /** * Sets a value for messaging.system - * * @param messagingSystem A string identifying the messaging system.. */ public MessagingConsumerSynchronousSemanticConvention setMessagingSystem(String messagingSystem); /** * Sets a value for messaging.destination - * - * @param messagingDestination The message destination name. This might be equal to the span name - * but is required nevertheless.. + * @param messagingDestination The message destination name. This might be equal to the span name but is required nevertheless.. */ - public MessagingConsumerSynchronousSemanticConvention setMessagingDestination( - String messagingDestination); + public MessagingConsumerSynchronousSemanticConvention setMessagingDestination(String messagingDestination); /** * Sets a value for messaging.destination_kind - * * @param messagingDestinationKind The kind of message destination. */ - public MessagingConsumerSynchronousSemanticConvention setMessagingDestinationKind( - String messagingDestinationKind); + public MessagingConsumerSynchronousSemanticConvention setMessagingDestinationKind(String messagingDestinationKind); /** * Sets a value for messaging.temp_destination - * - * @param messagingTempDestination A boolean that is true if the message destination is - * temporary.. + * @param messagingTempDestination A boolean that is true if the message destination is temporary.. */ - public MessagingConsumerSynchronousSemanticConvention setMessagingTempDestination( - boolean messagingTempDestination); + public MessagingConsumerSynchronousSemanticConvention setMessagingTempDestination(boolean messagingTempDestination); /** * Sets a value for messaging.protocol - * * @param messagingProtocol The name of the transport protocol.. */ - public MessagingConsumerSynchronousSemanticConvention setMessagingProtocol( - String messagingProtocol); + public MessagingConsumerSynchronousSemanticConvention setMessagingProtocol(String messagingProtocol); /** * Sets a value for messaging.protocol_version - * * @param messagingProtocolVersion The version of the transport protocol.. */ - public MessagingConsumerSynchronousSemanticConvention setMessagingProtocolVersion( - String messagingProtocolVersion); + public MessagingConsumerSynchronousSemanticConvention setMessagingProtocolVersion(String messagingProtocolVersion); /** * Sets a value for messaging.url - * * @param messagingUrl Connection string.. */ public MessagingConsumerSynchronousSemanticConvention setMessagingUrl(String messagingUrl); /** * Sets a value for messaging.message_id - * - * @param messagingMessageId A value used by the messaging system as an identifier for the - * message, represented as a string.. + * @param messagingMessageId A value used by the messaging system as an identifier for the message, represented as a string.. */ - public MessagingConsumerSynchronousSemanticConvention setMessagingMessageId( - String messagingMessageId); + public MessagingConsumerSynchronousSemanticConvention setMessagingMessageId(String messagingMessageId); /** * Sets a value for messaging.conversation_id - * - * @param messagingConversationId A value identifying the conversation to which the message - * belongs, represented as a string. Sometimes called "Correlation ID".. + * @param messagingConversationId A value identifying the conversation to which the message belongs, represented as a string. Sometimes called "Correlation ID".. */ - public MessagingConsumerSynchronousSemanticConvention setMessagingConversationId( - String messagingConversationId); + public MessagingConsumerSynchronousSemanticConvention setMessagingConversationId(String messagingConversationId); /** * Sets a value for messaging.message_payload_size_bytes - * - * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in - * bytes. Also use this attribute if it is unknown whether the compressed or uncompressed - * payload size is reported.. + * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in bytes. Also use this attribute if it is unknown whether the compressed or uncompressed payload size is reported.. */ - public MessagingConsumerSynchronousSemanticConvention setMessagingMessagePayloadSizeBytes( - long messagingMessagePayloadSizeBytes); + public MessagingConsumerSynchronousSemanticConvention setMessagingMessagePayloadSizeBytes(long messagingMessagePayloadSizeBytes); /** * Sets a value for messaging.message_payload_compressed_size_bytes - * - * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in - * bytes.. + * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in bytes.. */ - public MessagingConsumerSynchronousSemanticConvention - setMessagingMessagePayloadCompressedSizeBytes( - long messagingMessagePayloadCompressedSizeBytes); + public MessagingConsumerSynchronousSemanticConvention setMessagingMessagePayloadCompressedSizeBytes(long messagingMessagePayloadCompressedSizeBytes); /** * Sets a value for net.peer.port - * * @param netPeerPort Remote port number.. */ public MessagingConsumerSynchronousSemanticConvention setNetPeerPort(long netPeerPort); /** * Sets a value for net.transport - * * @param netTransport Strongly recommended for in-process queueing systems. */ public MessagingConsumerSynchronousSemanticConvention setNetTransport(String netTransport); /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public MessagingConsumerSynchronousSemanticConvention setNetPeerIp(String netPeerIp); /** * Sets a value for net.peer.name - * * @param netPeerName Remote hostname or similar, see note below.. */ public MessagingConsumerSynchronousSemanticConvention setNetPeerName(String netPeerName); /** * Sets a value for net.host.ip - * * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. */ public MessagingConsumerSynchronousSemanticConvention setNetHostIp(String netHostIp); /** * Sets a value for net.host.port - * * @param netHostPort Like `net.peer.port` but for the host port.. */ public MessagingConsumerSynchronousSemanticConvention setNetHostPort(long netHostPort); /** * Sets a value for net.host.name - * * @param netHostName Local hostname or similar, see note below.. */ public MessagingConsumerSynchronousSemanticConvention setNetHostName(String netHostName); -} + +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingConsumerSynchronousSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingConsumerSynchronousSpan.java index 4387ac21a768..6faf6cf474a5 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingConsumerSynchronousSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingConsumerSynchronousSpan.java @@ -25,8 +25,7 @@ * * * * Conditional attributes: @@ -45,8 +44,7 @@ *
  • net.peer.ip * */ -public class MessagingConsumerSynchronousSpan extends DelegatingSpan - implements MessagingConsumerSynchronousSemanticConvention { +public class MessagingConsumerSynchronousSpan extends DelegatingSpan implements MessagingConsumerSynchronousSemanticConvention { enum AttributeStatus { EMPTY, @@ -69,6 +67,7 @@ enum AttributeStatus { NET_HOST_IP, NET_HOST_PORT, NET_HOST_NAME; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -95,9 +94,7 @@ public long getValue() { } @SuppressWarnings("unused") - private static final Logger logger = - Logger.getLogger(MessagingConsumerSynchronousSpan.class.getName()); - + private static final Logger logger = Logger.getLogger(MessagingConsumerSynchronousSpan.class.getName()); public final AttributeStatus status; protected MessagingConsumerSynchronousSpan(Span span, AttributeStatus status) { @@ -105,31 +102,24 @@ protected MessagingConsumerSynchronousSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * Entry point to generate a {@link MessagingConsumerSynchronousSpan}. - * - * @param tracer Tracer to use - * @param spanName Name for the {@link Span} - * @return a {@link MessagingConsumerSynchronousSpan} object. - */ - public static MessagingConsumerSynchronousSpanBuilder createMessagingConsumerSynchronousSpan( - Tracer tracer, String spanName) { - return new MessagingConsumerSynchronousSpanBuilder(tracer, spanName).setKind(Kind.SERVER); + /** + * Entry point to generate a {@link MessagingConsumerSynchronousSpan}. + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link MessagingConsumerSynchronousSpan} object. + */ + public static MessagingConsumerSynchronousSpanBuilder createMessagingConsumerSynchronousSpanBuilder(Tracer tracer, String spanName) { + return new MessagingConsumerSynchronousSpanBuilder(tracer, spanName).setKind(Span.Kind.SERVER); } /** - * Creates a {@link MessagingConsumerSynchronousSpan} from a {@link MessagingConsumerSpan}. - * - * @param builder {@link MessagingConsumerSpan.MessagingConsumerSpanBuilder} to use. - * @return a {@link MessagingConsumerSynchronousSpan} object built from a {@link - * MessagingConsumerSpan}. - */ - public static MessagingConsumerSynchronousSpanBuilder createMessagingConsumerSynchronousSpan( - MessagingConsumerSpan.MessagingConsumerSpanBuilder builder) { - // we accept a builder from MessagingConsumer since MessagingConsumerSynchronous "extends" - // MessagingConsumer - return new MessagingConsumerSynchronousSpanBuilder( - builder.getSpanBuilder(), builder.status.getValue()); + * Creates a {@link MessagingConsumerSynchronousSpan} from a {@link MessagingConsumerSpan}. + * @param builder {@link MessagingConsumerSpan.MessagingConsumerSpanBuilder} to use. + * @return a {@link MessagingConsumerSynchronousSpan} object built from a {@link MessagingConsumerSpan}. + */ + public static MessagingConsumerSynchronousSpanBuilder createMessagingConsumerSynchronousSpanBuilder(MessagingConsumerSpan.MessagingConsumerSpanBuilder builder) { + // we accept a builder from MessagingConsumer since MessagingConsumerSynchronous "extends" MessagingConsumer + return new MessagingConsumerSynchronousSpanBuilder(builder.getSpanBuilder(), builder.status.getValue()); } /** @return the Span used internally */ @@ -154,8 +144,8 @@ public void end() { // extra constraints. { boolean flag = - (!this.status.isSet(AttributeStatus.NET_PEER_NAME)) - || (!this.status.isSet(AttributeStatus.NET_PEER_IP)); + (!this.status.isSet(AttributeStatus.NET_PEER_NAME) ) || + (!this.status.isSet(AttributeStatus.NET_PEER_IP) ) ; if (flag) { logger.info("Constraint not respected!"); } @@ -169,15 +159,13 @@ public void end() { } } + /** * Sets messaging.operation. - * - * @param messagingOperation A string identifying which part and kind of message consumption this - * span describes.. + * @param messagingOperation A string identifying which part and kind of message consumption this span describes. */ @Override - public MessagingConsumerSynchronousSemanticConvention setMessagingOperation( - String messagingOperation) { + public MessagingConsumerSynchronousSemanticConvention setMessagingOperation(String messagingOperation) { status.set(AttributeStatus.MESSAGING_OPERATION); delegate.setAttribute("messaging.operation", messagingOperation); return this; @@ -185,8 +173,7 @@ public MessagingConsumerSynchronousSemanticConvention setMessagingOperation( /** * Sets messaging.system. - * - * @param messagingSystem A string identifying the messaging system.. + * @param messagingSystem A string identifying the messaging system. */ @Override public MessagingConsumerSynchronousSemanticConvention setMessagingSystem(String messagingSystem) { @@ -197,13 +184,10 @@ public MessagingConsumerSynchronousSemanticConvention setMessagingSystem(String /** * Sets messaging.destination. - * - * @param messagingDestination The message destination name. This might be equal to the span name - * but is required nevertheless.. + * @param messagingDestination The message destination name. This might be equal to the span name but is required nevertheless. */ @Override - public MessagingConsumerSynchronousSemanticConvention setMessagingDestination( - String messagingDestination) { + public MessagingConsumerSynchronousSemanticConvention setMessagingDestination(String messagingDestination) { status.set(AttributeStatus.MESSAGING_DESTINATION); delegate.setAttribute("messaging.destination", messagingDestination); return this; @@ -211,12 +195,10 @@ public MessagingConsumerSynchronousSemanticConvention setMessagingDestination( /** * Sets messaging.destination_kind. - * * @param messagingDestinationKind The kind of message destination. */ @Override - public MessagingConsumerSynchronousSemanticConvention setMessagingDestinationKind( - String messagingDestinationKind) { + public MessagingConsumerSynchronousSemanticConvention setMessagingDestinationKind(String messagingDestinationKind) { status.set(AttributeStatus.MESSAGING_DESTINATION_KIND); delegate.setAttribute("messaging.destination_kind", messagingDestinationKind); return this; @@ -224,13 +206,10 @@ public MessagingConsumerSynchronousSemanticConvention setMessagingDestinationKin /** * Sets messaging.temp_destination. - * - * @param messagingTempDestination A boolean that is true if the message destination is - * temporary.. + * @param messagingTempDestination A boolean that is true if the message destination is temporary. */ @Override - public MessagingConsumerSynchronousSemanticConvention setMessagingTempDestination( - boolean messagingTempDestination) { + public MessagingConsumerSynchronousSemanticConvention setMessagingTempDestination(boolean messagingTempDestination) { status.set(AttributeStatus.MESSAGING_TEMP_DESTINATION); delegate.setAttribute("messaging.temp_destination", messagingTempDestination); return this; @@ -238,12 +217,10 @@ public MessagingConsumerSynchronousSemanticConvention setMessagingTempDestinatio /** * Sets messaging.protocol. - * - * @param messagingProtocol The name of the transport protocol.. + * @param messagingProtocol The name of the transport protocol. */ @Override - public MessagingConsumerSynchronousSemanticConvention setMessagingProtocol( - String messagingProtocol) { + public MessagingConsumerSynchronousSemanticConvention setMessagingProtocol(String messagingProtocol) { status.set(AttributeStatus.MESSAGING_PROTOCOL); delegate.setAttribute("messaging.protocol", messagingProtocol); return this; @@ -251,12 +228,10 @@ public MessagingConsumerSynchronousSemanticConvention setMessagingProtocol( /** * Sets messaging.protocol_version. - * - * @param messagingProtocolVersion The version of the transport protocol.. + * @param messagingProtocolVersion The version of the transport protocol. */ @Override - public MessagingConsumerSynchronousSemanticConvention setMessagingProtocolVersion( - String messagingProtocolVersion) { + public MessagingConsumerSynchronousSemanticConvention setMessagingProtocolVersion(String messagingProtocolVersion) { status.set(AttributeStatus.MESSAGING_PROTOCOL_VERSION); delegate.setAttribute("messaging.protocol_version", messagingProtocolVersion); return this; @@ -264,8 +239,7 @@ public MessagingConsumerSynchronousSemanticConvention setMessagingProtocolVersio /** * Sets messaging.url. - * - * @param messagingUrl Connection string.. + * @param messagingUrl Connection string. */ @Override public MessagingConsumerSynchronousSemanticConvention setMessagingUrl(String messagingUrl) { @@ -276,13 +250,10 @@ public MessagingConsumerSynchronousSemanticConvention setMessagingUrl(String mes /** * Sets messaging.message_id. - * - * @param messagingMessageId A value used by the messaging system as an identifier for the - * message, represented as a string.. + * @param messagingMessageId A value used by the messaging system as an identifier for the message, represented as a string. */ @Override - public MessagingConsumerSynchronousSemanticConvention setMessagingMessageId( - String messagingMessageId) { + public MessagingConsumerSynchronousSemanticConvention setMessagingMessageId(String messagingMessageId) { status.set(AttributeStatus.MESSAGING_MESSAGE_ID); delegate.setAttribute("messaging.message_id", messagingMessageId); return this; @@ -290,13 +261,10 @@ public MessagingConsumerSynchronousSemanticConvention setMessagingMessageId( /** * Sets messaging.conversation_id. - * - * @param messagingConversationId A value identifying the conversation to which the message - * belongs, represented as a string. Sometimes called "Correlation ID".. + * @param messagingConversationId A value identifying the conversation to which the message belongs, represented as a string. Sometimes called "Correlation ID". */ @Override - public MessagingConsumerSynchronousSemanticConvention setMessagingConversationId( - String messagingConversationId) { + public MessagingConsumerSynchronousSemanticConvention setMessagingConversationId(String messagingConversationId) { status.set(AttributeStatus.MESSAGING_CONVERSATION_ID); delegate.setAttribute("messaging.conversation_id", messagingConversationId); return this; @@ -304,14 +272,10 @@ public MessagingConsumerSynchronousSemanticConvention setMessagingConversationId /** * Sets messaging.message_payload_size_bytes. - * - * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in - * bytes. Also use this attribute if it is unknown whether the compressed or uncompressed - * payload size is reported.. + * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in bytes. Also use this attribute if it is unknown whether the compressed or uncompressed payload size is reported. */ @Override - public MessagingConsumerSynchronousSemanticConvention setMessagingMessagePayloadSizeBytes( - long messagingMessagePayloadSizeBytes) { + public MessagingConsumerSynchronousSemanticConvention setMessagingMessagePayloadSizeBytes(long messagingMessagePayloadSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES); delegate.setAttribute("messaging.message_payload_size_bytes", messagingMessagePayloadSizeBytes); return this; @@ -319,25 +283,18 @@ public MessagingConsumerSynchronousSemanticConvention setMessagingMessagePayload /** * Sets messaging.message_payload_compressed_size_bytes. - * - * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in - * bytes.. + * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in bytes. */ @Override - public MessagingConsumerSynchronousSemanticConvention - setMessagingMessagePayloadCompressedSizeBytes( - long messagingMessagePayloadCompressedSizeBytes) { + public MessagingConsumerSynchronousSemanticConvention setMessagingMessagePayloadCompressedSizeBytes(long messagingMessagePayloadCompressedSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_COMPRESSED_SIZE_BYTES); - delegate.setAttribute( - "messaging.message_payload_compressed_size_bytes", - messagingMessagePayloadCompressedSizeBytes); + delegate.setAttribute("messaging.message_payload_compressed_size_bytes", messagingMessagePayloadCompressedSizeBytes); return this; } /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ @Override public MessagingConsumerSynchronousSemanticConvention setNetPeerPort(long netPeerPort) { @@ -348,7 +305,6 @@ public MessagingConsumerSynchronousSemanticConvention setNetPeerPort(long netPee /** * Sets net.transport. - * * @param netTransport Strongly recommended for in-process queueing systems. */ @Override @@ -360,9 +316,7 @@ public MessagingConsumerSynchronousSemanticConvention setNetTransport(String net /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ @Override public MessagingConsumerSynchronousSemanticConvention setNetPeerIp(String netPeerIp) { @@ -373,8 +327,7 @@ public MessagingConsumerSynchronousSemanticConvention setNetPeerIp(String netPee /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ @Override public MessagingConsumerSynchronousSemanticConvention setNetPeerName(String netPeerName) { @@ -385,8 +338,7 @@ public MessagingConsumerSynchronousSemanticConvention setNetPeerName(String netP /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ @Override public MessagingConsumerSynchronousSemanticConvention setNetHostIp(String netHostIp) { @@ -397,8 +349,7 @@ public MessagingConsumerSynchronousSemanticConvention setNetHostIp(String netHos /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ @Override public MessagingConsumerSynchronousSemanticConvention setNetHostPort(long netHostPort) { @@ -409,8 +360,7 @@ public MessagingConsumerSynchronousSemanticConvention setNetHostPort(long netHos /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ @Override public MessagingConsumerSynchronousSemanticConvention setNetHostName(String netHostName) { @@ -419,39 +369,42 @@ public MessagingConsumerSynchronousSemanticConvention setNetHostName(String netH return this; } - /** Builder class for {@link MessagingConsumerSynchronousSpan}. */ - public static class MessagingConsumerSynchronousSpanBuilder { + + /** + * Builder class for {@link MessagingConsumerSynchronousSpan}. + */ + public static class MessagingConsumerSynchronousSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected MessagingConsumerSynchronousSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public MessagingConsumerSynchronousSpanBuilder(Builder spanBuilder, long attributes) { + public MessagingConsumerSynchronousSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public MessagingConsumerSynchronousSpanBuilder setParent(Span parent) { + public MessagingConsumerSynchronousSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public MessagingConsumerSynchronousSpanBuilder setParent(SpanContext remoteParent) { + public MessagingConsumerSynchronousSpanBuilder 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 MessagingConsumerSynchronousSpanBuilder setKind(Kind kind) { + public MessagingConsumerSynchronousSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -462,14 +415,12 @@ public MessagingConsumerSynchronousSpan start() { return new MessagingConsumerSynchronousSpan(this.internalBuilder.startSpan(), status); } + /** * Sets messaging.operation. - * - * @param messagingOperation A string identifying which part and kind of message consumption - * this span describes.. + * @param messagingOperation A string identifying which part and kind of message consumption this span describes. */ - public MessagingConsumerSynchronousSpanBuilder setMessagingOperation( - String messagingOperation) { + public MessagingConsumerSynchronousSpanBuilder setMessagingOperation(String messagingOperation) { status.set(AttributeStatus.MESSAGING_OPERATION); internalBuilder.setAttribute("messaging.operation", messagingOperation); return this; @@ -477,8 +428,7 @@ public MessagingConsumerSynchronousSpanBuilder setMessagingOperation( /** * Sets messaging.system. - * - * @param messagingSystem A string identifying the messaging system.. + * @param messagingSystem A string identifying the messaging system. */ public MessagingConsumerSynchronousSpanBuilder setMessagingSystem(String messagingSystem) { status.set(AttributeStatus.MESSAGING_SYSTEM); @@ -488,12 +438,9 @@ public MessagingConsumerSynchronousSpanBuilder setMessagingSystem(String messagi /** * Sets messaging.destination. - * - * @param messagingDestination The message destination name. This might be equal to the span - * name but is required nevertheless.. + * @param messagingDestination The message destination name. This might be equal to the span name but is required nevertheless. */ - public MessagingConsumerSynchronousSpanBuilder setMessagingDestination( - String messagingDestination) { + public MessagingConsumerSynchronousSpanBuilder setMessagingDestination(String messagingDestination) { status.set(AttributeStatus.MESSAGING_DESTINATION); internalBuilder.setAttribute("messaging.destination", messagingDestination); return this; @@ -501,11 +448,9 @@ public MessagingConsumerSynchronousSpanBuilder setMessagingDestination( /** * Sets messaging.destination_kind. - * * @param messagingDestinationKind The kind of message destination. */ - public MessagingConsumerSynchronousSpanBuilder setMessagingDestinationKind( - String messagingDestinationKind) { + public MessagingConsumerSynchronousSpanBuilder setMessagingDestinationKind(String messagingDestinationKind) { status.set(AttributeStatus.MESSAGING_DESTINATION_KIND); internalBuilder.setAttribute("messaging.destination_kind", messagingDestinationKind); return this; @@ -513,12 +458,9 @@ public MessagingConsumerSynchronousSpanBuilder setMessagingDestinationKind( /** * Sets messaging.temp_destination. - * - * @param messagingTempDestination A boolean that is true if the message destination is - * temporary.. + * @param messagingTempDestination A boolean that is true if the message destination is temporary. */ - public MessagingConsumerSynchronousSpanBuilder setMessagingTempDestination( - boolean messagingTempDestination) { + public MessagingConsumerSynchronousSpanBuilder setMessagingTempDestination(boolean messagingTempDestination) { status.set(AttributeStatus.MESSAGING_TEMP_DESTINATION); internalBuilder.setAttribute("messaging.temp_destination", messagingTempDestination); return this; @@ -526,8 +468,7 @@ public MessagingConsumerSynchronousSpanBuilder setMessagingTempDestination( /** * Sets messaging.protocol. - * - * @param messagingProtocol The name of the transport protocol.. + * @param messagingProtocol The name of the transport protocol. */ public MessagingConsumerSynchronousSpanBuilder setMessagingProtocol(String messagingProtocol) { status.set(AttributeStatus.MESSAGING_PROTOCOL); @@ -537,11 +478,9 @@ public MessagingConsumerSynchronousSpanBuilder setMessagingProtocol(String messa /** * Sets messaging.protocol_version. - * - * @param messagingProtocolVersion The version of the transport protocol.. + * @param messagingProtocolVersion The version of the transport protocol. */ - public MessagingConsumerSynchronousSpanBuilder setMessagingProtocolVersion( - String messagingProtocolVersion) { + public MessagingConsumerSynchronousSpanBuilder setMessagingProtocolVersion(String messagingProtocolVersion) { status.set(AttributeStatus.MESSAGING_PROTOCOL_VERSION); internalBuilder.setAttribute("messaging.protocol_version", messagingProtocolVersion); return this; @@ -549,8 +488,7 @@ public MessagingConsumerSynchronousSpanBuilder setMessagingProtocolVersion( /** * Sets messaging.url. - * - * @param messagingUrl Connection string.. + * @param messagingUrl Connection string. */ public MessagingConsumerSynchronousSpanBuilder setMessagingUrl(String messagingUrl) { status.set(AttributeStatus.MESSAGING_URL); @@ -560,12 +498,9 @@ public MessagingConsumerSynchronousSpanBuilder setMessagingUrl(String messagingU /** * Sets messaging.message_id. - * - * @param messagingMessageId A value used by the messaging system as an identifier for the - * message, represented as a string.. + * @param messagingMessageId A value used by the messaging system as an identifier for the message, represented as a string. */ - public MessagingConsumerSynchronousSpanBuilder setMessagingMessageId( - String messagingMessageId) { + public MessagingConsumerSynchronousSpanBuilder setMessagingMessageId(String messagingMessageId) { status.set(AttributeStatus.MESSAGING_MESSAGE_ID); internalBuilder.setAttribute("messaging.message_id", messagingMessageId); return this; @@ -573,12 +508,9 @@ public MessagingConsumerSynchronousSpanBuilder setMessagingMessageId( /** * Sets messaging.conversation_id. - * - * @param messagingConversationId A value identifying the conversation to which the message - * belongs, represented as a string. Sometimes called "Correlation ID".. + * @param messagingConversationId A value identifying the conversation to which the message belongs, represented as a string. Sometimes called "Correlation ID". */ - public MessagingConsumerSynchronousSpanBuilder setMessagingConversationId( - String messagingConversationId) { + public MessagingConsumerSynchronousSpanBuilder setMessagingConversationId(String messagingConversationId) { status.set(AttributeStatus.MESSAGING_CONVERSATION_ID); internalBuilder.setAttribute("messaging.conversation_id", messagingConversationId); return this; @@ -586,38 +518,27 @@ public MessagingConsumerSynchronousSpanBuilder setMessagingConversationId( /** * Sets messaging.message_payload_size_bytes. - * - * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in - * bytes. Also use this attribute if it is unknown whether the compressed or uncompressed - * payload size is reported.. + * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in bytes. Also use this attribute if it is unknown whether the compressed or uncompressed payload size is reported. */ - public MessagingConsumerSynchronousSpanBuilder setMessagingMessagePayloadSizeBytes( - long messagingMessagePayloadSizeBytes) { + public MessagingConsumerSynchronousSpanBuilder setMessagingMessagePayloadSizeBytes(long messagingMessagePayloadSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES); - internalBuilder.setAttribute( - "messaging.message_payload_size_bytes", messagingMessagePayloadSizeBytes); + internalBuilder.setAttribute("messaging.message_payload_size_bytes", messagingMessagePayloadSizeBytes); return this; } /** * Sets messaging.message_payload_compressed_size_bytes. - * - * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload - * in bytes.. + * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in bytes. */ - public MessagingConsumerSynchronousSpanBuilder setMessagingMessagePayloadCompressedSizeBytes( - long messagingMessagePayloadCompressedSizeBytes) { + public MessagingConsumerSynchronousSpanBuilder setMessagingMessagePayloadCompressedSizeBytes(long messagingMessagePayloadCompressedSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_COMPRESSED_SIZE_BYTES); - internalBuilder.setAttribute( - "messaging.message_payload_compressed_size_bytes", - messagingMessagePayloadCompressedSizeBytes); + internalBuilder.setAttribute("messaging.message_payload_compressed_size_bytes", messagingMessagePayloadCompressedSizeBytes); return this; } /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ public MessagingConsumerSynchronousSpanBuilder setNetPeerPort(long netPeerPort) { status.set(AttributeStatus.NET_PEER_PORT); @@ -627,7 +548,6 @@ public MessagingConsumerSynchronousSpanBuilder setNetPeerPort(long netPeerPort) /** * Sets net.transport. - * * @param netTransport Strongly recommended for in-process queueing systems. */ public MessagingConsumerSynchronousSpanBuilder setNetTransport(String netTransport) { @@ -638,9 +558,7 @@ public MessagingConsumerSynchronousSpanBuilder setNetTransport(String netTranspo /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public MessagingConsumerSynchronousSpanBuilder setNetPeerIp(String netPeerIp) { status.set(AttributeStatus.NET_PEER_IP); @@ -650,8 +568,7 @@ public MessagingConsumerSynchronousSpanBuilder setNetPeerIp(String netPeerIp) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ public MessagingConsumerSynchronousSpanBuilder setNetPeerName(String netPeerName) { status.set(AttributeStatus.NET_PEER_NAME); @@ -661,8 +578,7 @@ public MessagingConsumerSynchronousSpanBuilder setNetPeerName(String netPeerName /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ public MessagingConsumerSynchronousSpanBuilder setNetHostIp(String netHostIp) { status.set(AttributeStatus.NET_HOST_IP); @@ -672,8 +588,7 @@ public MessagingConsumerSynchronousSpanBuilder setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ public MessagingConsumerSynchronousSpanBuilder setNetHostPort(long netHostPort) { status.set(AttributeStatus.NET_HOST_PORT); @@ -683,13 +598,13 @@ public MessagingConsumerSynchronousSpanBuilder setNetHostPort(long netHostPort) /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ public MessagingConsumerSynchronousSpanBuilder setNetHostName(String netHostName) { status.set(AttributeStatus.NET_HOST_NAME); internalBuilder.setAttribute("net.host.name", netHostName); return this; } + } -} +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingProducerSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingProducerSemanticConvention.java index ebf4b2c70825..642457500b9b 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingProducerSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingProducerSemanticConvention.java @@ -22,143 +22,113 @@ public interface MessagingProducerSemanticConvention { Span getSpan(); + /** * Sets a value for messaging.system - * * @param messagingSystem A string identifying the messaging system.. */ public MessagingProducerSemanticConvention setMessagingSystem(String messagingSystem); /** * Sets a value for messaging.destination - * - * @param messagingDestination The message destination name. This might be equal to the span name - * but is required nevertheless.. + * @param messagingDestination The message destination name. This might be equal to the span name but is required nevertheless.. */ public MessagingProducerSemanticConvention setMessagingDestination(String messagingDestination); /** * Sets a value for messaging.destination_kind - * * @param messagingDestinationKind The kind of message destination. */ - public MessagingProducerSemanticConvention setMessagingDestinationKind( - String messagingDestinationKind); + public MessagingProducerSemanticConvention setMessagingDestinationKind(String messagingDestinationKind); /** * Sets a value for messaging.temp_destination - * - * @param messagingTempDestination A boolean that is true if the message destination is - * temporary.. + * @param messagingTempDestination A boolean that is true if the message destination is temporary.. */ - public MessagingProducerSemanticConvention setMessagingTempDestination( - boolean messagingTempDestination); + public MessagingProducerSemanticConvention setMessagingTempDestination(boolean messagingTempDestination); /** * Sets a value for messaging.protocol - * * @param messagingProtocol The name of the transport protocol.. */ public MessagingProducerSemanticConvention setMessagingProtocol(String messagingProtocol); /** * Sets a value for messaging.protocol_version - * * @param messagingProtocolVersion The version of the transport protocol.. */ - public MessagingProducerSemanticConvention setMessagingProtocolVersion( - String messagingProtocolVersion); + public MessagingProducerSemanticConvention setMessagingProtocolVersion(String messagingProtocolVersion); /** * Sets a value for messaging.url - * * @param messagingUrl Connection string.. */ public MessagingProducerSemanticConvention setMessagingUrl(String messagingUrl); /** * Sets a value for messaging.message_id - * - * @param messagingMessageId A value used by the messaging system as an identifier for the - * message, represented as a string.. + * @param messagingMessageId A value used by the messaging system as an identifier for the message, represented as a string.. */ public MessagingProducerSemanticConvention setMessagingMessageId(String messagingMessageId); /** * Sets a value for messaging.conversation_id - * - * @param messagingConversationId A value identifying the conversation to which the message - * belongs, represented as a string. Sometimes called "Correlation ID".. + * @param messagingConversationId A value identifying the conversation to which the message belongs, represented as a string. Sometimes called "Correlation ID".. */ - public MessagingProducerSemanticConvention setMessagingConversationId( - String messagingConversationId); + public MessagingProducerSemanticConvention setMessagingConversationId(String messagingConversationId); /** * Sets a value for messaging.message_payload_size_bytes - * - * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in - * bytes. Also use this attribute if it is unknown whether the compressed or uncompressed - * payload size is reported.. + * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in bytes. Also use this attribute if it is unknown whether the compressed or uncompressed payload size is reported.. */ - public MessagingProducerSemanticConvention setMessagingMessagePayloadSizeBytes( - long messagingMessagePayloadSizeBytes); + public MessagingProducerSemanticConvention setMessagingMessagePayloadSizeBytes(long messagingMessagePayloadSizeBytes); /** * Sets a value for messaging.message_payload_compressed_size_bytes - * - * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in - * bytes.. + * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in bytes.. */ - public MessagingProducerSemanticConvention setMessagingMessagePayloadCompressedSizeBytes( - long messagingMessagePayloadCompressedSizeBytes); + public MessagingProducerSemanticConvention setMessagingMessagePayloadCompressedSizeBytes(long messagingMessagePayloadCompressedSizeBytes); /** * Sets a value for net.peer.port - * * @param netPeerPort Remote port number.. */ public MessagingProducerSemanticConvention setNetPeerPort(long netPeerPort); /** * Sets a value for net.transport - * * @param netTransport Strongly recommended for in-process queueing systems. */ public MessagingProducerSemanticConvention setNetTransport(String netTransport); /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public MessagingProducerSemanticConvention setNetPeerIp(String netPeerIp); /** * Sets a value for net.peer.name - * * @param netPeerName Remote hostname or similar, see note below.. */ public MessagingProducerSemanticConvention setNetPeerName(String netPeerName); /** * Sets a value for net.host.ip - * * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. */ public MessagingProducerSemanticConvention setNetHostIp(String netHostIp); /** * Sets a value for net.host.port - * * @param netHostPort Like `net.peer.port` but for the host port.. */ public MessagingProducerSemanticConvention setNetHostPort(long netHostPort); /** * Sets a value for net.host.name - * * @param netHostName Local hostname or similar, see note below.. */ public MessagingProducerSemanticConvention setNetHostName(String netHostName); -} + +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingProducerSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingProducerSpan.java index 40674970c77c..7f88736f1683 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingProducerSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingProducerSpan.java @@ -25,8 +25,7 @@ * * * * Conditional attributes: @@ -45,8 +44,7 @@ *
  • net.peer.ip * */ -public class MessagingProducerSpan extends DelegatingSpan - implements MessagingProducerSemanticConvention { +public class MessagingProducerSpan extends DelegatingSpan implements MessagingProducerSemanticConvention { enum AttributeStatus { EMPTY, @@ -68,6 +66,7 @@ enum AttributeStatus { NET_HOST_IP, NET_HOST_PORT, NET_HOST_NAME; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -95,7 +94,6 @@ public long getValue() { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(MessagingProducerSpan.class.getName()); - public final AttributeStatus status; protected MessagingProducerSpan(Span span, AttributeStatus status) { @@ -103,27 +101,23 @@ protected MessagingProducerSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * Entry point to generate a {@link MessagingProducerSpan}. - * - * @param tracer Tracer to use - * @param spanName Name for the {@link Span} - * @return a {@link MessagingProducerSpan} object. - */ - public static MessagingProducerSpanBuilder createMessagingProducerSpan( - Tracer tracer, String spanName) { - return new MessagingProducerSpanBuilder(tracer, spanName).setKind(Kind.PRODUCER); + /** + * Entry point to generate a {@link MessagingProducerSpan}. + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link MessagingProducerSpan} object. + */ + public static MessagingProducerSpanBuilder createMessagingProducerSpanBuilder(Tracer tracer, String spanName) { + return new MessagingProducerSpanBuilder(tracer, spanName).setKind(Span.Kind.PRODUCER); } /** - * Creates a {@link MessagingProducerSpan} from a {@link MessagingSpan}. - * - * @param builder {@link MessagingSpan.MessagingSpanBuilder} to use. - * @return a {@link MessagingProducerSpan} object built from a {@link MessagingSpan}. - */ - public static MessagingProducerSpanBuilder createMessagingProducerSpan( - MessagingSpan.MessagingSpanBuilder builder) { - // we accept a builder from Messaging since MessagingProducer "extends" Messaging + * Creates a {@link MessagingProducerSpan} from a {@link MessagingSpan}. + * @param builder {@link MessagingSpan.MessagingSpanBuilder} to use. + * @return a {@link MessagingProducerSpan} object built from a {@link MessagingSpan}. + */ + public static MessagingProducerSpanBuilder createMessagingProducerSpanBuilder(MessagingSpan.MessagingSpanBuilder builder) { + // we accept a builder from Messaging since MessagingProducer "extends" Messaging return new MessagingProducerSpanBuilder(builder.getSpanBuilder(), builder.status.getValue()); } @@ -149,8 +143,8 @@ public void end() { // extra constraints. { boolean flag = - (!this.status.isSet(AttributeStatus.NET_PEER_NAME)) - || (!this.status.isSet(AttributeStatus.NET_PEER_IP)); + (!this.status.isSet(AttributeStatus.NET_PEER_NAME) ) || + (!this.status.isSet(AttributeStatus.NET_PEER_IP) ) ; if (flag) { logger.info("Constraint not respected!"); } @@ -164,10 +158,10 @@ public void end() { } } + /** * Sets messaging.system. - * - * @param messagingSystem A string identifying the messaging system.. + * @param messagingSystem A string identifying the messaging system. */ @Override public MessagingProducerSemanticConvention setMessagingSystem(String messagingSystem) { @@ -178,9 +172,7 @@ public MessagingProducerSemanticConvention setMessagingSystem(String messagingSy /** * Sets messaging.destination. - * - * @param messagingDestination The message destination name. This might be equal to the span name - * but is required nevertheless.. + * @param messagingDestination The message destination name. This might be equal to the span name but is required nevertheless. */ @Override public MessagingProducerSemanticConvention setMessagingDestination(String messagingDestination) { @@ -191,12 +183,10 @@ public MessagingProducerSemanticConvention setMessagingDestination(String messag /** * Sets messaging.destination_kind. - * * @param messagingDestinationKind The kind of message destination. */ @Override - public MessagingProducerSemanticConvention setMessagingDestinationKind( - String messagingDestinationKind) { + public MessagingProducerSemanticConvention setMessagingDestinationKind(String messagingDestinationKind) { status.set(AttributeStatus.MESSAGING_DESTINATION_KIND); delegate.setAttribute("messaging.destination_kind", messagingDestinationKind); return this; @@ -204,13 +194,10 @@ public MessagingProducerSemanticConvention setMessagingDestinationKind( /** * Sets messaging.temp_destination. - * - * @param messagingTempDestination A boolean that is true if the message destination is - * temporary.. + * @param messagingTempDestination A boolean that is true if the message destination is temporary. */ @Override - public MessagingProducerSemanticConvention setMessagingTempDestination( - boolean messagingTempDestination) { + public MessagingProducerSemanticConvention setMessagingTempDestination(boolean messagingTempDestination) { status.set(AttributeStatus.MESSAGING_TEMP_DESTINATION); delegate.setAttribute("messaging.temp_destination", messagingTempDestination); return this; @@ -218,8 +205,7 @@ public MessagingProducerSemanticConvention setMessagingTempDestination( /** * Sets messaging.protocol. - * - * @param messagingProtocol The name of the transport protocol.. + * @param messagingProtocol The name of the transport protocol. */ @Override public MessagingProducerSemanticConvention setMessagingProtocol(String messagingProtocol) { @@ -230,12 +216,10 @@ public MessagingProducerSemanticConvention setMessagingProtocol(String messaging /** * Sets messaging.protocol_version. - * - * @param messagingProtocolVersion The version of the transport protocol.. + * @param messagingProtocolVersion The version of the transport protocol. */ @Override - public MessagingProducerSemanticConvention setMessagingProtocolVersion( - String messagingProtocolVersion) { + public MessagingProducerSemanticConvention setMessagingProtocolVersion(String messagingProtocolVersion) { status.set(AttributeStatus.MESSAGING_PROTOCOL_VERSION); delegate.setAttribute("messaging.protocol_version", messagingProtocolVersion); return this; @@ -243,8 +227,7 @@ public MessagingProducerSemanticConvention setMessagingProtocolVersion( /** * Sets messaging.url. - * - * @param messagingUrl Connection string.. + * @param messagingUrl Connection string. */ @Override public MessagingProducerSemanticConvention setMessagingUrl(String messagingUrl) { @@ -255,9 +238,7 @@ public MessagingProducerSemanticConvention setMessagingUrl(String messagingUrl) /** * Sets messaging.message_id. - * - * @param messagingMessageId A value used by the messaging system as an identifier for the - * message, represented as a string.. + * @param messagingMessageId A value used by the messaging system as an identifier for the message, represented as a string. */ @Override public MessagingProducerSemanticConvention setMessagingMessageId(String messagingMessageId) { @@ -268,13 +249,10 @@ public MessagingProducerSemanticConvention setMessagingMessageId(String messagin /** * Sets messaging.conversation_id. - * - * @param messagingConversationId A value identifying the conversation to which the message - * belongs, represented as a string. Sometimes called "Correlation ID".. + * @param messagingConversationId A value identifying the conversation to which the message belongs, represented as a string. Sometimes called "Correlation ID". */ @Override - public MessagingProducerSemanticConvention setMessagingConversationId( - String messagingConversationId) { + public MessagingProducerSemanticConvention setMessagingConversationId(String messagingConversationId) { status.set(AttributeStatus.MESSAGING_CONVERSATION_ID); delegate.setAttribute("messaging.conversation_id", messagingConversationId); return this; @@ -282,14 +260,10 @@ public MessagingProducerSemanticConvention setMessagingConversationId( /** * Sets messaging.message_payload_size_bytes. - * - * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in - * bytes. Also use this attribute if it is unknown whether the compressed or uncompressed - * payload size is reported.. + * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in bytes. Also use this attribute if it is unknown whether the compressed or uncompressed payload size is reported. */ @Override - public MessagingProducerSemanticConvention setMessagingMessagePayloadSizeBytes( - long messagingMessagePayloadSizeBytes) { + public MessagingProducerSemanticConvention setMessagingMessagePayloadSizeBytes(long messagingMessagePayloadSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES); delegate.setAttribute("messaging.message_payload_size_bytes", messagingMessagePayloadSizeBytes); return this; @@ -297,24 +271,18 @@ public MessagingProducerSemanticConvention setMessagingMessagePayloadSizeBytes( /** * Sets messaging.message_payload_compressed_size_bytes. - * - * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in - * bytes.. + * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in bytes. */ @Override - public MessagingProducerSemanticConvention setMessagingMessagePayloadCompressedSizeBytes( - long messagingMessagePayloadCompressedSizeBytes) { + public MessagingProducerSemanticConvention setMessagingMessagePayloadCompressedSizeBytes(long messagingMessagePayloadCompressedSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_COMPRESSED_SIZE_BYTES); - delegate.setAttribute( - "messaging.message_payload_compressed_size_bytes", - messagingMessagePayloadCompressedSizeBytes); + delegate.setAttribute("messaging.message_payload_compressed_size_bytes", messagingMessagePayloadCompressedSizeBytes); return this; } /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ @Override public MessagingProducerSemanticConvention setNetPeerPort(long netPeerPort) { @@ -325,7 +293,6 @@ public MessagingProducerSemanticConvention setNetPeerPort(long netPeerPort) { /** * Sets net.transport. - * * @param netTransport Strongly recommended for in-process queueing systems. */ @Override @@ -337,9 +304,7 @@ public MessagingProducerSemanticConvention setNetTransport(String netTransport) /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ @Override public MessagingProducerSemanticConvention setNetPeerIp(String netPeerIp) { @@ -350,8 +315,7 @@ public MessagingProducerSemanticConvention setNetPeerIp(String netPeerIp) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ @Override public MessagingProducerSemanticConvention setNetPeerName(String netPeerName) { @@ -362,8 +326,7 @@ public MessagingProducerSemanticConvention setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ @Override public MessagingProducerSemanticConvention setNetHostIp(String netHostIp) { @@ -374,8 +337,7 @@ public MessagingProducerSemanticConvention setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ @Override public MessagingProducerSemanticConvention setNetHostPort(long netHostPort) { @@ -386,8 +348,7 @@ public MessagingProducerSemanticConvention setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ @Override public MessagingProducerSemanticConvention setNetHostName(String netHostName) { @@ -396,39 +357,42 @@ public MessagingProducerSemanticConvention setNetHostName(String netHostName) { return this; } - /** Builder class for {@link MessagingProducerSpan}. */ - public static class MessagingProducerSpanBuilder { + + /** + * Builder class for {@link MessagingProducerSpan}. + */ + public static class MessagingProducerSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected MessagingProducerSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public MessagingProducerSpanBuilder(Builder spanBuilder, long attributes) { + public MessagingProducerSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public MessagingProducerSpanBuilder setParent(Span parent) { + public MessagingProducerSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public MessagingProducerSpanBuilder setParent(SpanContext remoteParent) { + public MessagingProducerSpanBuilder 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 MessagingProducerSpanBuilder setKind(Kind kind) { + public MessagingProducerSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -439,10 +403,10 @@ public MessagingProducerSpan start() { return new MessagingProducerSpan(this.internalBuilder.startSpan(), status); } + /** * Sets messaging.system. - * - * @param messagingSystem A string identifying the messaging system.. + * @param messagingSystem A string identifying the messaging system. */ public MessagingProducerSpanBuilder setMessagingSystem(String messagingSystem) { status.set(AttributeStatus.MESSAGING_SYSTEM); @@ -452,9 +416,7 @@ public MessagingProducerSpanBuilder setMessagingSystem(String messagingSystem) { /** * Sets messaging.destination. - * - * @param messagingDestination The message destination name. This might be equal to the span - * name but is required nevertheless.. + * @param messagingDestination The message destination name. This might be equal to the span name but is required nevertheless. */ public MessagingProducerSpanBuilder setMessagingDestination(String messagingDestination) { status.set(AttributeStatus.MESSAGING_DESTINATION); @@ -464,11 +426,9 @@ public MessagingProducerSpanBuilder setMessagingDestination(String messagingDest /** * Sets messaging.destination_kind. - * * @param messagingDestinationKind The kind of message destination. */ - public MessagingProducerSpanBuilder setMessagingDestinationKind( - String messagingDestinationKind) { + public MessagingProducerSpanBuilder setMessagingDestinationKind(String messagingDestinationKind) { status.set(AttributeStatus.MESSAGING_DESTINATION_KIND); internalBuilder.setAttribute("messaging.destination_kind", messagingDestinationKind); return this; @@ -476,12 +436,9 @@ public MessagingProducerSpanBuilder setMessagingDestinationKind( /** * Sets messaging.temp_destination. - * - * @param messagingTempDestination A boolean that is true if the message destination is - * temporary.. + * @param messagingTempDestination A boolean that is true if the message destination is temporary. */ - public MessagingProducerSpanBuilder setMessagingTempDestination( - boolean messagingTempDestination) { + public MessagingProducerSpanBuilder setMessagingTempDestination(boolean messagingTempDestination) { status.set(AttributeStatus.MESSAGING_TEMP_DESTINATION); internalBuilder.setAttribute("messaging.temp_destination", messagingTempDestination); return this; @@ -489,8 +446,7 @@ public MessagingProducerSpanBuilder setMessagingTempDestination( /** * Sets messaging.protocol. - * - * @param messagingProtocol The name of the transport protocol.. + * @param messagingProtocol The name of the transport protocol. */ public MessagingProducerSpanBuilder setMessagingProtocol(String messagingProtocol) { status.set(AttributeStatus.MESSAGING_PROTOCOL); @@ -500,11 +456,9 @@ public MessagingProducerSpanBuilder setMessagingProtocol(String messagingProtoco /** * Sets messaging.protocol_version. - * - * @param messagingProtocolVersion The version of the transport protocol.. + * @param messagingProtocolVersion The version of the transport protocol. */ - public MessagingProducerSpanBuilder setMessagingProtocolVersion( - String messagingProtocolVersion) { + public MessagingProducerSpanBuilder setMessagingProtocolVersion(String messagingProtocolVersion) { status.set(AttributeStatus.MESSAGING_PROTOCOL_VERSION); internalBuilder.setAttribute("messaging.protocol_version", messagingProtocolVersion); return this; @@ -512,8 +466,7 @@ public MessagingProducerSpanBuilder setMessagingProtocolVersion( /** * Sets messaging.url. - * - * @param messagingUrl Connection string.. + * @param messagingUrl Connection string. */ public MessagingProducerSpanBuilder setMessagingUrl(String messagingUrl) { status.set(AttributeStatus.MESSAGING_URL); @@ -523,9 +476,7 @@ public MessagingProducerSpanBuilder setMessagingUrl(String messagingUrl) { /** * Sets messaging.message_id. - * - * @param messagingMessageId A value used by the messaging system as an identifier for the - * message, represented as a string.. + * @param messagingMessageId A value used by the messaging system as an identifier for the message, represented as a string. */ public MessagingProducerSpanBuilder setMessagingMessageId(String messagingMessageId) { status.set(AttributeStatus.MESSAGING_MESSAGE_ID); @@ -535,9 +486,7 @@ public MessagingProducerSpanBuilder setMessagingMessageId(String messagingMessag /** * Sets messaging.conversation_id. - * - * @param messagingConversationId A value identifying the conversation to which the message - * belongs, represented as a string. Sometimes called "Correlation ID".. + * @param messagingConversationId A value identifying the conversation to which the message belongs, represented as a string. Sometimes called "Correlation ID". */ public MessagingProducerSpanBuilder setMessagingConversationId(String messagingConversationId) { status.set(AttributeStatus.MESSAGING_CONVERSATION_ID); @@ -547,38 +496,27 @@ public MessagingProducerSpanBuilder setMessagingConversationId(String messagingC /** * Sets messaging.message_payload_size_bytes. - * - * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in - * bytes. Also use this attribute if it is unknown whether the compressed or uncompressed - * payload size is reported.. + * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in bytes. Also use this attribute if it is unknown whether the compressed or uncompressed payload size is reported. */ - public MessagingProducerSpanBuilder setMessagingMessagePayloadSizeBytes( - long messagingMessagePayloadSizeBytes) { + public MessagingProducerSpanBuilder setMessagingMessagePayloadSizeBytes(long messagingMessagePayloadSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES); - internalBuilder.setAttribute( - "messaging.message_payload_size_bytes", messagingMessagePayloadSizeBytes); + internalBuilder.setAttribute("messaging.message_payload_size_bytes", messagingMessagePayloadSizeBytes); return this; } /** * Sets messaging.message_payload_compressed_size_bytes. - * - * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload - * in bytes.. + * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in bytes. */ - public MessagingProducerSpanBuilder setMessagingMessagePayloadCompressedSizeBytes( - long messagingMessagePayloadCompressedSizeBytes) { + public MessagingProducerSpanBuilder setMessagingMessagePayloadCompressedSizeBytes(long messagingMessagePayloadCompressedSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_COMPRESSED_SIZE_BYTES); - internalBuilder.setAttribute( - "messaging.message_payload_compressed_size_bytes", - messagingMessagePayloadCompressedSizeBytes); + internalBuilder.setAttribute("messaging.message_payload_compressed_size_bytes", messagingMessagePayloadCompressedSizeBytes); return this; } /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ public MessagingProducerSpanBuilder setNetPeerPort(long netPeerPort) { status.set(AttributeStatus.NET_PEER_PORT); @@ -588,7 +526,6 @@ public MessagingProducerSpanBuilder setNetPeerPort(long netPeerPort) { /** * Sets net.transport. - * * @param netTransport Strongly recommended for in-process queueing systems. */ public MessagingProducerSpanBuilder setNetTransport(String netTransport) { @@ -599,9 +536,7 @@ public MessagingProducerSpanBuilder setNetTransport(String netTransport) { /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public MessagingProducerSpanBuilder setNetPeerIp(String netPeerIp) { status.set(AttributeStatus.NET_PEER_IP); @@ -611,8 +546,7 @@ public MessagingProducerSpanBuilder setNetPeerIp(String netPeerIp) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ public MessagingProducerSpanBuilder setNetPeerName(String netPeerName) { status.set(AttributeStatus.NET_PEER_NAME); @@ -622,8 +556,7 @@ public MessagingProducerSpanBuilder setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ public MessagingProducerSpanBuilder setNetHostIp(String netHostIp) { status.set(AttributeStatus.NET_HOST_IP); @@ -633,8 +566,7 @@ public MessagingProducerSpanBuilder setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ public MessagingProducerSpanBuilder setNetHostPort(long netHostPort) { status.set(AttributeStatus.NET_HOST_PORT); @@ -644,13 +576,13 @@ public MessagingProducerSpanBuilder setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ public MessagingProducerSpanBuilder setNetHostName(String netHostName) { status.set(AttributeStatus.NET_HOST_NAME); internalBuilder.setAttribute("net.host.name", netHostName); return this; } + } -} +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingProducerSynchronousSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingProducerSynchronousSemanticConvention.java index 6586be496f83..430afe76aae2 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingProducerSynchronousSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingProducerSynchronousSemanticConvention.java @@ -22,147 +22,113 @@ public interface MessagingProducerSynchronousSemanticConvention { Span getSpan(); + /** * Sets a value for messaging.system - * * @param messagingSystem A string identifying the messaging system.. */ public MessagingProducerSynchronousSemanticConvention setMessagingSystem(String messagingSystem); /** * Sets a value for messaging.destination - * - * @param messagingDestination The message destination name. This might be equal to the span name - * but is required nevertheless.. + * @param messagingDestination The message destination name. This might be equal to the span name but is required nevertheless.. */ - public MessagingProducerSynchronousSemanticConvention setMessagingDestination( - String messagingDestination); + public MessagingProducerSynchronousSemanticConvention setMessagingDestination(String messagingDestination); /** * Sets a value for messaging.destination_kind - * * @param messagingDestinationKind The kind of message destination. */ - public MessagingProducerSynchronousSemanticConvention setMessagingDestinationKind( - String messagingDestinationKind); + public MessagingProducerSynchronousSemanticConvention setMessagingDestinationKind(String messagingDestinationKind); /** * Sets a value for messaging.temp_destination - * - * @param messagingTempDestination A boolean that is true if the message destination is - * temporary.. + * @param messagingTempDestination A boolean that is true if the message destination is temporary.. */ - public MessagingProducerSynchronousSemanticConvention setMessagingTempDestination( - boolean messagingTempDestination); + public MessagingProducerSynchronousSemanticConvention setMessagingTempDestination(boolean messagingTempDestination); /** * Sets a value for messaging.protocol - * * @param messagingProtocol The name of the transport protocol.. */ - public MessagingProducerSynchronousSemanticConvention setMessagingProtocol( - String messagingProtocol); + public MessagingProducerSynchronousSemanticConvention setMessagingProtocol(String messagingProtocol); /** * Sets a value for messaging.protocol_version - * * @param messagingProtocolVersion The version of the transport protocol.. */ - public MessagingProducerSynchronousSemanticConvention setMessagingProtocolVersion( - String messagingProtocolVersion); + public MessagingProducerSynchronousSemanticConvention setMessagingProtocolVersion(String messagingProtocolVersion); /** * Sets a value for messaging.url - * * @param messagingUrl Connection string.. */ public MessagingProducerSynchronousSemanticConvention setMessagingUrl(String messagingUrl); /** * Sets a value for messaging.message_id - * - * @param messagingMessageId A value used by the messaging system as an identifier for the - * message, represented as a string.. + * @param messagingMessageId A value used by the messaging system as an identifier for the message, represented as a string.. */ - public MessagingProducerSynchronousSemanticConvention setMessagingMessageId( - String messagingMessageId); + public MessagingProducerSynchronousSemanticConvention setMessagingMessageId(String messagingMessageId); /** * Sets a value for messaging.conversation_id - * - * @param messagingConversationId A value identifying the conversation to which the message - * belongs, represented as a string. Sometimes called "Correlation ID".. + * @param messagingConversationId A value identifying the conversation to which the message belongs, represented as a string. Sometimes called "Correlation ID".. */ - public MessagingProducerSynchronousSemanticConvention setMessagingConversationId( - String messagingConversationId); + public MessagingProducerSynchronousSemanticConvention setMessagingConversationId(String messagingConversationId); /** * Sets a value for messaging.message_payload_size_bytes - * - * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in - * bytes. Also use this attribute if it is unknown whether the compressed or uncompressed - * payload size is reported.. + * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in bytes. Also use this attribute if it is unknown whether the compressed or uncompressed payload size is reported.. */ - public MessagingProducerSynchronousSemanticConvention setMessagingMessagePayloadSizeBytes( - long messagingMessagePayloadSizeBytes); + public MessagingProducerSynchronousSemanticConvention setMessagingMessagePayloadSizeBytes(long messagingMessagePayloadSizeBytes); /** * Sets a value for messaging.message_payload_compressed_size_bytes - * - * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in - * bytes.. + * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in bytes.. */ - public MessagingProducerSynchronousSemanticConvention - setMessagingMessagePayloadCompressedSizeBytes( - long messagingMessagePayloadCompressedSizeBytes); + public MessagingProducerSynchronousSemanticConvention setMessagingMessagePayloadCompressedSizeBytes(long messagingMessagePayloadCompressedSizeBytes); /** * Sets a value for net.peer.port - * * @param netPeerPort Remote port number.. */ public MessagingProducerSynchronousSemanticConvention setNetPeerPort(long netPeerPort); /** * Sets a value for net.transport - * * @param netTransport Strongly recommended for in-process queueing systems. */ public MessagingProducerSynchronousSemanticConvention setNetTransport(String netTransport); /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public MessagingProducerSynchronousSemanticConvention setNetPeerIp(String netPeerIp); /** * Sets a value for net.peer.name - * * @param netPeerName Remote hostname or similar, see note below.. */ public MessagingProducerSynchronousSemanticConvention setNetPeerName(String netPeerName); /** * Sets a value for net.host.ip - * * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. */ public MessagingProducerSynchronousSemanticConvention setNetHostIp(String netHostIp); /** * Sets a value for net.host.port - * * @param netHostPort Like `net.peer.port` but for the host port.. */ public MessagingProducerSynchronousSemanticConvention setNetHostPort(long netHostPort); /** * Sets a value for net.host.name - * * @param netHostName Local hostname or similar, see note below.. */ public MessagingProducerSynchronousSemanticConvention setNetHostName(String netHostName); -} + +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingProducerSynchronousSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingProducerSynchronousSpan.java index 6b0bf8dc4907..18a9db8655d1 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingProducerSynchronousSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingProducerSynchronousSpan.java @@ -25,8 +25,7 @@ * * * * Conditional attributes: @@ -45,8 +44,7 @@ *
  • net.peer.ip * */ -public class MessagingProducerSynchronousSpan extends DelegatingSpan - implements MessagingProducerSynchronousSemanticConvention { +public class MessagingProducerSynchronousSpan extends DelegatingSpan implements MessagingProducerSynchronousSemanticConvention { enum AttributeStatus { EMPTY, @@ -68,6 +66,7 @@ enum AttributeStatus { NET_HOST_IP, NET_HOST_PORT, NET_HOST_NAME; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -94,9 +93,7 @@ public long getValue() { } @SuppressWarnings("unused") - private static final Logger logger = - Logger.getLogger(MessagingProducerSynchronousSpan.class.getName()); - + private static final Logger logger = Logger.getLogger(MessagingProducerSynchronousSpan.class.getName()); public final AttributeStatus status; protected MessagingProducerSynchronousSpan(Span span, AttributeStatus status) { @@ -104,29 +101,24 @@ protected MessagingProducerSynchronousSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * Entry point to generate a {@link MessagingProducerSynchronousSpan}. - * - * @param tracer Tracer to use - * @param spanName Name for the {@link Span} - * @return a {@link MessagingProducerSynchronousSpan} object. - */ - public static MessagingProducerSynchronousSpanBuilder createMessagingProducerSynchronousSpan( - Tracer tracer, String spanName) { - return new MessagingProducerSynchronousSpanBuilder(tracer, spanName).setKind(Kind.CLIENT); + /** + * Entry point to generate a {@link MessagingProducerSynchronousSpan}. + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link MessagingProducerSynchronousSpan} object. + */ + public static MessagingProducerSynchronousSpanBuilder createMessagingProducerSynchronousSpanBuilder(Tracer tracer, String spanName) { + return new MessagingProducerSynchronousSpanBuilder(tracer, spanName).setKind(Span.Kind.CLIENT); } /** - * Creates a {@link MessagingProducerSynchronousSpan} from a {@link MessagingSpan}. - * - * @param builder {@link MessagingSpan.MessagingSpanBuilder} to use. - * @return a {@link MessagingProducerSynchronousSpan} object built from a {@link MessagingSpan}. - */ - public static MessagingProducerSynchronousSpanBuilder createMessagingProducerSynchronousSpan( - MessagingSpan.MessagingSpanBuilder builder) { - // we accept a builder from Messaging since MessagingProducerSynchronous "extends" Messaging - return new MessagingProducerSynchronousSpanBuilder( - builder.getSpanBuilder(), builder.status.getValue()); + * Creates a {@link MessagingProducerSynchronousSpan} from a {@link MessagingSpan}. + * @param builder {@link MessagingSpan.MessagingSpanBuilder} to use. + * @return a {@link MessagingProducerSynchronousSpan} object built from a {@link MessagingSpan}. + */ + public static MessagingProducerSynchronousSpanBuilder createMessagingProducerSynchronousSpanBuilder(MessagingSpan.MessagingSpanBuilder builder) { + // we accept a builder from Messaging since MessagingProducerSynchronous "extends" Messaging + return new MessagingProducerSynchronousSpanBuilder(builder.getSpanBuilder(), builder.status.getValue()); } /** @return the Span used internally */ @@ -151,8 +143,8 @@ public void end() { // extra constraints. { boolean flag = - (!this.status.isSet(AttributeStatus.NET_PEER_NAME)) - || (!this.status.isSet(AttributeStatus.NET_PEER_IP)); + (!this.status.isSet(AttributeStatus.NET_PEER_NAME) ) || + (!this.status.isSet(AttributeStatus.NET_PEER_IP) ) ; if (flag) { logger.info("Constraint not respected!"); } @@ -166,10 +158,10 @@ public void end() { } } + /** * Sets messaging.system. - * - * @param messagingSystem A string identifying the messaging system.. + * @param messagingSystem A string identifying the messaging system. */ @Override public MessagingProducerSynchronousSemanticConvention setMessagingSystem(String messagingSystem) { @@ -180,13 +172,10 @@ public MessagingProducerSynchronousSemanticConvention setMessagingSystem(String /** * Sets messaging.destination. - * - * @param messagingDestination The message destination name. This might be equal to the span name - * but is required nevertheless.. + * @param messagingDestination The message destination name. This might be equal to the span name but is required nevertheless. */ @Override - public MessagingProducerSynchronousSemanticConvention setMessagingDestination( - String messagingDestination) { + public MessagingProducerSynchronousSemanticConvention setMessagingDestination(String messagingDestination) { status.set(AttributeStatus.MESSAGING_DESTINATION); delegate.setAttribute("messaging.destination", messagingDestination); return this; @@ -194,12 +183,10 @@ public MessagingProducerSynchronousSemanticConvention setMessagingDestination( /** * Sets messaging.destination_kind. - * * @param messagingDestinationKind The kind of message destination. */ @Override - public MessagingProducerSynchronousSemanticConvention setMessagingDestinationKind( - String messagingDestinationKind) { + public MessagingProducerSynchronousSemanticConvention setMessagingDestinationKind(String messagingDestinationKind) { status.set(AttributeStatus.MESSAGING_DESTINATION_KIND); delegate.setAttribute("messaging.destination_kind", messagingDestinationKind); return this; @@ -207,13 +194,10 @@ public MessagingProducerSynchronousSemanticConvention setMessagingDestinationKin /** * Sets messaging.temp_destination. - * - * @param messagingTempDestination A boolean that is true if the message destination is - * temporary.. + * @param messagingTempDestination A boolean that is true if the message destination is temporary. */ @Override - public MessagingProducerSynchronousSemanticConvention setMessagingTempDestination( - boolean messagingTempDestination) { + public MessagingProducerSynchronousSemanticConvention setMessagingTempDestination(boolean messagingTempDestination) { status.set(AttributeStatus.MESSAGING_TEMP_DESTINATION); delegate.setAttribute("messaging.temp_destination", messagingTempDestination); return this; @@ -221,12 +205,10 @@ public MessagingProducerSynchronousSemanticConvention setMessagingTempDestinatio /** * Sets messaging.protocol. - * - * @param messagingProtocol The name of the transport protocol.. + * @param messagingProtocol The name of the transport protocol. */ @Override - public MessagingProducerSynchronousSemanticConvention setMessagingProtocol( - String messagingProtocol) { + public MessagingProducerSynchronousSemanticConvention setMessagingProtocol(String messagingProtocol) { status.set(AttributeStatus.MESSAGING_PROTOCOL); delegate.setAttribute("messaging.protocol", messagingProtocol); return this; @@ -234,12 +216,10 @@ public MessagingProducerSynchronousSemanticConvention setMessagingProtocol( /** * Sets messaging.protocol_version. - * - * @param messagingProtocolVersion The version of the transport protocol.. + * @param messagingProtocolVersion The version of the transport protocol. */ @Override - public MessagingProducerSynchronousSemanticConvention setMessagingProtocolVersion( - String messagingProtocolVersion) { + public MessagingProducerSynchronousSemanticConvention setMessagingProtocolVersion(String messagingProtocolVersion) { status.set(AttributeStatus.MESSAGING_PROTOCOL_VERSION); delegate.setAttribute("messaging.protocol_version", messagingProtocolVersion); return this; @@ -247,8 +227,7 @@ public MessagingProducerSynchronousSemanticConvention setMessagingProtocolVersio /** * Sets messaging.url. - * - * @param messagingUrl Connection string.. + * @param messagingUrl Connection string. */ @Override public MessagingProducerSynchronousSemanticConvention setMessagingUrl(String messagingUrl) { @@ -259,13 +238,10 @@ public MessagingProducerSynchronousSemanticConvention setMessagingUrl(String mes /** * Sets messaging.message_id. - * - * @param messagingMessageId A value used by the messaging system as an identifier for the - * message, represented as a string.. + * @param messagingMessageId A value used by the messaging system as an identifier for the message, represented as a string. */ @Override - public MessagingProducerSynchronousSemanticConvention setMessagingMessageId( - String messagingMessageId) { + public MessagingProducerSynchronousSemanticConvention setMessagingMessageId(String messagingMessageId) { status.set(AttributeStatus.MESSAGING_MESSAGE_ID); delegate.setAttribute("messaging.message_id", messagingMessageId); return this; @@ -273,13 +249,10 @@ public MessagingProducerSynchronousSemanticConvention setMessagingMessageId( /** * Sets messaging.conversation_id. - * - * @param messagingConversationId A value identifying the conversation to which the message - * belongs, represented as a string. Sometimes called "Correlation ID".. + * @param messagingConversationId A value identifying the conversation to which the message belongs, represented as a string. Sometimes called "Correlation ID". */ @Override - public MessagingProducerSynchronousSemanticConvention setMessagingConversationId( - String messagingConversationId) { + public MessagingProducerSynchronousSemanticConvention setMessagingConversationId(String messagingConversationId) { status.set(AttributeStatus.MESSAGING_CONVERSATION_ID); delegate.setAttribute("messaging.conversation_id", messagingConversationId); return this; @@ -287,14 +260,10 @@ public MessagingProducerSynchronousSemanticConvention setMessagingConversationId /** * Sets messaging.message_payload_size_bytes. - * - * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in - * bytes. Also use this attribute if it is unknown whether the compressed or uncompressed - * payload size is reported.. + * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in bytes. Also use this attribute if it is unknown whether the compressed or uncompressed payload size is reported. */ @Override - public MessagingProducerSynchronousSemanticConvention setMessagingMessagePayloadSizeBytes( - long messagingMessagePayloadSizeBytes) { + public MessagingProducerSynchronousSemanticConvention setMessagingMessagePayloadSizeBytes(long messagingMessagePayloadSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES); delegate.setAttribute("messaging.message_payload_size_bytes", messagingMessagePayloadSizeBytes); return this; @@ -302,25 +271,18 @@ public MessagingProducerSynchronousSemanticConvention setMessagingMessagePayload /** * Sets messaging.message_payload_compressed_size_bytes. - * - * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in - * bytes.. + * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in bytes. */ @Override - public MessagingProducerSynchronousSemanticConvention - setMessagingMessagePayloadCompressedSizeBytes( - long messagingMessagePayloadCompressedSizeBytes) { + public MessagingProducerSynchronousSemanticConvention setMessagingMessagePayloadCompressedSizeBytes(long messagingMessagePayloadCompressedSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_COMPRESSED_SIZE_BYTES); - delegate.setAttribute( - "messaging.message_payload_compressed_size_bytes", - messagingMessagePayloadCompressedSizeBytes); + delegate.setAttribute("messaging.message_payload_compressed_size_bytes", messagingMessagePayloadCompressedSizeBytes); return this; } /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ @Override public MessagingProducerSynchronousSemanticConvention setNetPeerPort(long netPeerPort) { @@ -331,7 +293,6 @@ public MessagingProducerSynchronousSemanticConvention setNetPeerPort(long netPee /** * Sets net.transport. - * * @param netTransport Strongly recommended for in-process queueing systems. */ @Override @@ -343,9 +304,7 @@ public MessagingProducerSynchronousSemanticConvention setNetTransport(String net /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ @Override public MessagingProducerSynchronousSemanticConvention setNetPeerIp(String netPeerIp) { @@ -356,8 +315,7 @@ public MessagingProducerSynchronousSemanticConvention setNetPeerIp(String netPee /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ @Override public MessagingProducerSynchronousSemanticConvention setNetPeerName(String netPeerName) { @@ -368,8 +326,7 @@ public MessagingProducerSynchronousSemanticConvention setNetPeerName(String netP /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ @Override public MessagingProducerSynchronousSemanticConvention setNetHostIp(String netHostIp) { @@ -380,8 +337,7 @@ public MessagingProducerSynchronousSemanticConvention setNetHostIp(String netHos /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ @Override public MessagingProducerSynchronousSemanticConvention setNetHostPort(long netHostPort) { @@ -392,8 +348,7 @@ public MessagingProducerSynchronousSemanticConvention setNetHostPort(long netHos /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ @Override public MessagingProducerSynchronousSemanticConvention setNetHostName(String netHostName) { @@ -402,39 +357,42 @@ public MessagingProducerSynchronousSemanticConvention setNetHostName(String netH return this; } - /** Builder class for {@link MessagingProducerSynchronousSpan}. */ - public static class MessagingProducerSynchronousSpanBuilder { + + /** + * Builder class for {@link MessagingProducerSynchronousSpan}. + */ + public static class MessagingProducerSynchronousSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected MessagingProducerSynchronousSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public MessagingProducerSynchronousSpanBuilder(Builder spanBuilder, long attributes) { + public MessagingProducerSynchronousSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public MessagingProducerSynchronousSpanBuilder setParent(Span parent) { + public MessagingProducerSynchronousSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public MessagingProducerSynchronousSpanBuilder setParent(SpanContext remoteParent) { + public MessagingProducerSynchronousSpanBuilder 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 MessagingProducerSynchronousSpanBuilder setKind(Kind kind) { + public MessagingProducerSynchronousSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -445,10 +403,10 @@ public MessagingProducerSynchronousSpan start() { return new MessagingProducerSynchronousSpan(this.internalBuilder.startSpan(), status); } + /** * Sets messaging.system. - * - * @param messagingSystem A string identifying the messaging system.. + * @param messagingSystem A string identifying the messaging system. */ public MessagingProducerSynchronousSpanBuilder setMessagingSystem(String messagingSystem) { status.set(AttributeStatus.MESSAGING_SYSTEM); @@ -458,12 +416,9 @@ public MessagingProducerSynchronousSpanBuilder setMessagingSystem(String messagi /** * Sets messaging.destination. - * - * @param messagingDestination The message destination name. This might be equal to the span - * name but is required nevertheless.. + * @param messagingDestination The message destination name. This might be equal to the span name but is required nevertheless. */ - public MessagingProducerSynchronousSpanBuilder setMessagingDestination( - String messagingDestination) { + public MessagingProducerSynchronousSpanBuilder setMessagingDestination(String messagingDestination) { status.set(AttributeStatus.MESSAGING_DESTINATION); internalBuilder.setAttribute("messaging.destination", messagingDestination); return this; @@ -471,11 +426,9 @@ public MessagingProducerSynchronousSpanBuilder setMessagingDestination( /** * Sets messaging.destination_kind. - * * @param messagingDestinationKind The kind of message destination. */ - public MessagingProducerSynchronousSpanBuilder setMessagingDestinationKind( - String messagingDestinationKind) { + public MessagingProducerSynchronousSpanBuilder setMessagingDestinationKind(String messagingDestinationKind) { status.set(AttributeStatus.MESSAGING_DESTINATION_KIND); internalBuilder.setAttribute("messaging.destination_kind", messagingDestinationKind); return this; @@ -483,12 +436,9 @@ public MessagingProducerSynchronousSpanBuilder setMessagingDestinationKind( /** * Sets messaging.temp_destination. - * - * @param messagingTempDestination A boolean that is true if the message destination is - * temporary.. + * @param messagingTempDestination A boolean that is true if the message destination is temporary. */ - public MessagingProducerSynchronousSpanBuilder setMessagingTempDestination( - boolean messagingTempDestination) { + public MessagingProducerSynchronousSpanBuilder setMessagingTempDestination(boolean messagingTempDestination) { status.set(AttributeStatus.MESSAGING_TEMP_DESTINATION); internalBuilder.setAttribute("messaging.temp_destination", messagingTempDestination); return this; @@ -496,8 +446,7 @@ public MessagingProducerSynchronousSpanBuilder setMessagingTempDestination( /** * Sets messaging.protocol. - * - * @param messagingProtocol The name of the transport protocol.. + * @param messagingProtocol The name of the transport protocol. */ public MessagingProducerSynchronousSpanBuilder setMessagingProtocol(String messagingProtocol) { status.set(AttributeStatus.MESSAGING_PROTOCOL); @@ -507,11 +456,9 @@ public MessagingProducerSynchronousSpanBuilder setMessagingProtocol(String messa /** * Sets messaging.protocol_version. - * - * @param messagingProtocolVersion The version of the transport protocol.. + * @param messagingProtocolVersion The version of the transport protocol. */ - public MessagingProducerSynchronousSpanBuilder setMessagingProtocolVersion( - String messagingProtocolVersion) { + public MessagingProducerSynchronousSpanBuilder setMessagingProtocolVersion(String messagingProtocolVersion) { status.set(AttributeStatus.MESSAGING_PROTOCOL_VERSION); internalBuilder.setAttribute("messaging.protocol_version", messagingProtocolVersion); return this; @@ -519,8 +466,7 @@ public MessagingProducerSynchronousSpanBuilder setMessagingProtocolVersion( /** * Sets messaging.url. - * - * @param messagingUrl Connection string.. + * @param messagingUrl Connection string. */ public MessagingProducerSynchronousSpanBuilder setMessagingUrl(String messagingUrl) { status.set(AttributeStatus.MESSAGING_URL); @@ -530,12 +476,9 @@ public MessagingProducerSynchronousSpanBuilder setMessagingUrl(String messagingU /** * Sets messaging.message_id. - * - * @param messagingMessageId A value used by the messaging system as an identifier for the - * message, represented as a string.. + * @param messagingMessageId A value used by the messaging system as an identifier for the message, represented as a string. */ - public MessagingProducerSynchronousSpanBuilder setMessagingMessageId( - String messagingMessageId) { + public MessagingProducerSynchronousSpanBuilder setMessagingMessageId(String messagingMessageId) { status.set(AttributeStatus.MESSAGING_MESSAGE_ID); internalBuilder.setAttribute("messaging.message_id", messagingMessageId); return this; @@ -543,12 +486,9 @@ public MessagingProducerSynchronousSpanBuilder setMessagingMessageId( /** * Sets messaging.conversation_id. - * - * @param messagingConversationId A value identifying the conversation to which the message - * belongs, represented as a string. Sometimes called "Correlation ID".. + * @param messagingConversationId A value identifying the conversation to which the message belongs, represented as a string. Sometimes called "Correlation ID". */ - public MessagingProducerSynchronousSpanBuilder setMessagingConversationId( - String messagingConversationId) { + public MessagingProducerSynchronousSpanBuilder setMessagingConversationId(String messagingConversationId) { status.set(AttributeStatus.MESSAGING_CONVERSATION_ID); internalBuilder.setAttribute("messaging.conversation_id", messagingConversationId); return this; @@ -556,38 +496,27 @@ public MessagingProducerSynchronousSpanBuilder setMessagingConversationId( /** * Sets messaging.message_payload_size_bytes. - * - * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in - * bytes. Also use this attribute if it is unknown whether the compressed or uncompressed - * payload size is reported.. + * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in bytes. Also use this attribute if it is unknown whether the compressed or uncompressed payload size is reported. */ - public MessagingProducerSynchronousSpanBuilder setMessagingMessagePayloadSizeBytes( - long messagingMessagePayloadSizeBytes) { + public MessagingProducerSynchronousSpanBuilder setMessagingMessagePayloadSizeBytes(long messagingMessagePayloadSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES); - internalBuilder.setAttribute( - "messaging.message_payload_size_bytes", messagingMessagePayloadSizeBytes); + internalBuilder.setAttribute("messaging.message_payload_size_bytes", messagingMessagePayloadSizeBytes); return this; } /** * Sets messaging.message_payload_compressed_size_bytes. - * - * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload - * in bytes.. + * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in bytes. */ - public MessagingProducerSynchronousSpanBuilder setMessagingMessagePayloadCompressedSizeBytes( - long messagingMessagePayloadCompressedSizeBytes) { + public MessagingProducerSynchronousSpanBuilder setMessagingMessagePayloadCompressedSizeBytes(long messagingMessagePayloadCompressedSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_COMPRESSED_SIZE_BYTES); - internalBuilder.setAttribute( - "messaging.message_payload_compressed_size_bytes", - messagingMessagePayloadCompressedSizeBytes); + internalBuilder.setAttribute("messaging.message_payload_compressed_size_bytes", messagingMessagePayloadCompressedSizeBytes); return this; } /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ public MessagingProducerSynchronousSpanBuilder setNetPeerPort(long netPeerPort) { status.set(AttributeStatus.NET_PEER_PORT); @@ -597,7 +526,6 @@ public MessagingProducerSynchronousSpanBuilder setNetPeerPort(long netPeerPort) /** * Sets net.transport. - * * @param netTransport Strongly recommended for in-process queueing systems. */ public MessagingProducerSynchronousSpanBuilder setNetTransport(String netTransport) { @@ -608,9 +536,7 @@ public MessagingProducerSynchronousSpanBuilder setNetTransport(String netTranspo /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public MessagingProducerSynchronousSpanBuilder setNetPeerIp(String netPeerIp) { status.set(AttributeStatus.NET_PEER_IP); @@ -620,8 +546,7 @@ public MessagingProducerSynchronousSpanBuilder setNetPeerIp(String netPeerIp) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ public MessagingProducerSynchronousSpanBuilder setNetPeerName(String netPeerName) { status.set(AttributeStatus.NET_PEER_NAME); @@ -631,8 +556,7 @@ public MessagingProducerSynchronousSpanBuilder setNetPeerName(String netPeerName /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ public MessagingProducerSynchronousSpanBuilder setNetHostIp(String netHostIp) { status.set(AttributeStatus.NET_HOST_IP); @@ -642,8 +566,7 @@ public MessagingProducerSynchronousSpanBuilder setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ public MessagingProducerSynchronousSpanBuilder setNetHostPort(long netHostPort) { status.set(AttributeStatus.NET_HOST_PORT); @@ -653,13 +576,13 @@ public MessagingProducerSynchronousSpanBuilder setNetHostPort(long netHostPort) /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ public MessagingProducerSynchronousSpanBuilder setNetHostName(String netHostName) { status.set(AttributeStatus.NET_HOST_NAME); internalBuilder.setAttribute("net.host.name", netHostName); return this; } + } -} +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingSemanticConvention.java index b58bc18b2732..c5340a0d5e2a 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingSemanticConvention.java @@ -22,139 +22,113 @@ public interface MessagingSemanticConvention { Span getSpan(); + /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public MessagingSemanticConvention setNetPeerIp(String netPeerIp); /** * Sets a value for net.peer.name - * * @param netPeerName Remote hostname or similar, see note below.. */ public MessagingSemanticConvention setNetPeerName(String netPeerName); /** * Sets a value for net.host.ip - * * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. */ public MessagingSemanticConvention setNetHostIp(String netHostIp); /** * Sets a value for net.host.port - * * @param netHostPort Like `net.peer.port` but for the host port.. */ public MessagingSemanticConvention setNetHostPort(long netHostPort); /** * Sets a value for net.host.name - * * @param netHostName Local hostname or similar, see note below.. */ public MessagingSemanticConvention setNetHostName(String netHostName); /** * Sets a value for messaging.system - * * @param messagingSystem A string identifying the messaging system.. */ public MessagingSemanticConvention setMessagingSystem(String messagingSystem); /** * Sets a value for messaging.destination - * - * @param messagingDestination The message destination name. This might be equal to the span name - * but is required nevertheless.. + * @param messagingDestination The message destination name. This might be equal to the span name but is required nevertheless.. */ public MessagingSemanticConvention setMessagingDestination(String messagingDestination); /** * Sets a value for messaging.destination_kind - * * @param messagingDestinationKind The kind of message destination. */ public MessagingSemanticConvention setMessagingDestinationKind(String messagingDestinationKind); /** * Sets a value for messaging.temp_destination - * - * @param messagingTempDestination A boolean that is true if the message destination is - * temporary.. + * @param messagingTempDestination A boolean that is true if the message destination is temporary.. */ public MessagingSemanticConvention setMessagingTempDestination(boolean messagingTempDestination); /** * Sets a value for messaging.protocol - * * @param messagingProtocol The name of the transport protocol.. */ public MessagingSemanticConvention setMessagingProtocol(String messagingProtocol); /** * Sets a value for messaging.protocol_version - * * @param messagingProtocolVersion The version of the transport protocol.. */ public MessagingSemanticConvention setMessagingProtocolVersion(String messagingProtocolVersion); /** * Sets a value for messaging.url - * * @param messagingUrl Connection string.. */ public MessagingSemanticConvention setMessagingUrl(String messagingUrl); /** * Sets a value for messaging.message_id - * - * @param messagingMessageId A value used by the messaging system as an identifier for the - * message, represented as a string.. + * @param messagingMessageId A value used by the messaging system as an identifier for the message, represented as a string.. */ public MessagingSemanticConvention setMessagingMessageId(String messagingMessageId); /** * Sets a value for messaging.conversation_id - * - * @param messagingConversationId A value identifying the conversation to which the message - * belongs, represented as a string. Sometimes called "Correlation ID".. + * @param messagingConversationId A value identifying the conversation to which the message belongs, represented as a string. Sometimes called "Correlation ID".. */ public MessagingSemanticConvention setMessagingConversationId(String messagingConversationId); /** * Sets a value for messaging.message_payload_size_bytes - * - * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in - * bytes. Also use this attribute if it is unknown whether the compressed or uncompressed - * payload size is reported.. + * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in bytes. Also use this attribute if it is unknown whether the compressed or uncompressed payload size is reported.. */ - public MessagingSemanticConvention setMessagingMessagePayloadSizeBytes( - long messagingMessagePayloadSizeBytes); + public MessagingSemanticConvention setMessagingMessagePayloadSizeBytes(long messagingMessagePayloadSizeBytes); /** * Sets a value for messaging.message_payload_compressed_size_bytes - * - * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in - * bytes.. + * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in bytes.. */ - public MessagingSemanticConvention setMessagingMessagePayloadCompressedSizeBytes( - long messagingMessagePayloadCompressedSizeBytes); + public MessagingSemanticConvention setMessagingMessagePayloadCompressedSizeBytes(long messagingMessagePayloadCompressedSizeBytes); /** * Sets a value for net.peer.port - * * @param netPeerPort Remote port number.. */ public MessagingSemanticConvention setNetPeerPort(long netPeerPort); /** * Sets a value for net.transport - * * @param netTransport Strongly recommended for in-process queueing systems. */ public MessagingSemanticConvention setNetTransport(String netTransport); -} + +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingSpan.java index 641caeca6588..020b6e6f3dca 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/MessagingSpan.java @@ -25,8 +25,7 @@ * * * * Conditional attributes: @@ -67,6 +66,7 @@ enum AttributeStatus { MESSAGING_MESSAGE_PAYLOAD_COMPRESSED_SIZE_BYTES, NET_PEER_PORT, NET_TRANSPORT; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -94,7 +94,6 @@ public long getValue() { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(MessagingSpan.class.getName()); - public final AttributeStatus status; protected MessagingSpan(Span span, AttributeStatus status) { @@ -102,17 +101,18 @@ protected MessagingSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * Entry point to generate a {@link MessagingSpan}. - * - * @param tracer Tracer to use - * @param spanName Name for the {@link Span} - * @return a {@link MessagingSpan} object. - */ - public static MessagingSpanBuilder createMessagingSpan(Tracer tracer, String spanName) { + /** + * Entry point to generate a {@link MessagingSpan}. + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link MessagingSpan} object. + */ + public static MessagingSpanBuilder createMessagingSpanBuilder(Tracer tracer, String spanName) { return new MessagingSpanBuilder(tracer, spanName); } + + /** @return the Span used internally */ @Override public Span getSpan() { @@ -135,8 +135,8 @@ public void end() { // extra constraints. { boolean flag = - (!this.status.isSet(AttributeStatus.NET_PEER_NAME)) - || (!this.status.isSet(AttributeStatus.NET_PEER_IP)); + (!this.status.isSet(AttributeStatus.NET_PEER_NAME) ) || + (!this.status.isSet(AttributeStatus.NET_PEER_IP) ) ; if (flag) { logger.info("Constraint not respected!"); } @@ -150,11 +150,10 @@ public void end() { } } + /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ @Override public MessagingSemanticConvention setNetPeerIp(String netPeerIp) { @@ -165,8 +164,7 @@ public MessagingSemanticConvention setNetPeerIp(String netPeerIp) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ @Override public MessagingSemanticConvention setNetPeerName(String netPeerName) { @@ -177,8 +175,7 @@ public MessagingSemanticConvention setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ @Override public MessagingSemanticConvention setNetHostIp(String netHostIp) { @@ -189,8 +186,7 @@ public MessagingSemanticConvention setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ @Override public MessagingSemanticConvention setNetHostPort(long netHostPort) { @@ -201,8 +197,7 @@ public MessagingSemanticConvention setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ @Override public MessagingSemanticConvention setNetHostName(String netHostName) { @@ -213,8 +208,7 @@ public MessagingSemanticConvention setNetHostName(String netHostName) { /** * Sets messaging.system. - * - * @param messagingSystem A string identifying the messaging system.. + * @param messagingSystem A string identifying the messaging system. */ @Override public MessagingSemanticConvention setMessagingSystem(String messagingSystem) { @@ -225,9 +219,7 @@ public MessagingSemanticConvention setMessagingSystem(String messagingSystem) { /** * Sets messaging.destination. - * - * @param messagingDestination The message destination name. This might be equal to the span name - * but is required nevertheless.. + * @param messagingDestination The message destination name. This might be equal to the span name but is required nevertheless. */ @Override public MessagingSemanticConvention setMessagingDestination(String messagingDestination) { @@ -238,7 +230,6 @@ public MessagingSemanticConvention setMessagingDestination(String messagingDesti /** * Sets messaging.destination_kind. - * * @param messagingDestinationKind The kind of message destination. */ @Override @@ -250,9 +241,7 @@ public MessagingSemanticConvention setMessagingDestinationKind(String messagingD /** * Sets messaging.temp_destination. - * - * @param messagingTempDestination A boolean that is true if the message destination is - * temporary.. + * @param messagingTempDestination A boolean that is true if the message destination is temporary. */ @Override public MessagingSemanticConvention setMessagingTempDestination(boolean messagingTempDestination) { @@ -263,8 +252,7 @@ public MessagingSemanticConvention setMessagingTempDestination(boolean messaging /** * Sets messaging.protocol. - * - * @param messagingProtocol The name of the transport protocol.. + * @param messagingProtocol The name of the transport protocol. */ @Override public MessagingSemanticConvention setMessagingProtocol(String messagingProtocol) { @@ -275,8 +263,7 @@ public MessagingSemanticConvention setMessagingProtocol(String messagingProtocol /** * Sets messaging.protocol_version. - * - * @param messagingProtocolVersion The version of the transport protocol.. + * @param messagingProtocolVersion The version of the transport protocol. */ @Override public MessagingSemanticConvention setMessagingProtocolVersion(String messagingProtocolVersion) { @@ -287,8 +274,7 @@ public MessagingSemanticConvention setMessagingProtocolVersion(String messagingP /** * Sets messaging.url. - * - * @param messagingUrl Connection string.. + * @param messagingUrl Connection string. */ @Override public MessagingSemanticConvention setMessagingUrl(String messagingUrl) { @@ -299,9 +285,7 @@ public MessagingSemanticConvention setMessagingUrl(String messagingUrl) { /** * Sets messaging.message_id. - * - * @param messagingMessageId A value used by the messaging system as an identifier for the - * message, represented as a string.. + * @param messagingMessageId A value used by the messaging system as an identifier for the message, represented as a string. */ @Override public MessagingSemanticConvention setMessagingMessageId(String messagingMessageId) { @@ -312,9 +296,7 @@ public MessagingSemanticConvention setMessagingMessageId(String messagingMessage /** * Sets messaging.conversation_id. - * - * @param messagingConversationId A value identifying the conversation to which the message - * belongs, represented as a string. Sometimes called "Correlation ID".. + * @param messagingConversationId A value identifying the conversation to which the message belongs, represented as a string. Sometimes called "Correlation ID". */ @Override public MessagingSemanticConvention setMessagingConversationId(String messagingConversationId) { @@ -325,14 +307,10 @@ public MessagingSemanticConvention setMessagingConversationId(String messagingCo /** * Sets messaging.message_payload_size_bytes. - * - * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in - * bytes. Also use this attribute if it is unknown whether the compressed or uncompressed - * payload size is reported.. + * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in bytes. Also use this attribute if it is unknown whether the compressed or uncompressed payload size is reported. */ @Override - public MessagingSemanticConvention setMessagingMessagePayloadSizeBytes( - long messagingMessagePayloadSizeBytes) { + public MessagingSemanticConvention setMessagingMessagePayloadSizeBytes(long messagingMessagePayloadSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES); delegate.setAttribute("messaging.message_payload_size_bytes", messagingMessagePayloadSizeBytes); return this; @@ -340,24 +318,18 @@ public MessagingSemanticConvention setMessagingMessagePayloadSizeBytes( /** * Sets messaging.message_payload_compressed_size_bytes. - * - * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in - * bytes.. + * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in bytes. */ @Override - public MessagingSemanticConvention setMessagingMessagePayloadCompressedSizeBytes( - long messagingMessagePayloadCompressedSizeBytes) { + public MessagingSemanticConvention setMessagingMessagePayloadCompressedSizeBytes(long messagingMessagePayloadCompressedSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_COMPRESSED_SIZE_BYTES); - delegate.setAttribute( - "messaging.message_payload_compressed_size_bytes", - messagingMessagePayloadCompressedSizeBytes); + delegate.setAttribute("messaging.message_payload_compressed_size_bytes", messagingMessagePayloadCompressedSizeBytes); return this; } /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ @Override public MessagingSemanticConvention setNetPeerPort(long netPeerPort) { @@ -368,7 +340,6 @@ public MessagingSemanticConvention setNetPeerPort(long netPeerPort) { /** * Sets net.transport. - * * @param netTransport Strongly recommended for in-process queueing systems. */ @Override @@ -378,39 +349,42 @@ public MessagingSemanticConvention setNetTransport(String netTransport) { return this; } - /** Builder class for {@link MessagingSpan}. */ - public static class MessagingSpanBuilder { + + /** + * Builder class for {@link MessagingSpan}. + */ + public static class MessagingSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected MessagingSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public MessagingSpanBuilder(Builder spanBuilder, long attributes) { + public MessagingSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public MessagingSpanBuilder setParent(Span parent) { + public MessagingSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public MessagingSpanBuilder setParent(SpanContext remoteParent) { + public MessagingSpanBuilder 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 MessagingSpanBuilder setKind(Kind kind) { + public MessagingSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -421,11 +395,10 @@ public MessagingSpan start() { return new MessagingSpan(this.internalBuilder.startSpan(), status); } + /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public MessagingSpanBuilder setNetPeerIp(String netPeerIp) { status.set(AttributeStatus.NET_PEER_IP); @@ -435,8 +408,7 @@ public MessagingSpanBuilder setNetPeerIp(String netPeerIp) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ public MessagingSpanBuilder setNetPeerName(String netPeerName) { status.set(AttributeStatus.NET_PEER_NAME); @@ -446,8 +418,7 @@ public MessagingSpanBuilder setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ public MessagingSpanBuilder setNetHostIp(String netHostIp) { status.set(AttributeStatus.NET_HOST_IP); @@ -457,8 +428,7 @@ public MessagingSpanBuilder setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ public MessagingSpanBuilder setNetHostPort(long netHostPort) { status.set(AttributeStatus.NET_HOST_PORT); @@ -468,8 +438,7 @@ public MessagingSpanBuilder setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ public MessagingSpanBuilder setNetHostName(String netHostName) { status.set(AttributeStatus.NET_HOST_NAME); @@ -479,8 +448,7 @@ public MessagingSpanBuilder setNetHostName(String netHostName) { /** * Sets messaging.system. - * - * @param messagingSystem A string identifying the messaging system.. + * @param messagingSystem A string identifying the messaging system. */ public MessagingSpanBuilder setMessagingSystem(String messagingSystem) { status.set(AttributeStatus.MESSAGING_SYSTEM); @@ -490,9 +458,7 @@ public MessagingSpanBuilder setMessagingSystem(String messagingSystem) { /** * Sets messaging.destination. - * - * @param messagingDestination The message destination name. This might be equal to the span - * name but is required nevertheless.. + * @param messagingDestination The message destination name. This might be equal to the span name but is required nevertheless. */ public MessagingSpanBuilder setMessagingDestination(String messagingDestination) { status.set(AttributeStatus.MESSAGING_DESTINATION); @@ -502,7 +468,6 @@ public MessagingSpanBuilder setMessagingDestination(String messagingDestination) /** * Sets messaging.destination_kind. - * * @param messagingDestinationKind The kind of message destination. */ public MessagingSpanBuilder setMessagingDestinationKind(String messagingDestinationKind) { @@ -513,9 +478,7 @@ public MessagingSpanBuilder setMessagingDestinationKind(String messagingDestinat /** * Sets messaging.temp_destination. - * - * @param messagingTempDestination A boolean that is true if the message destination is - * temporary.. + * @param messagingTempDestination A boolean that is true if the message destination is temporary. */ public MessagingSpanBuilder setMessagingTempDestination(boolean messagingTempDestination) { status.set(AttributeStatus.MESSAGING_TEMP_DESTINATION); @@ -525,8 +488,7 @@ public MessagingSpanBuilder setMessagingTempDestination(boolean messagingTempDes /** * Sets messaging.protocol. - * - * @param messagingProtocol The name of the transport protocol.. + * @param messagingProtocol The name of the transport protocol. */ public MessagingSpanBuilder setMessagingProtocol(String messagingProtocol) { status.set(AttributeStatus.MESSAGING_PROTOCOL); @@ -536,8 +498,7 @@ public MessagingSpanBuilder setMessagingProtocol(String messagingProtocol) { /** * Sets messaging.protocol_version. - * - * @param messagingProtocolVersion The version of the transport protocol.. + * @param messagingProtocolVersion The version of the transport protocol. */ public MessagingSpanBuilder setMessagingProtocolVersion(String messagingProtocolVersion) { status.set(AttributeStatus.MESSAGING_PROTOCOL_VERSION); @@ -547,8 +508,7 @@ public MessagingSpanBuilder setMessagingProtocolVersion(String messagingProtocol /** * Sets messaging.url. - * - * @param messagingUrl Connection string.. + * @param messagingUrl Connection string. */ public MessagingSpanBuilder setMessagingUrl(String messagingUrl) { status.set(AttributeStatus.MESSAGING_URL); @@ -558,9 +518,7 @@ public MessagingSpanBuilder setMessagingUrl(String messagingUrl) { /** * Sets messaging.message_id. - * - * @param messagingMessageId A value used by the messaging system as an identifier for the - * message, represented as a string.. + * @param messagingMessageId A value used by the messaging system as an identifier for the message, represented as a string. */ public MessagingSpanBuilder setMessagingMessageId(String messagingMessageId) { status.set(AttributeStatus.MESSAGING_MESSAGE_ID); @@ -570,9 +528,7 @@ public MessagingSpanBuilder setMessagingMessageId(String messagingMessageId) { /** * Sets messaging.conversation_id. - * - * @param messagingConversationId A value identifying the conversation to which the message - * belongs, represented as a string. Sometimes called "Correlation ID".. + * @param messagingConversationId A value identifying the conversation to which the message belongs, represented as a string. Sometimes called "Correlation ID". */ public MessagingSpanBuilder setMessagingConversationId(String messagingConversationId) { status.set(AttributeStatus.MESSAGING_CONVERSATION_ID); @@ -582,38 +538,27 @@ public MessagingSpanBuilder setMessagingConversationId(String messagingConversat /** * Sets messaging.message_payload_size_bytes. - * - * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in - * bytes. Also use this attribute if it is unknown whether the compressed or uncompressed - * payload size is reported.. + * @param messagingMessagePayloadSizeBytes The (uncompressed) size of the message payload in bytes. Also use this attribute if it is unknown whether the compressed or uncompressed payload size is reported. */ - public MessagingSpanBuilder setMessagingMessagePayloadSizeBytes( - long messagingMessagePayloadSizeBytes) { + public MessagingSpanBuilder setMessagingMessagePayloadSizeBytes(long messagingMessagePayloadSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES); - internalBuilder.setAttribute( - "messaging.message_payload_size_bytes", messagingMessagePayloadSizeBytes); + internalBuilder.setAttribute("messaging.message_payload_size_bytes", messagingMessagePayloadSizeBytes); return this; } /** * Sets messaging.message_payload_compressed_size_bytes. - * - * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload - * in bytes.. + * @param messagingMessagePayloadCompressedSizeBytes The compressed size of the message payload in bytes. */ - public MessagingSpanBuilder setMessagingMessagePayloadCompressedSizeBytes( - long messagingMessagePayloadCompressedSizeBytes) { + public MessagingSpanBuilder setMessagingMessagePayloadCompressedSizeBytes(long messagingMessagePayloadCompressedSizeBytes) { status.set(AttributeStatus.MESSAGING_MESSAGE_PAYLOAD_COMPRESSED_SIZE_BYTES); - internalBuilder.setAttribute( - "messaging.message_payload_compressed_size_bytes", - messagingMessagePayloadCompressedSizeBytes); + internalBuilder.setAttribute("messaging.message_payload_compressed_size_bytes", messagingMessagePayloadCompressedSizeBytes); return this; } /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ public MessagingSpanBuilder setNetPeerPort(long netPeerPort) { status.set(AttributeStatus.NET_PEER_PORT); @@ -623,7 +568,6 @@ public MessagingSpanBuilder setNetPeerPort(long netPeerPort) { /** * Sets net.transport. - * * @param netTransport Strongly recommended for in-process queueing systems. */ public MessagingSpanBuilder setNetTransport(String netTransport) { @@ -631,5 +575,6 @@ public MessagingSpanBuilder setNetTransport(String netTransport) { internalBuilder.setAttribute("net.transport", netTransport); return this; } + } -} +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/NetworkSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/NetworkSemanticConvention.java index 8e4ab610242b..d83b091c47b2 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/NetworkSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/NetworkSemanticConvention.java @@ -22,53 +22,47 @@ public interface NetworkSemanticConvention { Span getSpan(); + /** * Sets a value for net.transport - * * @param netTransport Transport protocol used. See note below.. */ public NetworkSemanticConvention setNetTransport(String netTransport); /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public NetworkSemanticConvention setNetPeerIp(String netPeerIp); /** * Sets a value for net.peer.port - * * @param netPeerPort Remote port number.. */ public NetworkSemanticConvention setNetPeerPort(long netPeerPort); /** * Sets a value for net.peer.name - * * @param netPeerName Remote hostname or similar, see note below.. */ public NetworkSemanticConvention setNetPeerName(String netPeerName); /** * Sets a value for net.host.ip - * * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. */ public NetworkSemanticConvention setNetHostIp(String netHostIp); /** * Sets a value for net.host.port - * * @param netHostPort Like `net.peer.port` but for the host port.. */ public NetworkSemanticConvention setNetHostPort(long netHostPort); /** * Sets a value for net.host.name - * * @param netHostName Local hostname or similar, see note below.. */ public NetworkSemanticConvention setNetHostName(String netHostName); -} + +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/NetworkSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/NetworkSpan.java index 1fa5ac163d28..1dd145ba842a 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/NetworkSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/NetworkSpan.java @@ -30,6 +30,7 @@ * * + * */ public class NetworkSpan extends DelegatingSpan implements NetworkSemanticConvention { @@ -42,6 +43,7 @@ enum AttributeStatus { NET_HOST_IP, NET_HOST_PORT, NET_HOST_NAME; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -69,7 +71,6 @@ public long getValue() { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(NetworkSpan.class.getName()); - public final AttributeStatus status; protected NetworkSpan(Span span, AttributeStatus status) { @@ -77,17 +78,18 @@ protected NetworkSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * Entry point to generate a {@link NetworkSpan}. - * - * @param tracer Tracer to use - * @param spanName Name for the {@link Span} - * @return a {@link NetworkSpan} object. - */ - public static NetworkSpanBuilder createNetworkSpan(Tracer tracer, String spanName) { + /** + * Entry point to generate a {@link NetworkSpan}. + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link NetworkSpan} object. + */ + public static NetworkSpanBuilder createNetworkSpanBuilder(Tracer tracer, String spanName) { return new NetworkSpanBuilder(tracer, spanName); } + + /** @return the Span used internally */ @Override public Span getSpan() { @@ -105,10 +107,10 @@ public void end() { // conditional attributes } + /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ @Override public NetworkSemanticConvention setNetTransport(String netTransport) { @@ -119,9 +121,7 @@ public NetworkSemanticConvention setNetTransport(String netTransport) { /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ @Override public NetworkSemanticConvention setNetPeerIp(String netPeerIp) { @@ -132,8 +132,7 @@ public NetworkSemanticConvention setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ @Override public NetworkSemanticConvention setNetPeerPort(long netPeerPort) { @@ -144,8 +143,7 @@ public NetworkSemanticConvention setNetPeerPort(long netPeerPort) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ @Override public NetworkSemanticConvention setNetPeerName(String netPeerName) { @@ -156,8 +154,7 @@ public NetworkSemanticConvention setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ @Override public NetworkSemanticConvention setNetHostIp(String netHostIp) { @@ -168,8 +165,7 @@ public NetworkSemanticConvention setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ @Override public NetworkSemanticConvention setNetHostPort(long netHostPort) { @@ -180,8 +176,7 @@ public NetworkSemanticConvention setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ @Override public NetworkSemanticConvention setNetHostName(String netHostName) { @@ -190,39 +185,42 @@ public NetworkSemanticConvention setNetHostName(String netHostName) { return this; } - /** Builder class for {@link NetworkSpan}. */ - public static class NetworkSpanBuilder { + + /** + * Builder class for {@link NetworkSpan}. + */ + public static class NetworkSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected NetworkSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public NetworkSpanBuilder(Builder spanBuilder, long attributes) { + public NetworkSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public NetworkSpanBuilder setParent(Span parent) { + public NetworkSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public NetworkSpanBuilder setParent(SpanContext remoteParent) { + public NetworkSpanBuilder 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 NetworkSpanBuilder setKind(Kind kind) { + public NetworkSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -233,10 +231,10 @@ public NetworkSpan start() { return new NetworkSpan(this.internalBuilder.startSpan(), status); } + /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ public NetworkSpanBuilder setNetTransport(String netTransport) { status.set(AttributeStatus.NET_TRANSPORT); @@ -246,9 +244,7 @@ public NetworkSpanBuilder setNetTransport(String netTransport) { /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public NetworkSpanBuilder setNetPeerIp(String netPeerIp) { status.set(AttributeStatus.NET_PEER_IP); @@ -258,8 +254,7 @@ public NetworkSpanBuilder setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ public NetworkSpanBuilder setNetPeerPort(long netPeerPort) { status.set(AttributeStatus.NET_PEER_PORT); @@ -269,8 +264,7 @@ public NetworkSpanBuilder setNetPeerPort(long netPeerPort) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ public NetworkSpanBuilder setNetPeerName(String netPeerName) { status.set(AttributeStatus.NET_PEER_NAME); @@ -280,8 +274,7 @@ public NetworkSpanBuilder setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ public NetworkSpanBuilder setNetHostIp(String netHostIp) { status.set(AttributeStatus.NET_HOST_IP); @@ -291,8 +284,7 @@ public NetworkSpanBuilder setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ public NetworkSpanBuilder setNetHostPort(long netHostPort) { status.set(AttributeStatus.NET_HOST_PORT); @@ -302,13 +294,13 @@ public NetworkSpanBuilder setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ public NetworkSpanBuilder setNetHostName(String netHostName) { status.set(AttributeStatus.NET_HOST_NAME); internalBuilder.setAttribute("net.host.name", netHostName); return this; } + } -} +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/RpcSemanticConvention.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/RpcSemanticConvention.java index 82e552f2eb3b..ebfc21cc3596 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/RpcSemanticConvention.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/RpcSemanticConvention.java @@ -22,60 +22,53 @@ public interface RpcSemanticConvention { Span getSpan(); + /** * Sets a value for net.transport - * * @param netTransport Transport protocol used. See note below.. */ public RpcSemanticConvention setNetTransport(String netTransport); /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public RpcSemanticConvention setNetPeerIp(String netPeerIp); /** * Sets a value for net.peer.port - * * @param netPeerPort Remote port number.. */ public RpcSemanticConvention setNetPeerPort(long netPeerPort); /** * Sets a value for net.peer.name - * * @param netPeerName Remote hostname or similar, see note below.. */ public RpcSemanticConvention setNetPeerName(String netPeerName); /** * Sets a value for net.host.ip - * * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. */ public RpcSemanticConvention setNetHostIp(String netHostIp); /** * Sets a value for net.host.port - * * @param netHostPort Like `net.peer.port` but for the host port.. */ public RpcSemanticConvention setNetHostPort(long netHostPort); /** * Sets a value for net.host.name - * * @param netHostName Local hostname or similar, see note below.. */ public RpcSemanticConvention setNetHostName(String netHostName); /** * Sets a value for rpc.service - * * @param rpcService The service name, must be equal to the $service part in the span name.. */ public RpcSemanticConvention setRpcService(String rpcService); -} + +} \ No newline at end of file diff --git a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/RpcSpan.java b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/RpcSpan.java index 67f17db255c2..3dfd8389f2d1 100644 --- a/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/RpcSpan.java +++ b/agent-bootstrap/src/main/java/io/opentelemetry/auto/typedspan/RpcSpan.java @@ -53,6 +53,7 @@ enum AttributeStatus { NET_HOST_PORT, NET_HOST_NAME, RPC_SERVICE; + @SuppressWarnings("ImmutableEnumChecker") private long flag; @@ -80,7 +81,6 @@ public long getValue() { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(RpcSpan.class.getName()); - public final AttributeStatus status; protected RpcSpan(Span span, AttributeStatus status) { @@ -88,17 +88,18 @@ protected RpcSpan(Span span, AttributeStatus status) { this.status = status; } - /** - * Entry point to generate a {@link RpcSpan}. - * - * @param tracer Tracer to use - * @param spanName Name for the {@link Span} - * @return a {@link RpcSpan} object. - */ - public static RpcSpanBuilder createRpcSpan(Tracer tracer, String spanName) { + /** + * Entry point to generate a {@link RpcSpan}. + * @param tracer Tracer to use + * @param spanName Name for the {@link Span} + * @return a {@link RpcSpan} object. + */ + public static RpcSpanBuilder createRpcSpanBuilder(Tracer tracer, String spanName) { return new RpcSpanBuilder(tracer, spanName); } + + /** @return the Span used internally */ @Override public Span getSpan() { @@ -118,8 +119,8 @@ public void end() { // extra constraints. { boolean flag = - (!this.status.isSet(AttributeStatus.NET_PEER_IP)) - || (!this.status.isSet(AttributeStatus.NET_PEER_NAME)); + (!this.status.isSet(AttributeStatus.NET_PEER_IP) ) || + (!this.status.isSet(AttributeStatus.NET_PEER_NAME) ) ; if (flag) { logger.info("Constraint not respected!"); } @@ -127,10 +128,10 @@ public void end() { // conditional attributes } + /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ @Override public RpcSemanticConvention setNetTransport(String netTransport) { @@ -141,9 +142,7 @@ public RpcSemanticConvention setNetTransport(String netTransport) { /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ @Override public RpcSemanticConvention setNetPeerIp(String netPeerIp) { @@ -154,8 +153,7 @@ public RpcSemanticConvention setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ @Override public RpcSemanticConvention setNetPeerPort(long netPeerPort) { @@ -166,8 +164,7 @@ public RpcSemanticConvention setNetPeerPort(long netPeerPort) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ @Override public RpcSemanticConvention setNetPeerName(String netPeerName) { @@ -178,8 +175,7 @@ public RpcSemanticConvention setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ @Override public RpcSemanticConvention setNetHostIp(String netHostIp) { @@ -190,8 +186,7 @@ public RpcSemanticConvention setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ @Override public RpcSemanticConvention setNetHostPort(long netHostPort) { @@ -202,8 +197,7 @@ public RpcSemanticConvention setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ @Override public RpcSemanticConvention setNetHostName(String netHostName) { @@ -214,8 +208,7 @@ public RpcSemanticConvention setNetHostName(String netHostName) { /** * Sets rpc.service. - * - * @param rpcService The service name, must be equal to the $service part in the span name.. + * @param rpcService The service name, must be equal to the $service part in the span name. */ @Override public RpcSemanticConvention setRpcService(String rpcService) { @@ -224,39 +217,42 @@ public RpcSemanticConvention setRpcService(String rpcService) { return this; } - /** Builder class for {@link RpcSpan}. */ - public static class RpcSpanBuilder { + + /** + * Builder class for {@link RpcSpan}. + */ + public static class RpcSpanBuilder { // Protected because maybe we want to extend manually these classes - protected Builder internalBuilder; + protected Span.Builder internalBuilder; protected AttributeStatus status = AttributeStatus.EMPTY; protected RpcSpanBuilder(Tracer tracer, String spanName) { internalBuilder = tracer.spanBuilder(spanName); } - public RpcSpanBuilder(Builder spanBuilder, long attributes) { + public RpcSpanBuilder(Span.Builder spanBuilder, long attributes) { this.internalBuilder = spanBuilder; this.status.set(attributes); } - public Builder getSpanBuilder() { + public Span.Builder getSpanBuilder() { return this.internalBuilder; } /** sets the {@link Span} parent. */ - public RpcSpanBuilder setParent(Span parent) { + public RpcSpanBuilder setParent(Span parent){ this.internalBuilder.setParent(parent); return this; } /** sets the {@link Span} parent. */ - public RpcSpanBuilder setParent(SpanContext remoteParent) { + public RpcSpanBuilder 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 RpcSpanBuilder setKind(Kind kind) { + public RpcSpanBuilder setKind(Span.Kind kind) { internalBuilder.setSpanKind(kind); return this; } @@ -267,10 +263,10 @@ public RpcSpan start() { return new RpcSpan(this.internalBuilder.startSpan(), status); } + /** * Sets net.transport. - * - * @param netTransport Transport protocol used. See note below.. + * @param netTransport Transport protocol used. See note below. */ public RpcSpanBuilder setNetTransport(String netTransport) { status.set(AttributeStatus.NET_TRANSPORT); @@ -280,9 +276,7 @@ public RpcSpanBuilder setNetTransport(String netTransport) { /** * 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). + * @param netPeerIp Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6). */ public RpcSpanBuilder setNetPeerIp(String netPeerIp) { status.set(AttributeStatus.NET_PEER_IP); @@ -292,8 +286,7 @@ public RpcSpanBuilder setNetPeerIp(String netPeerIp) { /** * Sets net.peer.port. - * - * @param netPeerPort Remote port number.. + * @param netPeerPort Remote port number. */ public RpcSpanBuilder setNetPeerPort(long netPeerPort) { status.set(AttributeStatus.NET_PEER_PORT); @@ -303,8 +296,7 @@ public RpcSpanBuilder setNetPeerPort(long netPeerPort) { /** * Sets net.peer.name. - * - * @param netPeerName Remote hostname or similar, see note below.. + * @param netPeerName Remote hostname or similar, see note below. */ public RpcSpanBuilder setNetPeerName(String netPeerName) { status.set(AttributeStatus.NET_PEER_NAME); @@ -314,8 +306,7 @@ public RpcSpanBuilder setNetPeerName(String netPeerName) { /** * Sets net.host.ip. - * - * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.. + * @param netHostIp Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. */ public RpcSpanBuilder setNetHostIp(String netHostIp) { status.set(AttributeStatus.NET_HOST_IP); @@ -325,8 +316,7 @@ public RpcSpanBuilder setNetHostIp(String netHostIp) { /** * Sets net.host.port. - * - * @param netHostPort Like `net.peer.port` but for the host port.. + * @param netHostPort Like `net.peer.port` but for the host port. */ public RpcSpanBuilder setNetHostPort(long netHostPort) { status.set(AttributeStatus.NET_HOST_PORT); @@ -336,8 +326,7 @@ public RpcSpanBuilder setNetHostPort(long netHostPort) { /** * Sets net.host.name. - * - * @param netHostName Local hostname or similar, see note below.. + * @param netHostName Local hostname or similar, see note below. */ public RpcSpanBuilder setNetHostName(String netHostName) { status.set(AttributeStatus.NET_HOST_NAME); @@ -347,13 +336,13 @@ public RpcSpanBuilder setNetHostName(String netHostName) { /** * Sets rpc.service. - * - * @param rpcService The service name, must be equal to the $service part in the span name.. + * @param rpcService The service name, must be equal to the $service part in the span name. */ public RpcSpanBuilder setRpcService(String rpcService) { status.set(AttributeStatus.RPC_SERVICE); internalBuilder.setAttribute("rpc.service", rpcService); return this; } + } -} +} \ No newline at end of file diff --git a/agent-bootstrap/src/test/java/io/opentelemetry/auto/typedspan/HttpTypedSpanExampleTest.java b/agent-bootstrap/src/test/java/io/opentelemetry/auto/typedspan/HttpTypedSpanExampleTest.java index d1ae088d2fb3..dac5334b24a3 100644 --- a/agent-bootstrap/src/test/java/io/opentelemetry/auto/typedspan/HttpTypedSpanExampleTest.java +++ b/agent-bootstrap/src/test/java/io/opentelemetry/auto/typedspan/HttpTypedSpanExampleTest.java @@ -28,7 +28,7 @@ public class HttpTypedSpanExampleTest { public void exampleUsage_span() { // https://github.com/open-telemetry/opentelemetry-java/issues/778 HttpServerSpan span = - HttpServerSpan.createHttpServerSpan( + HttpServerSpan.createHttpServerSpanBuilder( OpenTelemetry.getTracerProvider().get("test-tracer"), "https://example.com") .setHttpMethod("GET") .setHttpServerName("example.com") @@ -50,11 +50,11 @@ public void exampleUsage_span() { @Test public void testAttributeEnumBit_builder() { HttpSpan.HttpSpanBuilder span = - HttpSpan.createHttpSpan( + HttpSpan.createHttpSpanBuilder( OpenTelemetry.getTracerProvider().get("test-tracer"), "https://example.com") .setHttpMethod("GET") .setHttpFlavor("1.1"); - HttpServerSpan serverSpan = HttpServerSpan.createHttpServerSpan(span).start(); + HttpServerSpan serverSpan = HttpServerSpan.createHttpServerSpanBuilder(span).start(); serverSpan .setHttpStatusCode(200) .setHttpStatusText("OK")