Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Events SDK #4629

Merged
merged 33 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
197d94f
feat(sdk-events): add Events SDK
martinkuba Mar 28, 2024
7de3134
updated changelog
martinkuba Apr 11, 2024
ad6acae
markdown lint
martinkuba Apr 11, 2024
ce6ac1d
updated changelog with changes to the events API
martinkuba Apr 11, 2024
89709d4
added missing implements
martinkuba Apr 16, 2024
7dd02aa
Merge branch 'main' into events-sdk
martinkuba Apr 16, 2024
bb7a972
Merge remote-tracking branch 'origin/main' into events-sdk
martinkuba Apr 22, 2024
52adb93
set defaults for severityNumber and timestamp
martinkuba Apr 25, 2024
26e5820
added OTLP exporter to example
martinkuba Apr 25, 2024
bc440e9
Merge branch 'main' into events-sdk
martinkuba Apr 25, 2024
73711ec
updated package-lock.json
martinkuba Apr 25, 2024
8b97e9c
updated versions
martinkuba Apr 25, 2024
c47ebe9
pinned api-logs and api-events versions
martinkuba May 2, 2024
b72c354
removed getting global LoggerProvider
martinkuba May 2, 2024
66085f2
updated example version
martinkuba May 2, 2024
0ee3e7f
removed unnecessary constant
martinkuba May 2, 2024
70d7228
lint
martinkuba May 2, 2024
9a557e4
updated events example
martinkuba May 6, 2024
68f47e1
pinned api-logs version for logs sdk
martinkuba May 6, 2024
574e3e2
updated package-lock
martinkuba May 6, 2024
2e8f0d3
Merge remote-tracking branch 'origin/main' into events-sdk
martinkuba May 6, 2024
3f5d227
removed unused configuration
martinkuba May 6, 2024
fc248bc
added forceFlush and shutdown to EventLoggerProvider
martinkuba May 7, 2024
4d55ff4
updated package-lock.json
martinkuba May 7, 2024
b10bad5
updated tsconfig files
martinkuba May 7, 2024
6481b65
fixed package-lock.json
martinkuba May 8, 2024
68789ab
removed shutdown method, updated example
martinkuba May 13, 2024
b45cccb
cleanup
martinkuba May 13, 2024
cb9f2b1
Merge branch 'main' into events-sdk
martinkuba May 13, 2024
5bdbe8d
added domain to examples
martinkuba Jun 3, 2024
0a565e9
Merge branch 'main' into events-sdk
martinkuba Jun 3, 2024
1e6d89f
updated versions
martinkuba Jun 3, 2024
87ad9bc
fix browser tests
martinkuba Jun 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ All notable changes to experimental packages in this project will be documented
* `NodeSDK.configureLoggerProvider()`, please use constructor options instead
* `NodeSDK.addResource()`, please use constructor options instead
* `NodeSDK.detectResources()`, this is not necessary anymore, resources are now auto-detected on `NodeSDK.start()` if the constructor option `autoDetectResources` is unset, `undefined` or `true`.
* feat(api-events): removed traceId and spanId from Event interface, added context and severityNumber [#4629](https://github.com/open-telemetry/opentelemetry-js/pull/4629)

### :rocket: (Enhancement)

* feat(otlp-transformer): consolidate scope/resource creation in transformer [#4600](https://github.com/open-telemetry/opentelemetry-js/pull/4600)
* feat(sdk-logs): print message when attributes are dropped due to attribute count limit [#4614](https://github.com/open-telemetry/opentelemetry-js/pull/4614) @HyunnoH
* feat(sdk-events): add Events SDK [#4629](https://github.com/open-telemetry/opentelemetry-js/pull/4629)

### :bug: (Bug Fix)

Expand Down
23 changes: 23 additions & 0 deletions experimental/examples/events/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Installation

```sh
# from this directory
npm install
```

## Run the Application

LogRecord

JamieDanielson marked this conversation as resolved.
Show resolved Hide resolved
```sh
npm start
```

## Useful links

- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
- For more information on OpenTelemetry logs, visit: <https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/sdk-logs>

## LICENSE

Apache License 2.0
52 changes: 52 additions & 0 deletions experimental/examples/events/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { DiagConsoleLogger, DiagLogLevel, diag } from '@opentelemetry/api';
import { logs } from '@opentelemetry/api-logs';
import {
LoggerProvider,
ConsoleLogRecordExporter,
SimpleLogRecordProcessor,
} from '@opentelemetry/sdk-logs';
import { events } from '@opentelemetry/api-events';
import { EventLoggerProvider } from '@opentelemetry/sdk-events';

// Optional and only needed to see the internal diagnostic logging (during development)
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);

// configure global LoggerProvider
const loggerProvider = new LoggerProvider();
loggerProvider.addLogRecordProcessor(
JamieDanielson marked this conversation as resolved.
Show resolved Hide resolved
new SimpleLogRecordProcessor(new ConsoleLogRecordExporter())
);
logs.setGlobalLoggerProvider(loggerProvider);

// configure global EventLoggerProvider
const eventLoggerProvider = new EventLoggerProvider();
events.setGlobalEventLoggerProvider(eventLoggerProvider);

// emit a log record
const eventLogger = events.getEventLogger('example');
eventLogger.emit({
name: 'my-event',
JamieDanielson marked this conversation as resolved.
Show resolved Hide resolved
data: {
a: 1,
b: 'hello',
c: {
d: 123
}
}
});
19 changes: 19 additions & 0 deletions experimental/examples/events/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "events-example",
"version": "0.50.0",
pichlermarc marked this conversation as resolved.
Show resolved Hide resolved
"private": true,
"scripts": {
"start": "ts-node index.ts"
},
"dependencies": {
"@opentelemetry/api": "^1.7.0",
"@opentelemetry/api-logs": "0.50.0",
"@opentelemetry/sdk-logs": "0.50.0",
"@opentelemetry/api-events": "0.50.0",
"@opentelemetry/sdk-events": "0.50.0"
},
"devDependencies": {
"@types/node": "18.6.5",
"ts-node": "^10.9.1"
}
}
25 changes: 25 additions & 0 deletions experimental/examples/events/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "build",
"rootDir": "."
},
"include": ["./index.ts"],
"references": [
{
"path": "../../../api"
},
{
"path": "../../../experimental/packages/api-events"
},
{
"path": "../../../experimental/packages/api-logs"
},
{
"path": "../../../experimental/packages/sdk-events"
},
{
"path": "../../../experimental/packages/sdk-logs"
}
]
}
16 changes: 8 additions & 8 deletions experimental/packages/api-events/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
},
"repository": "open-telemetry/opentelemetry-js",
"scripts": {
"prepublishOnly": "npm run compile",
"compile": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"build": "npm run compile",
"clean": "tsc --build --clean tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"test": "nyc ts-mocha -p tsconfig.json test/**/*.test.ts",
"test:browser": "karma start --single-run",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../",
"codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../",
"build": "npm run compile",
"compile": "tsc --build 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",
"prepublishOnly": "npm run compile",
"precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies",
"prewatch": "node ../../../scripts/version-update.js"
"prewatch": "node ../../../scripts/version-update.js",
"test": "nyc ts-mocha -p tsconfig.json test/**/*.test.ts",
"test:browser": "karma start --single-run",
"version": "node ../../../scripts/version-update.js",
"watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json"
},
"keywords": [
"opentelemetry",
Expand Down
17 changes: 6 additions & 11 deletions experimental/packages/api-events/src/types/Event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

import { Attributes } from '@opentelemetry/api';
import { AnyValue } from '@opentelemetry/api-logs';
import { Attributes, Context } from '@opentelemetry/api';
import { AnyValue, SeverityNumber } from '@opentelemetry/api-logs';

export interface Event {
/**
Expand All @@ -40,17 +40,12 @@ export interface Event {
attributes?: Attributes;

/**
* 8 least significant bits are the trace flags as defined in W3C Trace Context specification.
* Numerical value of the severity.
*/
traceFlags?: number;
severityNumber?: SeverityNumber;

/**
* A unique identifier for a trace.
* The Context associated with the Event.
*/
traceId?: string;

/**
* A unique identifier for a span within a trace.
*/
spanId?: string;
context?: Context;
}
1 change: 1 addition & 0 deletions experimental/packages/sdk-events/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
7 changes: 7 additions & 0 deletions experimental/packages/sdk-events/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
env: {
mocha: true,
node: true,
},
...require('../../../eslint.base.js'),
};
4 changes: 4 additions & 0 deletions experimental/packages/sdk-events/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/bin
/coverage
/doc
/test
Loading