npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@opentelemetry/semantic-conventions

v1.38.0

Published

OpenTelemetry semantic conventions

Downloads

211,536,961

Readme

OpenTelemetry Semantic Conventions

NPM Published Version Apache License

Semantic Convention constants for use with the OpenTelemetry SDK/APIs. This document defines standard attributes for traces.

Installation

npm install --save @opentelemetry/semantic-conventions

Import Structure

This package has 2 separate entry-points:

  • The main entry-point, @opentelemetry/semantic-conventions, 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.
  • 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. 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.

Exported constants follow this naming scheme:

  • ATTR_${attributeName} for attributes
  • ${attributeName}_VALUE_{$enumValue} for enumerations of attribute values
  • METRIC_${metricName} for metric names
  • EVENT_${eventName} for event names

The ATTR, METRIC, EVENT, and VALUE static strings were used to facilitate readability and filtering in auto-complete lists in IDEs.

Usage

Stable SemConv

npm install --save @opentelemetry/semantic-conventions
import {
  ATTR_NETWORK_PEER_ADDRESS,
  ATTR_NETWORK_PEER_PORT,
  ATTR_NETWORK_PROTOCOL_NAME,
  ATTR_NETWORK_PROTOCOL_VERSION,
  NETWORK_TRANSPORT_VALUE_TCP,
} from '@opentelemetry/semantic-conventions';

const span = tracer.startSpan(spanName, spanOptions)
  .setAttributes({
    [ATTR_NETWORK_PEER_ADDRESS]: 'localhost',
    [ATTR_NETWORK_PEER_PORT]: 8080,
    [ATTR_NETWORK_PROTOCOL_NAME]: 'http',
    [ATTR_NETWORK_PROTOCOL_VERSION]: '1.1',
    [ATTR_NETWORK_TRANSPORT]: NETWORK_TRANSPORT_VALUE_TCP,
  });

Unstable SemConv

Because 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 as for other languages.)

For example, create a "src/semconv.ts" (or "lib/semconv.js" if implementing in JavaScript) file that copies from experimental_attributes.ts or experimental_metrics.ts:

// src/semconv.ts
export const ATTR_DB_NAMESPACE = 'db.namespace';
export const ATTR_DB_OPERATION_NAME = 'db.operation.name';
// src/instrumentation.ts
import {
  ATTR_SERVER_PORT,
  ATTR_SERVER_ADDRESS,
} from '@opentelemetry/semantic-conventions';
import {
  ATTR_DB_NAMESPACE,
  ATTR_DB_OPERATION_NAME,
} from './semconv';

span.setAttributes({
  [ATTR_DB_NAMESPACE]: ...,
  [ATTR_DB_OPERATION_NAME]: ...,
  [ATTR_SERVER_PORT]: ...,
  [ATTR_SERVER_ADDRESS]: ...,
})

Occasionally, 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.

Why not pin the version?

A considered alternative for using unstable exports is to pin the version. I.e., depend on an exact version, rather than on a version range.

npm install --save-exact @opentelemetry/semantic-conventions  # Don't do this.

Then, import directly from @opentelemetry/semantic-conventions/incubating. This is not recommended.

In 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.

Deprecations

There are two main types of deprecations in this package:

  1. "semconv deprecations": The process of defining the OpenTelemetry Semantic Conventions sometimes involves deprecating a particular field name as conventions are stabilized. For example, the stabilization of HTTP conventions 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.
  2. "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.

Migrating from SEMATTRS_*, SEMRESATTRS_*, ...

Deprecated as of @opentelemetry/[email protected].

Before 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:

Deprecated usage:

import {
  SEMRESATTRS_SERVICE_NAME,
  SEMATTRS_HTTP_ROUTE,
  SEMATTRS_DB_SYSTEM,
  DBSYSTEMVALUES_POSTGRESQL
} from '@opentelemetry/semantic-conventions';

// 'service.name' resource attribute
console.log(SEMRESATTRS_SERVICE_NAME); // migrate to 'ATTR_SERVICE_NAME'

// 'http.route' attribute
console.log(SEMATTRS_HTTP_ROUTE); // migrate to 'ATTR_HTTP_ROUTE'

// 'db.system' attribute
console.log(SEMATTRS_DB_SYSTEM); // migrate to 'ATTR_DB_SYSTEM' (in incubating [*])

// 'postgresql' enum value for 'db.system' attribute
console.log(DBSYSTEMVALUES_POSTGRESQL); // migrate to 'DB_SYSTEM_VALUE_POSTGRESQL' (in incubating [*])

See Migrated usage below.

Migrating from SemanticAttributes.*, SemanticResourceAttributes.*, ...

Deprecated as of @opentelemetry/[email protected].

Before 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:

Deprecated usage:

import {
  SemanticAttributes,
  SemanticResourceAttributes,
  DbSystemValues,
} from '@opentelemetry/semantic-conventions';

// 'service.name' resource attribute
console.log(SemanticResourceAttributes.SERVICE_NAME); // migrate to 'ATTR_SERVICE_NAME'

// 'http.route' attribute
console.log(SemanticAttributes.HTTP_ROUTE); // migrate to 'ATTR_HTTP_ROUTE'

// 'db.system' attribute
console.log(SemanticAttributes.DB_SYSTEM); // migrate to 'ATTR_DB_SYSTEM' (in incubating [*])

// 'postgresql' enum value for 'db.system' attribute
console.log(DbSystemValues.POSTGRESQL); // migrate to 'DB_SYSTEM_VALUE_POSTGRESQL' (in incubating [*])

See Migrated usage below.

Migrated usage

If using any unstable conventions, copy the relevant definitions into your code base (e.g. to "src/semconv.ts", see above):

// src/semconv.ts
export const ATTR_DB_SYSTEM = 'db.system' as const;
export const DB_SYSTEM_VALUE_POSTGRESQL = "postgresql" as const;

then:

import {
  ATTR_SERVICE_NAME,
  ATTR_HTTP_ROUTE,
  METRIC_HTTP_CLIENT_REQUEST_DURATION
} from '@opentelemetry/semantic-conventions'; // stable semconv
import {
  ATTR_DB_SYSTEM,
  DB_SYSTEM_VALUE_POSTGRESQL
} from './semconv'; // unstable semconv

console.log(ATTR_SERVICE_NAME); // 'service.name'
console.log(ATTR_HTTP_ROUTE);   // 'http.route'

// Bonus: the older exports did not include metric names from semconv.
// 'http.client.request.duration' metric name
console.log(METRIC_HTTP_CLIENT_REQUEST_DURATION);

console.log(ATTR_DB_SYSTEM);    // 'db.system'
// 'postgresql' enum value for 'db.system' attribute
console.log(DB_SYSTEM_VALUE_POSTGRESQL);

Useful links

License

Apache 2.0 - See LICENSE for more information.