@opentelemetry/semantic-conventions
v1.25.0 opentelemetry nodejs tracing attributes semantic conventions
OpenTelemetry Semantic Conventions
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 exports.
The main export (@opentelemetry/semantic-conventions
) includes only stable semantic conventions.
It is subject to the restrictions of semantic versioning 2.0.
The /incubating
export (@opentelemetry/semantic-conventions/incubating
) contains all stable and unstable semantic conventions.
It is NOT subject to the restrictions of semantic versioning and MAY contain breaking changes in minor releases.
Usage
Stable SemConv
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
import {
ATTR_PROCESS_COMMAND,
ATTR_PROCESS_COMMAND_ARGS,
ATTR_PROCESS_COMMAND_LINE,
} from '@opentelemetry/semantic-conventions/incubating';
const span = tracer.startSpan(spanName, spanOptions)
.setAttributes({
[ATTR_PROCESS_COMMAND]: 'cat',
[ATTR_PROCESS_COMMAND_ARGS]: ['file1', 'file2'],
[ATTR_CONTAINER_COMMAND_LINE]: 'cat file1 file2',
});
Useful links
- For more information on OpenTelemetry, visit: https://opentelemetry.io/
- For more about OpenTelemetry JavaScript: https://github.com/open-telemetry/opentelemetry-js
- For help or feedback on this project, join us in GitHub Discussions
License
Apache 2.0 - See LICENSE for more information.
npm i @opentelemetry/[email protected]
Metadata
- Apache-2.0
- >=14
- OpenTelemetry Authors
- released 6/5/2024