opentelemetry-js/modules/_opentelemetry_semantic-con...

79 lines
30 KiB
HTML

<!DOCTYPE html><html class="default" lang="en" data-base=".."><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>@opentelemetry/semantic-conventions | OpenTelemetry SDK</title><meta name="description" content="Documentation for OpenTelemetry SDK"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script><script async src="../assets/hierarchy.js" id="tsd-hierarchy-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search"><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">OpenTelemetry SDK</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../index.html">OpenTelemetry SDK</a></li><li><a href="_opentelemetry_semantic-conventions.html">@opentelemetry/semantic-conventions</a></li></ul><h1>Module @opentelemetry/semantic-conventions</h1></div><section class="tsd-panel tsd-typography"><a id="opentelemetry-semantic-conventions" class="tsd-anchor"></a><h1 class="tsd-anchor-link">OpenTelemetry Semantic Conventions<a href="#opentelemetry-semantic-conventions" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h1><p><a href="https://www.npmjs.com/package/@opentelemetry/semantic-conventions"><img src="https://badge.fury.io/js/%40opentelemetry%2Fsemantic-conventions.svg" alt="NPM Published Version"></a>
<a href="https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat"><img src="https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat" alt="Apache License"></a></p>
<p>Semantic Convention constants for use with the OpenTelemetry SDK/APIs. <a href="https://github.com/open-telemetry/semantic-conventions/tree/main/specification/trace/semantic_conventions">This document</a> defines standard attributes for traces.</p>
<a id="installation" class="tsd-anchor"></a><h2 class="tsd-anchor-link">Installation<a href="#installation" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><pre><code class="bash"><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-2">install</span><span class="hl-1"> </span><span class="hl-3">--save</span><span class="hl-1"> </span><span class="hl-2">@opentelemetry/semantic-conventions</span>
</code><button type="button">Copy</button></pre>
<a id="import-structure" class="tsd-anchor"></a><h2 class="tsd-anchor-link">Import Structure<a href="#import-structure" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p>This package has 2 separate entry-points:</p>
<ul>
<li>The main entry-point, <code>@opentelemetry/semantic-conventions</code>, includes only stable semantic conventions.
This entry-point follows semantic versioning 2.0: it will not include breaking changes except with a change in the major version number.</li>
<li>The &quot;incubating&quot; entry-point, <code>@opentelemetry/semantic-conventions/incubating</code>, contains unstable semantic conventions (sometimes called &quot;experimental&quot;) and, for convenience, a re-export of the stable semantic conventions.
This entry-point is <em>NOT</em> subject to the restrictions of semantic versioning and <em>MAY</em> contain breaking changes in minor releases. See below for suggested usage of this entry-point.</li>
</ul>
<p>Exported constants follow this naming scheme:</p>
<ul>
<li><code>ATTR_${attributeName}</code> for attributes</li>
<li><code>${attributeName}_VALUE_{$enumValue}</code> for enumerations of attribute values</li>
<li><code>METRIC_${metricName}</code> for metric names</li>
<li><code>EVENT_${eventName}</code> for event names</li>
</ul>
<p>The <code>ATTR</code>, <code>METRIC</code>, <code>EVENT</code>, and <code>VALUE</code> static strings were used to facilitate readability and filtering in auto-complete lists in IDEs.</p>
<a id="usage" class="tsd-anchor"></a><h2 class="tsd-anchor-link">Usage<a href="#usage" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><a id="stable-semconv" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Stable SemConv<a href="#stable-semconv" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><pre><code class="bash"><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-2">install</span><span class="hl-1"> </span><span class="hl-3">--save</span><span class="hl-1"> </span><span class="hl-2">@opentelemetry/semantic-conventions</span>
</code><button type="button">Copy</button></pre>
<pre><code class="ts"><span class="hl-7">import</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-6">ATTR_NETWORK_PEER_ADDRESS</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-6">ATTR_NETWORK_PEER_PORT</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-6">ATTR_NETWORK_PROTOCOL_NAME</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-6">ATTR_NETWORK_PROTOCOL_VERSION</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-6">NETWORK_TRANSPORT_VALUE_TCP</span><span class="hl-1">,</span><br/><span class="hl-1">} </span><span class="hl-7">from</span><span class="hl-1"> </span><span class="hl-2">&#39;@opentelemetry/semantic-conventions&#39;</span><span class="hl-1">;</span><br/><br/><span class="hl-3">const</span><span class="hl-1"> </span><span class="hl-4">span</span><span class="hl-1"> = </span><span class="hl-6">tracer</span><span class="hl-1">.</span><span class="hl-0">startSpan</span><span class="hl-1">(</span><span class="hl-6">spanName</span><span class="hl-1">, </span><span class="hl-6">spanOptions</span><span class="hl-1">)</span><br/><span class="hl-1"> .</span><span class="hl-0">setAttributes</span><span class="hl-1">({</span><br/><span class="hl-1"> </span><span class="hl-6">[</span><span class="hl-4">ATTR_NETWORK_PEER_ADDRESS</span><span class="hl-6">]:</span><span class="hl-1"> </span><span class="hl-2">&#39;localhost&#39;</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-6">[</span><span class="hl-4">ATTR_NETWORK_PEER_PORT</span><span class="hl-6">]:</span><span class="hl-1"> </span><span class="hl-9">8080</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-6">[</span><span class="hl-4">ATTR_NETWORK_PROTOCOL_NAME</span><span class="hl-6">]:</span><span class="hl-1"> </span><span class="hl-2">&#39;http&#39;</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-6">[</span><span class="hl-4">ATTR_NETWORK_PROTOCOL_VERSION</span><span class="hl-6">]:</span><span class="hl-1"> </span><span class="hl-2">&#39;1.1&#39;</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-6">[</span><span class="hl-4">ATTR_NETWORK_TRANSPORT</span><span class="hl-6">]:</span><span class="hl-1"> </span><span class="hl-4">NETWORK_TRANSPORT_VALUE_TCP</span><span class="hl-1">,</span><br/><span class="hl-1"> });</span>
</code><button type="button">Copy</button></pre>
<a id="unstable-semconv" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Unstable SemConv<a href="#unstable-semconv" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><!-- Dev Note: ^^ This '#unstable-semconv' anchor is being used in jsdoc links in the code. -->
<p>Because the &quot;incubating&quot; entry-point may include breaking changes in minor versions, it is recommended that instrumentation libraries <strong>not</strong> import <code>@opentelemetry/semantic-conventions/incubating</code> in runtime code, but instead <strong>copy relevant definitions into their own code base</strong>. (This is the same <a href="https://opentelemetry.io/docs/specs/semconv/non-normative/code-generation/#stability-and-versioning">recommendation</a> as for other languages.)</p>
<p>For example, create a &quot;src/semconv.ts&quot; (or &quot;lib/semconv.js&quot; if implementing in JavaScript) file that copies from <a href="../media/experimental_attributes.ts">experimental_attributes.ts</a> or <a href="../media/experimental_metrics.ts">experimental_metrics.ts</a>:</p>
<pre><code class="ts"><span class="hl-5">// src/semconv.ts</span><br/><span class="hl-7">export</span><span class="hl-1"> </span><span class="hl-3">const</span><span class="hl-1"> </span><span class="hl-4">ATTR_DB_NAMESPACE</span><span class="hl-1"> = </span><span class="hl-2">&#39;db.namespace&#39;</span><span class="hl-1">;</span><br/><span class="hl-7">export</span><span class="hl-1"> </span><span class="hl-3">const</span><span class="hl-1"> </span><span class="hl-4">ATTR_DB_OPERATION_NAME</span><span class="hl-1"> = </span><span class="hl-2">&#39;db.operation.name&#39;</span><span class="hl-1">;</span>
</code><button type="button">Copy</button></pre>
<pre><code class="ts"><span class="hl-5">// src/instrumentation.ts</span><br/><span class="hl-7">import</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-6">ATTR_SERVER_PORT</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-6">ATTR_SERVER_ADDRESS</span><span class="hl-1">,</span><br/><span class="hl-1">} </span><span class="hl-7">from</span><span class="hl-1"> </span><span class="hl-2">&#39;@opentelemetry/semantic-conventions&#39;</span><span class="hl-1">;</span><br/><span class="hl-7">import</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-6">ATTR_DB_NAMESPACE</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-6">ATTR_DB_OPERATION_NAME</span><span class="hl-1">,</span><br/><span class="hl-1">} </span><span class="hl-7">from</span><span class="hl-1"> </span><span class="hl-2">&#39;./semconv&#39;</span><span class="hl-1">;</span><br/><br/><span class="hl-6">span</span><span class="hl-1">.</span><span class="hl-0">setAttributes</span><span class="hl-1">({</span><br/><span class="hl-1"> </span><span class="hl-6">[</span><span class="hl-4">ATTR_DB_NAMESPACE</span><span class="hl-6">]:</span><span class="hl-1"> ...,</span><br/><span class="hl-1"> </span><span class="hl-6">[</span><span class="hl-4">ATTR_DB_OPERATION_NAME</span><span class="hl-6">]:</span><span class="hl-1"> ...,</span><br/><span class="hl-1"> </span><span class="hl-6">[</span><span class="hl-4">ATTR_SERVER_PORT</span><span class="hl-6">]:</span><span class="hl-1"> ...,</span><br/><span class="hl-1"> </span><span class="hl-6">[</span><span class="hl-4">ATTR_SERVER_ADDRESS</span><span class="hl-6">]:</span><span class="hl-1"> ...,</span><br/><span class="hl-1">})</span>
</code><button type="button">Copy</button></pre>
<p>Occasionally, one should review changes to <code>@opentelemetry/semantic-conventions</code> 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.</p>
<a id="why-not-pin-the-version" class="tsd-anchor"></a><h4 class="tsd-anchor-link">Why not pin the version?<a href="#why-not-pin-the-version" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>A considered alternative for using unstable exports is to <strong>pin</strong> the version. I.e., depend on an exact version, rather than on a version range.</p>
<pre><code class="bash"><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-2">install</span><span class="hl-1"> </span><span class="hl-3">--save-exact</span><span class="hl-1"> </span><span class="hl-2">@opentelemetry/semantic-conventions</span><span class="hl-1"> </span><span class="hl-5"># Don&#39;t do this.</span>
</code><button type="button">Copy</button></pre>
<p>Then, import directly from <code>@opentelemetry/semantic-conventions/incubating</code>.
This is <strong>not</strong> recommended.</p>
<p>In some languages having multiple versions of a package in a single application is not possible. This <em>is</em> 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 <code>node_modules/...</code>, which can cause significant disk usage. In a disk-constrained environment, such as AWS Lambda Layers, that can be a blocker.</p>
<a id="deprecations" class="tsd-anchor"></a><h2 class="tsd-anchor-link">Deprecations<a href="#deprecations" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p>There are two main types of deprecations in this package:</p>
<ol>
<li>&quot;semconv deprecations&quot;: The process of defining the OpenTelemetry <a href="https://github.com/open-telemetry/semantic-conventions/blob/main/docs/README.md">Semantic Conventions</a> sometimes involves deprecating a particular field name as conventions are <a href="https://opentelemetry.io/docs/specs/otel/versioning-and-stability/#semantic-conventions-stability">stabilized</a>. For example, the <a href="https://opentelemetry.io/blog/2023/http-conventions-declared-stable/">stabilization of HTTP conventions</a> included deprecating the <code>http.url</code> span attribute in favor of <code>url.full</code>. When using this JS package, that appears as a deprecation of the <code>ATTR_HTTP_URL</code> export in favour of <code>ATTR_URL_FULL</code>.</li>
<li>&quot;JS package deprecations&quot;: Independently, this JavaScript package has twice changed how it exports the Semantic Conventions constants, e.g. <code>ATTR_HTTP_URL</code> instead of <code>SEMATTRS_HTTP_URL</code>. 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.</li>
</ol>
<a id="migrating-from-semattrs_-semresattrs_-" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Migrating from <code>SEMATTRS_*</code>, <code>SEMRESATTRS_*</code>, ...<a href="#migrating-from-semattrs_-semresattrs_-" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><p>Deprecated as of <code>@opentelemetry/semantic-conventions@1.26.0</code>.</p>
<p>Before v1.26.0, constants for each semconv attribute were exported, prefixed with <code>SEMRESATTRS_</code> (if defined as a Resource Attribute) or <code>SEMATTRS_</code>. As well, constants were exported for each value in an enumeration, of the form <code>${attributeName}VALUES_${enumValue}</code>. For example:</p>
<p><strong>Deprecated usage:</strong></p>
<pre><code class="js"><span class="hl-7">import</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-6">SEMRESATTRS_SERVICE_NAME</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-6">SEMATTRS_HTTP_ROUTE</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-6">SEMATTRS_DB_SYSTEM</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-6">DBSYSTEMVALUES_POSTGRESQL</span><br/><span class="hl-1">} </span><span class="hl-7">from</span><span class="hl-1"> </span><span class="hl-2">&#39;@opentelemetry/semantic-conventions&#39;</span><span class="hl-1">;</span><br/><br/><span class="hl-5">// &#39;service.name&#39; resource attribute</span><br/><span class="hl-6">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-4">SEMRESATTRS_SERVICE_NAME</span><span class="hl-1">); </span><span class="hl-5">// migrate to &#39;ATTR_SERVICE_NAME&#39;</span><br/><br/><span class="hl-5">// &#39;http.route&#39; attribute</span><br/><span class="hl-6">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-4">SEMATTRS_HTTP_ROUTE</span><span class="hl-1">); </span><span class="hl-5">// migrate to &#39;ATTR_HTTP_ROUTE&#39;</span><br/><br/><span class="hl-5">// &#39;db.system&#39; attribute</span><br/><span class="hl-6">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-4">SEMATTRS_DB_SYSTEM</span><span class="hl-1">); </span><span class="hl-5">// migrate to &#39;ATTR_DB_SYSTEM&#39; (in incubating [*])</span><br/><br/><span class="hl-5">// &#39;postgresql&#39; enum value for &#39;db.system&#39; attribute</span><br/><span class="hl-6">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-4">DBSYSTEMVALUES_POSTGRESQL</span><span class="hl-1">); </span><span class="hl-5">// migrate to &#39;DB_SYSTEM_VALUE_POSTGRESQL&#39; (in incubating [*])</span>
</code><button type="button">Copy</button></pre>
<p>See <a href="#migrated-usage">Migrated usage</a> below.</p>
<a id="migrating-from-semanticattributes-semanticresourceattributes-" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Migrating from <code>SemanticAttributes.*</code>, <code>SemanticResourceAttributes.*</code>, ...<a href="#migrating-from-semanticattributes-semanticresourceattributes-" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><p>Deprecated as of <code>@opentelemetry/semantic-conventions@1.0.0</code>.</p>
<p>Before v1.0.0, constants were exported in namespace objects <code>SemanticResourceAttributes</code> and <code>SemanticAttributes</code>, and a namespace object for enumerated values for some fields (e.g. <code>DbSystemValues</code> for values of the 'db.system' enum). For example:</p>
<p><strong>Deprecated usage:</strong></p>
<pre><code class="js"><span class="hl-7">import</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-6">SemanticAttributes</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-6">SemanticResourceAttributes</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-6">DbSystemValues</span><span class="hl-1">,</span><br/><span class="hl-1">} </span><span class="hl-7">from</span><span class="hl-1"> </span><span class="hl-2">&#39;@opentelemetry/semantic-conventions&#39;</span><span class="hl-1">;</span><br/><br/><span class="hl-5">// &#39;service.name&#39; resource attribute</span><br/><span class="hl-6">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-6">SemanticResourceAttributes</span><span class="hl-1">.</span><span class="hl-4">SERVICE_NAME</span><span class="hl-1">); </span><span class="hl-5">// migrate to &#39;ATTR_SERVICE_NAME&#39;</span><br/><br/><span class="hl-5">// &#39;http.route&#39; attribute</span><br/><span class="hl-6">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-6">SemanticAttributes</span><span class="hl-1">.</span><span class="hl-4">HTTP_ROUTE</span><span class="hl-1">); </span><span class="hl-5">// migrate to &#39;ATTR_HTTP_ROUTE&#39;</span><br/><br/><span class="hl-5">// &#39;db.system&#39; attribute</span><br/><span class="hl-6">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-6">SemanticAttributes</span><span class="hl-1">.</span><span class="hl-4">DB_SYSTEM</span><span class="hl-1">); </span><span class="hl-5">// migrate to &#39;ATTR_DB_SYSTEM&#39; (in incubating [*])</span><br/><br/><span class="hl-5">// &#39;postgresql&#39; enum value for &#39;db.system&#39; attribute</span><br/><span class="hl-6">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-6">DbSystemValues</span><span class="hl-1">.</span><span class="hl-4">POSTGRESQL</span><span class="hl-1">); </span><span class="hl-5">// migrate to &#39;DB_SYSTEM_VALUE_POSTGRESQL&#39; (in incubating [*])</span>
</code><button type="button">Copy</button></pre>
<p>See <a href="#migrated-usage">Migrated usage</a> below.</p>
<a id="migrated-usage" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Migrated usage<a href="#migrated-usage" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><p>If using any unstable conventions, copy the relevant definitions into your code base (e.g. to &quot;src/semconv.ts&quot;, see <a href="#unstable-semconv">above</a>):</p>
<pre><code class="ts"><span class="hl-5">// src/semconv.ts</span><br/><span class="hl-7">export</span><span class="hl-1"> </span><span class="hl-3">const</span><span class="hl-1"> </span><span class="hl-4">ATTR_DB_SYSTEM</span><span class="hl-1"> = </span><span class="hl-2">&#39;db.system&#39;</span><span class="hl-1"> </span><span class="hl-7">as</span><span class="hl-1"> </span><span class="hl-3">const</span><span class="hl-1">;</span><br/><span class="hl-7">export</span><span class="hl-1"> </span><span class="hl-3">const</span><span class="hl-1"> </span><span class="hl-4">DB_SYSTEM_VALUE_POSTGRESQL</span><span class="hl-1"> = </span><span class="hl-2">&quot;postgresql&quot;</span><span class="hl-1"> </span><span class="hl-7">as</span><span class="hl-1"> </span><span class="hl-3">const</span><span class="hl-1">;</span>
</code><button type="button">Copy</button></pre>
<p>then:</p>
<pre><code class="js"><span class="hl-7">import</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-6">ATTR_SERVICE_NAME</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-6">ATTR_HTTP_ROUTE</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-6">METRIC_HTTP_CLIENT_REQUEST_DURATION</span><br/><span class="hl-1">} </span><span class="hl-7">from</span><span class="hl-1"> </span><span class="hl-2">&#39;@opentelemetry/semantic-conventions&#39;</span><span class="hl-1">; </span><span class="hl-5">// stable semconv</span><br/><span class="hl-7">import</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-6">ATTR_DB_SYSTEM</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-6">DB_SYSTEM_VALUE_POSTGRESQL</span><br/><span class="hl-1">} </span><span class="hl-7">from</span><span class="hl-1"> </span><span class="hl-2">&#39;./semconv&#39;</span><span class="hl-1">; </span><span class="hl-5">// unstable semconv</span><br/><br/><span class="hl-6">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-4">ATTR_SERVICE_NAME</span><span class="hl-1">); </span><span class="hl-5">// &#39;service.name&#39;</span><br/><span class="hl-6">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-4">ATTR_HTTP_ROUTE</span><span class="hl-1">); </span><span class="hl-5">// &#39;http.route&#39;</span><br/><br/><span class="hl-5">// Bonus: the older exports did not include metric names from semconv.</span><br/><span class="hl-5">// &#39;http.client.request.duration&#39; metric name</span><br/><span class="hl-6">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-4">METRIC_HTTP_CLIENT_REQUEST_DURATION</span><span class="hl-1">);</span><br/><br/><span class="hl-6">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-4">ATTR_DB_SYSTEM</span><span class="hl-1">); </span><span class="hl-5">// &#39;db.system&#39;</span><br/><span class="hl-5">// &#39;postgresql&#39; enum value for &#39;db.system&#39; attribute</span><br/><span class="hl-6">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-4">DB_SYSTEM_VALUE_POSTGRESQL</span><span class="hl-1">);</span>
</code><button type="button">Copy</button></pre>
<a id="useful-links" class="tsd-anchor"></a><h2 class="tsd-anchor-link">Useful links<a href="#useful-links" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><ul>
<li>For more information on OpenTelemetry, visit: <a href="https://opentelemetry.io/">https://opentelemetry.io/</a></li>
<li>For more about OpenTelemetry JavaScript: <a href="https://github.com/open-telemetry/opentelemetry-js">https://github.com/open-telemetry/opentelemetry-js</a></li>
<li>For help or feedback on this project, join us in <a href="https://github.com/open-telemetry/opentelemetry-js/discussions">GitHub Discussions</a></li>
</ul>
<a id="license" class="tsd-anchor"></a><h2 class="tsd-anchor-link">License<a href="#license" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p>Apache 2.0 - See <a href="https://github.com/open-telemetry/opentelemetry-js/blob/main/LICENSE">LICENSE</a> for more information.</p>
</section></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><a href="#opentelemetry-semantic-conventions"><span>Open<wbr/>Telemetry <wbr/>Semantic <wbr/>Conventions</span></a><ul><li><a href="#installation"><span>Installation</span></a></li><li><a href="#import-structure"><span>Import <wbr/>Structure</span></a></li><li><a href="#usage"><span>Usage</span></a></li><li><ul><li><a href="#stable-semconv"><span>Stable <wbr/>Sem<wbr/>Conv</span></a></li><li><a href="#unstable-semconv"><span>Unstable <wbr/>Sem<wbr/>Conv</span></a></li><li><ul><li><a href="#why-not-pin-the-version"><span>Why not pin the version?</span></a></li></ul></li></ul></li><li><a href="#deprecations"><span>Deprecations</span></a></li><li><ul><li><a href="#migrating-from-semattrs_-semresattrs_-"><span>Migrating from SEMATTRS_<wbr/>*, SEMRESATTRS_<wbr/>*, ...</span></a></li><li><a href="#migrating-from-semanticattributes-semanticresourceattributes-"><span>Migrating from <wbr/>Semantic<wbr/>Attributes.*, <wbr/>Semantic<wbr/>Resource<wbr/>Attributes.*, ...</span></a></li><li><a href="#migrated-usage"><span>Migrated usage</span></a></li></ul></li><li><a href="#useful-links"><span>Useful links</span></a></li><li><a href="#license"><span>License</span></a></li></ul></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../index.html">OpenTelemetry SDK</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>