opentelemetry-js/packages/opentelemetry-resources
renovate[bot] 08afa47f6a
chore(deps): update dependency webpack to v5.99.9 (#5704)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-22 15:10:01 +00:00
..
src chore: enable tsconfig isolatedModules (#5697) 2025-05-21 08:10:51 +00:00
test refactor(resources): update semconv usage to ATTR_ exports (#5666) 2025-05-09 16:40:04 +00:00
.eslintignore fix(lint): move tslint to eslint (#892) 2020-05-20 20:42:17 -07:00
.eslintrc.js chore(deps): update dependency eslint to v8.43.0 (#3929) 2023-07-06 15:14:56 +02:00
.npmignore Resources API: package, semantic conventions, and test utils (#815) 2020-03-02 10:13:23 -05:00
LICENSE fix: revert modifications to Apache license (#4640) 2024-04-16 18:01:36 +02:00
README.md docs: update from deprecated SEMRESATTRS_SERVICE_NAME to ATTR_SERVICE_NAME (#5604) 2025-04-10 07:35:26 +00:00
karma.conf.js fix(resources): align exported names in different environments (#2739) 2022-01-29 09:54:01 +01:00
karma.worker.js fix(resources): fix browser compatibility for host and os detectors (#3004) 2022-06-01 10:48:42 -04:00
package.json chore(deps): update dependency webpack to v5.99.9 (#5704) 2025-05-22 15:10:01 +00:00
tsconfig.esm.json chore(semconv): Separate SemConv releases to allow different versioning (#4904) 2024-08-20 21:29:59 +00:00
tsconfig.esnext.json chore(semconv): Separate SemConv releases to allow different versioning (#4904) 2024-08-20 21:29:59 +00:00
tsconfig.json chore(semconv): Separate SemConv releases to allow different versioning (#4904) 2024-08-20 21:29:59 +00:00

README.md

OpenTelemetry Resources Util

NPM Published Version Apache License

The OpenTelemetry Resource is an immutable representation of the entity producing telemetry. For example, a process producing telemetry that is running in a container on Kubernetes has a Pod name, it is in a namespace and possibly is part of a Deployment which also has a name. All three of these attributes can be included in the Resource.

This document defines standard attributes for resources which are accessible via @opentelemetry/semantic-conventions.

Installation

npm install --save @opentelemetry/resources

Usage

import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
import { resourceFromAttributes } from '@opentelemetry/resources';

const resource = resourceFromAttributes({
    [ATTR_SERVICE_NAME]: 'api-service',
});

const anotherResource = resourceFromAttributes({
    'service.version': '2.0.0',
    'service.group': 'instrumentation-group'
});
const mergedResource = resource.merge(anotherResource);

License

Apache 2.0 - See LICENSE for more information.