|
| 1 | +/* |
| 2 | + * Copyright 2025 New Relic Corporation. All rights reserved. |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | + |
| 6 | +'use strict' |
| 7 | + |
| 8 | +// Attribute values are found at: |
| 9 | +// https://opentelemetry.io/docs/specs/semconv/attributes-registry/ |
| 10 | +// Attribute constant names are found at: |
| 11 | +// https://github.com/open-telemetry/opentelemetry-js/tree/e744798957ac6d980673262a61634f066d9f66a3/semantic-conventions/src |
| 12 | + |
| 13 | +/** |
| 14 | + * Provides a hash of constant attribute names to attribute values as defined |
| 15 | + * by the OTEL semantic conventions. The values and names are still very much |
| 16 | + * in flux (2025-02). As a result, it is easier for us to copy the ones we need |
| 17 | + * here. |
| 18 | + * |
| 19 | + * 1. Everything should be listed in alphabetical order. |
| 20 | + * 2. If an attribute can have multiple names, but all have a common value, |
| 21 | + * only list one constant for us to standardize on internally. Make notes of |
| 22 | + * the other possible upstream names within the jsdoc for the attribute. If they |
| 23 | + * have different values, include multiple attributes with documentation |
| 24 | + * referencing which should be favored. |
| 25 | + * |
| 26 | + * @see https://opentelemetry.io/docs/specs/semconv/ |
| 27 | + * |
| 28 | + * @type {object} |
| 29 | + */ |
| 30 | +module.exports = { |
| 31 | + /** |
| 32 | + * Name of the database (schema) being accessed. |
| 33 | + */ |
| 34 | + ATTR_DB_NAME: 'db.name', |
| 35 | + |
| 36 | + /** |
| 37 | + * The name of the database operation being performed. |
| 38 | + * |
| 39 | + * @example select |
| 40 | + * @example findAndModify |
| 41 | + */ |
| 42 | + ATTR_DB_OPERATION: 'db.operation', |
| 43 | + |
| 44 | + /** |
| 45 | + * The table name that is targeted in the operation. |
| 46 | + */ |
| 47 | + ATTR_DB_SQL_TABLE: 'db.sql.table', |
| 48 | + |
| 49 | + /** |
| 50 | + * The database statement being executed. |
| 51 | + * |
| 52 | + * @example select * from foo |
| 53 | + */ |
| 54 | + ATTR_DB_STATEMENT: 'db.statement', |
| 55 | + |
| 56 | + /** |
| 57 | + * Name of the remote database technology being accessed. |
| 58 | + * |
| 59 | + * @example mysql |
| 60 | + * @see https://opentelemetry.io/docs/specs/semconv/database/sql/ |
| 61 | + */ |
| 62 | + ATTR_DB_SYSTEM: 'db.system', |
| 63 | + |
| 64 | + /** |
| 65 | + * The full resource URL. |
| 66 | + * |
| 67 | + * @example https://example.com/foo?bar=baz |
| 68 | + */ |
| 69 | + ATTR_FULL_URL: 'url.full', |
| 70 | + |
| 71 | + /** |
| 72 | + * Value of the HTTP `host` header. |
| 73 | + * |
| 74 | + * {@link ATTR_HTTP_REQUEST_METHOD} is newer and should be used instead. |
| 75 | + */ |
| 76 | + ATTR_HTTP_HOST: 'http.host', |
| 77 | + |
| 78 | + /** |
| 79 | + * The HTTP request method, e.g. `GET` or `POST`. |
| 80 | + */ |
| 81 | + ATTR_HTTP_METHOD: 'http.method', |
| 82 | + |
| 83 | + /** |
| 84 | + * HTTP method used for the request, e.g. `GET` or `POST`. |
| 85 | + */ |
| 86 | + ATTR_HTTP_REQUEST_METHOD: 'http.request.method', |
| 87 | + |
| 88 | + /** |
| 89 | + * Framework representation for a route, may include parameter tokens. |
| 90 | + * |
| 91 | + * @example /orders/:order_id |
| 92 | + */ |
| 93 | + ATTR_HTTP_ROUTE: 'http.route', |
| 94 | + |
| 95 | + /** |
| 96 | + * The full resource URL. |
| 97 | + * |
| 98 | + * {@link ATTR_FULL_URL} is newer and should be used instead. |
| 99 | + * |
| 100 | + * @example https://example.com/foo?bar=baz |
| 101 | + */ |
| 102 | + ATTR_HTTP_URL: 'http.url', |
| 103 | + |
| 104 | + /** |
| 105 | + * The message destination name. |
| 106 | + * |
| 107 | + * {@link ATTR_MESSAGING_DESTINATION_NAME} is newer and should be used. |
| 108 | + */ |
| 109 | + ATTR_MESSAGING_DESTINATION: 'messaging.destination', |
| 110 | + |
| 111 | + /** |
| 112 | + * The kind of message destination (don't really know, this is what the |
| 113 | + * otel code calls it). |
| 114 | + */ |
| 115 | + ATTR_MESSAGING_DESTINATION_KIND: 'messaging.destination_kind', |
| 116 | + |
| 117 | + /** |
| 118 | + * The target queue name for the message to be delivered to. |
| 119 | + * |
| 120 | + * @example MyQueue |
| 121 | + * @example MyTopic |
| 122 | + */ |
| 123 | + ATTR_MESSAGING_DESTINATION_NAME: 'messaging.destination.name', |
| 124 | + |
| 125 | + /** |
| 126 | + * Target messaging system name. |
| 127 | + * |
| 128 | + * @example kafka |
| 129 | + * @see https://opentelemetry.io/docs/specs/semconv/messaging/messaging-spans/ |
| 130 | + */ |
| 131 | + ATTR_MESSAGING_SYSTEM: 'messaging.system', |
| 132 | + |
| 133 | + /** |
| 134 | + * The collection being accessed. |
| 135 | + */ |
| 136 | + ATTR_MONGODB_COLLECTION: 'db.mongodb.collection', |
| 137 | + |
| 138 | + /** |
| 139 | + * Remote host name. |
| 140 | + */ |
| 141 | + ATTR_NET_PEER_NAME: 'net.peer.name', |
| 142 | + |
| 143 | + /** |
| 144 | + * Remote port number. |
| 145 | + */ |
| 146 | + ATTR_NET_PEER_PORT: 'net.peer.port', |
| 147 | + |
| 148 | + /** |
| 149 | + * The name of the remote method being invoked. |
| 150 | + */ |
| 151 | + ATTR_RPC_METHOD: 'rpc.method', |
| 152 | + |
| 153 | + /** |
| 154 | + * The logical name of the service being called. |
| 155 | + * |
| 156 | + * @example myservice.EchoService |
| 157 | + */ |
| 158 | + ATTR_RPC_SERVICE: 'rpc.service', |
| 159 | + |
| 160 | + /** |
| 161 | + * Defines the RPC technology being instrumented. Will be a string name |
| 162 | + * for a known RPC system. |
| 163 | + * |
| 164 | + * @example grpc |
| 165 | + * @see https://opentelemetry.io/docs/specs/semconv/rpc/rpc-spans/ |
| 166 | + */ |
| 167 | + ATTR_RPC_SYSTEM: 'rpc.system', |
| 168 | + |
| 169 | + /** |
| 170 | + * Logical name of the local service being instrumented. |
| 171 | + */ |
| 172 | + ATTR_SERVICE_NAME: 'service.name', |
| 173 | + |
| 174 | + /** |
| 175 | + * URL path component, e.g. `/foo` in `http://example.com/foo`. This is |
| 176 | + * the fully realized path. See {@link ATTR_HTTP_ROUTE} for the framework |
| 177 | + * representation. |
| 178 | + */ |
| 179 | + ATTR_URL_PATH: 'url.path', |
| 180 | + |
| 181 | + /* !!! Miscellaneous !!! */ |
| 182 | + /** |
| 183 | + * Database system names. |
| 184 | + * |
| 185 | + * @example mysql |
| 186 | + */ |
| 187 | + DB_SYSTEM_VALUES: { |
| 188 | + ADABAS: 'adabas', |
| 189 | + CACHE: 'cache', |
| 190 | + CASSANDRA: 'cassandra', |
| 191 | + CLOUDSCAPE: 'cloudscape', |
| 192 | + COCKROACHDB: 'cockroachdb', |
| 193 | + COLDFUSION: 'coldfusion', |
| 194 | + COSMOSDB: 'cosmosdb', |
| 195 | + COUCHBASE: 'couchbase', |
| 196 | + COUCHDB: 'couchdb', |
| 197 | + DB2: 'DB2', |
| 198 | + DERBY: 'derby', |
| 199 | + DYNAMODB: 'dynamodb', |
| 200 | + EDB: 'edb', |
| 201 | + ELASTICSEARCH: 'elasticsearch', |
| 202 | + FILEMAKER: 'filemaker', |
| 203 | + FIREBIRD: 'firebird', |
| 204 | + FIRSTSQL: 'firstsql', |
| 205 | + GEODE: 'geode', |
| 206 | + H2: 'h2', |
| 207 | + HANADB: 'handadb', |
| 208 | + HBASE: 'hbase', |
| 209 | + HIVE: 'hive', |
| 210 | + HSQLDB: 'hsqldb', |
| 211 | + INFORMIX: 'informix', |
| 212 | + INGRESS: 'ingres', |
| 213 | + INSTANTDB: 'instantdb', |
| 214 | + INTERBASE: 'interbase', |
| 215 | + MARIADB: 'mariadb', |
| 216 | + MAXDB: 'maxdb', |
| 217 | + MEMCACHED: 'memcached', |
| 218 | + MONGODB: 'mongodb', |
| 219 | + MSSQL: 'mssql', |
| 220 | + MYSQL: 'mysql', |
| 221 | + NEO4J: 'neo4j', |
| 222 | + NETEZZA: 'netezza', |
| 223 | + ORACLE: 'oracle', |
| 224 | + OTHER_SQL: 'other_sql', |
| 225 | + PERVASIVE: 'pervasive', |
| 226 | + POINTBASE: 'pointbase', |
| 227 | + POSTGRESQL: 'postgresql', |
| 228 | + PROGRESS: 'progress', |
| 229 | + REDIS: 'redis', |
| 230 | + REDSHIFT: 'redshift', |
| 231 | + SQLITE: 'sqlite', |
| 232 | + SYBASE: 'sybase', |
| 233 | + TERADATA: 'teradata', |
| 234 | + VERTICA: 'vertica', |
| 235 | + }, |
| 236 | + |
| 237 | + /** |
| 238 | + * Kinds of messaging system destinations. |
| 239 | + */ |
| 240 | + MESSAGING_SYSTEM_KIND_VALUES: { |
| 241 | + QUEUE: 'queue', |
| 242 | + TOPIC: 'topic' |
| 243 | + } |
| 244 | +} |
0 commit comments