Skip to content

Commit

Permalink
Use weaver to generate latest semconv 1.27 (open-telemetry#4690)
Browse files Browse the repository at this point in the history
Co-authored-by: Trent Mick <[email protected]>
Co-authored-by: Marc Pichler <[email protected]>
  • Loading branch information
3 people authored and Zirak committed Sep 14, 2024
1 parent 4a23300 commit 2bee559
Show file tree
Hide file tree
Showing 19 changed files with 10,429 additions and 265 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
### :rocket: (Enhancement)

* feat: include instrumentation scope info in console span and log record exporters [#4848](https://github.com/open-telemetry/opentelemetry-js/pull/4848) @blumamir
* feat(semconv): update semantic conventions to 1.27 (from 1.7.0) [#4690](https://github.com/open-telemetry/opentelemetry-js/pull/4690) @dyladan
* Exported names have changed to `ATTR_{name}` for attributes (e.g. `ATTR_HTTP_REQUEST_METHOD`), `{name}_VALUE_{value}` for enumeration values (e.g. `HTTP_REQUEST_METHOD_VALUE_POST`), and `METRIC_{name}` for metrics. Exported names from previous versions are deprecated.
* Import `@opentelemetry/semantic-conventions` for *stable* semantic conventions. Import `@opentelemetry/semantic-conventions/incubating` for all semantic conventions, stable and unstable.

### :bug: (Bug Fix)

Expand Down
43 changes: 40 additions & 3 deletions packages/opentelemetry-semantic-conventions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,51 @@ Semantic Convention constants for use with the OpenTelemetry SDK/APIs. [This doc
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

```ts
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

```ts
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import {
ATTR_PROCESS_COMMAND,
ATTR_PROCESS_COMMAND_ARGS,
ATTR_PROCESS_COMMAND_LINE,
} from '@opentelemetry/semantic-conventions/incubating';

const span = tracer.startSpan().startSpan(spanName, spanOptions)
const span = tracer.startSpan(spanName, spanOptions)
.setAttributes({
[SemanticAttributes.NET_PEER_NAME]: 'localhost',
[ATTR_PROCESS_COMMAND]: 'cat',
[ATTR_PROCESS_COMMAND_ARGS]: ['file1', 'file2'],
[ATTR_CONTAINER_COMMAND_LINE]: 'cat file1 file2',
});
```

Expand Down
26 changes: 24 additions & 2 deletions packages/opentelemetry-semantic-conventions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,35 @@
"module": "build/esm/index.js",
"esnext": "build/esnext/index.js",
"types": "build/src/index.d.ts",
"exports": {
".": {
"module": "./build/esm/index.js",
"esnext": "./build/esnext/index.js",
"types": "./build/src/index.d.ts",
"default": "./build/src/index.js"
},
"./incubating": {
"module": "./build/esm/index-incubating.js",
"esnext": "./build/esnext/index-incubating.js",
"types": "./build/src/index-incubating.d.ts",
"default": "./build/src/index-incubating.js"
}
},
"typesVersions": {
"*": {
"*": [
"./build/src/index.d.ts"
],
"incubating": [
"./build/src/index-incubating.d.ts"
]
}
},
"repository": "open-telemetry/opentelemetry-js",
"scripts": {
"prepublishOnly": "npm run compile",
"compile": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"clean": "tsc --build --clean tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"version": "node ../../scripts/version-update.js",
"watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies",
Expand Down
Loading

0 comments on commit 2bee559

Please sign in to comment.