forked from open-telemetry/opentelemetry-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Events SDK (open-telemetry#4629)
* feat(sdk-events): add Events SDK * updated changelog * markdown lint * updated changelog with changes to the events API * added missing implements * set defaults for severityNumber and timestamp * added OTLP exporter to example * updated package-lock.json * updated versions * pinned api-logs and api-events versions * removed getting global LoggerProvider * updated example version * removed unnecessary constant * lint * updated events example * pinned api-logs version for logs sdk * updated package-lock * removed unused configuration * added forceFlush and shutdown to EventLoggerProvider * updated package-lock.json * updated tsconfig files * fixed package-lock.json * removed shutdown method, updated example * cleanup * added domain to examples * updated versions * fix browser tests
- Loading branch information
1 parent
1f0dcff
commit 89ddaa3
Showing
31 changed files
with
2,344 additions
and
717 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
## Installation | ||
|
||
```sh | ||
# from this directory | ||
npm install | ||
``` | ||
|
||
## Run the Application | ||
|
||
```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-events> | ||
|
||
## LICENSE | ||
|
||
Apache License 2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* 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 { | ||
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( | ||
new SimpleLogRecordProcessor(new ConsoleLogRecordExporter()) | ||
); | ||
|
||
// uncomment to use OTLP exporter | ||
// import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http'; | ||
// const logExporter = new OTLPLogExporter(); | ||
// loggerProvider.addLogRecordProcessor(new SimpleLogRecordProcessor(logExporter)); | ||
|
||
// configure global EventLoggerProvider | ||
const eventLoggerProvider = new EventLoggerProvider(loggerProvider); | ||
events.setGlobalEventLoggerProvider(eventLoggerProvider); | ||
|
||
// emit a log record | ||
const eventLogger = events.getEventLogger('example'); | ||
eventLogger.emit({ | ||
name: 'my-domain.my-event', | ||
data: { | ||
a: 1, | ||
b: 'hello', | ||
c: { | ||
d: 123 | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "events-example", | ||
"version": "0.51.1", | ||
"private": true, | ||
"scripts": { | ||
"start": "ts-node index.ts" | ||
}, | ||
"dependencies": { | ||
"@opentelemetry/api": "^1.7.0", | ||
"@opentelemetry/api-logs": "0.51.1", | ||
"@opentelemetry/sdk-logs": "0.51.1", | ||
"@opentelemetry/api-events": "0.51.1", | ||
"@opentelemetry/sdk-events": "0.51.1", | ||
"@opentelemetry/exporter-logs-otlp-http": "0.51.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "18.6.5", | ||
"ts-node": "^10.9.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"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" | ||
}, | ||
{ | ||
"path": "../../../experimental/packages/exporter-logs-otlp-http" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,6 @@ npm install | |
|
||
## Run the Application | ||
|
||
LogRecord | ||
|
||
```sh | ||
npm start | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/bin | ||
/coverage | ||
/doc | ||
/test |
Oops, something went wrong.