opentelemetry-js/packages/opentelemetry-resources
Trent Mick b76281a32c
refactor(resources): update semconv usage to ATTR_ exports (#5666)
2025-05-09 16:40:04 +00:00
..
src refactor(resources): update semconv usage to ATTR_ exports (#5666) 2025-05-09 16:40:04 +00:00
test refactor(resources): update semconv usage to ATTR_ exports (#5666) 2025-05-09 16:40:04 +00:00
.eslintignore
.eslintrc.js chore(deps): update dependency eslint to v8.43.0 (#3929) 2023-07-06 15:14:56 +02:00
.npmignore
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
karma.worker.js
package.json chore(deps): update dependency webpack to v5.99.7 (#5635) 2025-04-28 10:55:46 +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.