{"name":"@opentelemetry/semantic-conventions","version":"1.29.0","keywords":["opentelemetry","nodejs","tracing","attributes","semantic conventions"],"author":{"name":"OpenTelemetry Authors"},"license":"Apache-2.0","_id":"@opentelemetry/semantic-conventions@1.29.0","homepage":"https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions","bugs":{"url":"https://github.com/open-telemetry/opentelemetry-js/issues"},"dist":{"shasum":"27abd60a1823c39b947d898425ea01da8a4ea0c8","tarball":"http://registry-npm.ywwl.com/@opentelemetry/semantic-conventions/download/@opentelemetry/semantic-conventions-1.29.0.tgz","fileCount":111,"integrity":"sha512-KZ1JsXcP2pqunfsJBNk+py6AJ5R6ZJ3yvM5Lhhf93rHPHvdDzgfMYPS4F7GNO3j/MVDCtfbttrkcpu7sl0Wu/Q==","signatures":[{"sig":"MEUCIHI6rsa3QJDUruwDDNQHY7sMC5IhsUeASTMoi5agZXdgAiEAmiJqjNo/r332BIhH4ErV+LrFSw40il6yZVCHRQqabpQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@opentelemetry%2fsemantic-conventions@1.29.0","provenance":{"predicateType":"https://slsa.dev/provenance/v0.2"}},"unpackedSize":6542606,"size":972096,"noattachment":false,"key":"/@opentelemetry/semantic-conventions/-/@opentelemetry/semantic-conventions-1.29.0.tgz"},"main":"build/src/index.js","types":"build/src/index.d.ts","esnext":"build/esnext/index.js","module":"build/esm/index.js","engines":{"node":">=14"},"exports":{".":{"types":"./build/src/index.d.ts","esnext":"./build/esnext/index.js","module":"./build/esm/index.js","default":"./build/src/index.js"},"./incubating":{"types":"./build/src/index-incubating.d.ts","esnext":"./build/esnext/index-incubating.js","module":"./build/esm/index-incubating.js","default":"./build/src/index-incubating.js"}},"gitHead":"6508845fa61a7d029cc3da52a2efbc5c55cb15e9","scripts":{"clean":"tsc --build --clean tsconfig.json tsconfig.esm.json tsconfig.esnext.json","watch":"tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json","compile":"tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json","version":"node ../scripts/version-update.js","prewatch":"npm run precompile","precompile":"cross-var lerna run version --scope $npm_package_name --include-dependencies","size-check":"npm run compile && mocha 'test/**/*.test.ts'","align-api-deps":"node ../scripts/align-api-deps.js","peer-api-check":"node ../scripts/peer-api-check.js","prepublishOnly":"npm run compile"},"_npmUser":{"name":"dyladan","email":"dyladan@gmail.com"},"repository":{"url":"git+https://github.com/open-telemetry/opentelemetry-js.git","type":"git"},"_npmVersion":"lerna/6.6.2/node@v18.20.6+x64 (linux)","description":"OpenTelemetry semantic conventions","directories":{},"sideEffects":false,"_nodeVersion":"18.20.6","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"17.1.0","nock":"13.5.6","lerna":"6.6.2","mocha":"11.1.0","sinon":"15.1.2","ts-node":"10.9.2","cross-var":"1.1.0","size-limit":"^11.0.1","typescript":"5.0.4","@types/node":"18.6.5","@types/mocha":"10.0.10","@types/sinon":"17.0.3","@size-limit/file":"^11.0.1","@size-limit/time":"^11.0.1","@size-limit/webpack":"^11.0.1"},"_npmOperationalInternal":{"tmp":"tmp/semantic-conventions_1.29.0_1738875172353_0.9208146377782942","host":"s3://npm-registry-packages-npm-production"},"readme":"# OpenTelemetry Semantic Conventions\n\n[![NPM Published Version][npm-img]][npm-url]\n[![Apache License][license-image]][license-image]\n\nSemantic Convention constants for use with the OpenTelemetry SDK/APIs. [This document][trace-semantic_conventions] defines standard attributes for traces.\n\n## Installation\n\n```bash\nnpm install --save @opentelemetry/semantic-conventions\n```\n\n## Import Structure\n\nThis package has 2 separate entry-points:\n\n- The main entry-point, `@opentelemetry/semantic-conventions`, includes only stable semantic conventions.\n  This entry-point follows semantic versioning 2.0: it will not include breaking changes except with a change in the major version number.\n- The \"incubating\" entry-point, `@opentelemetry/semantic-conventions/incubating`, contains unstable semantic conventions (sometimes called \"experimental\") and, for convenience, a re-export of the stable semantic conventions.\n  This entry-point is _NOT_ subject to the restrictions of semantic versioning and _MAY_ contain breaking changes in minor releases. See below for suggested usage of this entry-point.\n\nExported constants follow this naming scheme:\n\n- `ATTR_${attributeName}` for attributes\n- `METRIC_${metricName}` for metric names\n- `${attributeName}_VALUE_{$enumValue}` for enumerations\n\nThe `ATTR`, `METRIC`, and `VALUE` static strings were used to facilitate readability and filtering in auto-complete lists in IDEs.\n\n## Usage\n\n### Stable SemConv\n\n```bash\nnpm install --save @opentelemetry/semantic-conventions\n```\n\n```ts\nimport {\n  ATTR_NETWORK_PEER_ADDRESS,\n  ATTR_NETWORK_PEER_PORT,\n  ATTR_NETWORK_PROTOCOL_NAME,\n  ATTR_NETWORK_PROTOCOL_VERSION,\n  NETWORK_TRANSPORT_VALUE_TCP,\n} from '@opentelemetry/semantic-conventions';\n\nconst span = tracer.startSpan(spanName, spanOptions)\n  .setAttributes({\n    [ATTR_NETWORK_PEER_ADDRESS]: 'localhost',\n    [ATTR_NETWORK_PEER_PORT]: 8080,\n    [ATTR_NETWORK_PROTOCOL_NAME]: 'http',\n    [ATTR_NETWORK_PROTOCOL_VERSION]: '1.1',\n    [ATTR_NETWORK_TRANSPORT]: NETWORK_TRANSPORT_VALUE_TCP,\n  });\n```\n\n### Unstable SemConv\n\n<!-- Dev Note: ^^ This '#unstable-semconv' anchor is being used in jsdoc links in the code. -->\n\nBecause the \"incubating\" entry-point may include breaking changes in minor versions, it is recommended that instrumentation libraries **not** import `@opentelemetry/semantic-conventions/incubating` in runtime code, but instead **copy relevant definitions into their own code base**. (This is the same [recommendation](https://opentelemetry.io/docs/specs/semconv/non-normative/code-generation/#stability-and-versioning) as for other languages.)\n\nFor example, create a \"src/semconv.ts\" (or \"lib/semconv.js\" if implementing in JavaScript) file that copies from [experimental_attributes.ts](./src/experimental_attributes.ts) or [experimental_metrics.ts](./src/experimental_metrics.ts):\n\n```ts\n// src/semconv.ts\nexport const ATTR_DB_NAMESPACE = 'db.namespace';\nexport const ATTR_DB_OPERATION_NAME = 'db.operation.name';\n```\n\n```ts\n// src/instrumentation.ts\nimport {\n  ATTR_SERVER_PORT,\n  ATTR_SERVER_ADDRESS,\n} from '@opentelemetry/semantic-conventions';\nimport {\n  ATTR_DB_NAMESPACE,\n  ATTR_DB_OPERATION_NAME,\n} from './semconv';\n\nspan.setAttributes({\n  [ATTR_DB_NAMESPACE]: ...,\n  [ATTR_DB_OPERATION_NAME]: ...,\n  [ATTR_SERVER_PORT]: ...,\n  [ATTR_SERVER_ADDRESS]: ...,\n})\n```\n\nOccasionally, one should review changes to `@opentelemetry/semantic-conventions` to see if any used unstable conventions have changed or been stabilized. However, an update to a newer minor version of the package will never be breaking.\n\n#### Why not pin the version?\n\nA considered alternative for using unstable exports is to **pin** the version. I.e., depend on an exact version, rather than on a version range.\n\n```bash\nnpm install --save-exact @opentelemetry/semantic-conventions  # Don't do this.\n```\n\nThen, import directly from `@opentelemetry/semantic-conventions/incubating`.\nThis is **not** recommended.\n\nIn some languages having multiple versions of a package in a single application is not possible. This _is_ possible in JavaScript. The primary argument against pinning this package is that it can easily lead to many copies being installed in an application's `node_modules/...`, which can cause significant disk usage. In a disk-constrained environment, such as AWS Lambda Layers, that can be a blocker.\n\n## Deprecations\n\nThere are two main types of deprecations in this package:\n\n1. \"semconv deprecations\": The process of defining the OpenTelemetry [Semantic Conventions][semconv-docs] sometimes involves deprecating a particular field name as conventions are [stabilized][semconv-stability]. For example, the [stabilization of HTTP conventions][semconv-http-stabilization] included deprecating the `http.url` span attribute in favor of `url.full`. When using this JS package, that appears as a deprecation of the `ATTR_HTTP_URL` export in favour of `ATTR_URL_FULL`.\n2. \"JS package deprecations\": Independently, this JavaScript package has twice changed how it exports the Semantic Conventions constants, e.g. `ATTR_HTTP_URL` instead of `SEMATTRS_HTTP_URL`. The two older forms are still included in 1.x versions of this package for backwards compatibility. The rest of this section shows how to migrate to the latest form.\n\n### Migrating from `SEMATTRS_*`, `SEMRESATTRS_*`, ...\n\nDeprecated as of `@opentelemetry/semantic-conventions@1.26.0`.\n\nBefore v1.26.0, constants for each semconv attribute were exported, prefixed with `SEMRESATTRS_` (if defined as a Resource Attribute) or `SEMATTRS_`. As well, constants were exported for each value in an enumeration, of the form `${attributeName}VALUES_${enumValue}`. For example:\n\n**Deprecated usage:**\n\n```js\nimport {\n  SEMRESATTRS_SERVICE_NAME,\n  SEMATTRS_HTTP_ROUTE,\n  SEMATTRS_DB_SYSTEM,\n  DBSYSTEMVALUES_POSTGRESQL\n} from '@opentelemetry/semantic-conventions';\n\n// 'service.name' resource attribute\nconsole.log(SEMRESATTRS_SERVICE_NAME); // migrate to 'ATTR_SERVICE_NAME'\n\n// 'http.route' attribute\nconsole.log(SEMATTRS_HTTP_ROUTE); // migrate to 'ATTR_HTTP_ROUTE'\n\n// 'db.system' attribute\nconsole.log(SEMATTRS_DB_SYSTEM); // migrate to 'ATTR_DB_SYSTEM' (in incubating [*])\n\n// 'postgresql' enum value for 'db.system' attribute\nconsole.log(DBSYSTEMVALUES_POSTGRESQL); // migrate to 'DB_SYSTEM_VALUE_POSTGRESQL' (in incubating [*])\n```\n\nSee [Migrated usage](#migrated-usage) below.\n\n### Migrating from `SemanticAttributes.*`, `SemanticResourceAttributes.*`, ...\n\nDeprecated as of `@opentelemetry/semantic-conventions@1.0.0`.\n\nBefore v1.0.0, constants were exported in namespace objects `SemanticResourceAttributes` and `SemanticAttributes`, and a namespace object for enumerated values for some fields (e.g. `DbSystemValues` for values of the 'db.system' enum). For example:\n\n**Deprecated usage:**\n\n```js\nimport {\n  SemanticAttributes,\n  SemanticResourceAttributes,\n  DbSystemValues,\n} from '@opentelemetry/semantic-conventions';\n\n// 'service.name' resource attribute\nconsole.log(SemanticResourceAttributes.SERVICE_NAME); // migrate to 'ATTR_SERVICE_NAME'\n\n// 'http.route' attribute\nconsole.log(SemanticAttributes.HTTP_ROUTE); // migrate to 'ATTR_HTTP_ROUTE'\n\n// 'db.system' attribute\nconsole.log(SemanticAttributes.DB_SYSTEM); // migrate to 'ATTR_DB_SYSTEM' (in incubating [*])\n\n// 'postgresql' enum value for 'db.system' attribute\nconsole.log(DbSystemValues.POSTGRESQL); // migrate to 'DB_SYSTEM_VALUE_POSTGRESQL' (in incubating [*])\n```\n\nSee [Migrated usage](#migrated-usage) below.\n\n### Migrated usage\n\nIf using any unstable conventions, copy the relevant definitions into your code base (e.g. to \"src/semconv.ts\", see [above](#unstable-semconv)):\n\n```ts\n// src/semconv.ts\nexport const ATTR_DB_SYSTEM = 'db.system' as const;\nexport const DB_SYSTEM_VALUE_POSTGRESQL = \"postgresql\" as const;\n```\n\nthen:\n\n```js\nimport {\n  ATTR_SERVICE_NAME,\n  ATTR_HTTP_ROUTE,\n  METRIC_HTTP_CLIENT_REQUEST_DURATION\n} from '@opentelemetry/semantic-conventions'; // stable semconv\nimport {\n  ATTR_DB_SYSTEM,\n  DB_SYSTEM_VALUE_POSTGRESQL\n} from './semconv'; // unstable semconv\n\nconsole.log(ATTR_SERVICE_NAME); // 'service.name'\nconsole.log(ATTR_HTTP_ROUTE);   // 'http.route'\n\n// Bonus: the older exports did not include metric names from semconv.\n// 'http.client.request.duration' metric name\nconsole.log(METRIC_HTTP_CLIENT_REQUEST_DURATION);\n\nconsole.log(ATTR_DB_SYSTEM);    // 'db.system'\n// 'postgresql' enum value for 'db.system' attribute\nconsole.log(DB_SYSTEM_VALUE_POSTGRESQL);\n```\n\n## Useful links\n\n- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>\n- For more about OpenTelemetry JavaScript: <https://github.com/open-telemetry/opentelemetry-js>\n- For help or feedback on this project, join us in [GitHub Discussions][discussions-url]\n\n## License\n\nApache 2.0 - See [LICENSE][license-url] for more information.\n\n[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions\n[license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/LICENSE\n[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat\n[npm-url]: https://www.npmjs.com/package/@opentelemetry/semantic-conventions\n[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fsemantic-conventions.svg\n[semconv-docs]: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/README.md\n[semconv-stability]: https://opentelemetry.io/docs/specs/otel/versioning-and-stability/#semantic-conventions-stability\n[semconv-http-stabilization]: https://opentelemetry.io/blog/2023/http-conventions-declared-stable/\n[trace-semantic_conventions]: https://github.com/open-telemetry/semantic-conventions/tree/main/specification/trace/semantic_conventions\n","publish_time":1738875172624,"maintainers":[{"name":"bogdandrutu","email":"bogdandrutu@gmail.com"},{"name":"dyladan","email":"dyladan@gmail.com"},{"name":"pichlermarc","email":"marc.pichler@dynatrace.com"}],"_cnpm_publish_time":1738875172624,"dist-tags":{"canary":"0.25.1-alpha.13","latest":"1.45.0","next":"1.8.0"}}