-
Notifications
You must be signed in to change notification settings - Fork 821
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
61 changed files
with
3,972 additions
and
20 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
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,23 @@ | ||
## Installation | ||
|
||
```sh | ||
# from this directory | ||
npm install | ||
``` | ||
|
||
## Run the Application | ||
|
||
LogRecord | ||
|
||
```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 |
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,43 @@ | ||
/* | ||
* 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, SeverityNumber } from '@opentelemetry/api-logs'; | ||
import { | ||
LoggerProvider, | ||
ConsoleLogRecordExporter, | ||
SimpleLogRecordProcessor, | ||
} from '@opentelemetry/sdk-logs'; | ||
|
||
// Optional and only needed to see the internal diagnostic logging (during development) | ||
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG); | ||
|
||
const loggerProvider = new LoggerProvider(); | ||
loggerProvider.addLogRecordProcessor( | ||
new SimpleLogRecordProcessor(new ConsoleLogRecordExporter()) | ||
); | ||
|
||
logs.setGlobalLoggerProvider(loggerProvider); | ||
|
||
const logger = logs.getLogger('example', '1.0.0'); | ||
|
||
// emit a log record | ||
logger.emit({ | ||
severityNumber: SeverityNumber.INFO, | ||
severityText: 'INFO', | ||
body: 'this is a log record body', | ||
attributes: { 'log.type': 'custom' }, | ||
}); |
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,17 @@ | ||
{ | ||
"name": "logs-example", | ||
"version": "0.1.0", | ||
"private": true, | ||
"scripts": { | ||
"start": "ts-node index.ts" | ||
}, | ||
"dependencies": { | ||
"@opentelemetry/api": "^1.4.1", | ||
"@opentelemetry/api-logs": "^0.37.0", | ||
"@opentelemetry/sdk-logs": "^0.37.0" | ||
}, | ||
"devDependencies": { | ||
"ts-node": "^10.9.1", | ||
"@types/node": "18.6.5" | ||
} | ||
} |
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,19 @@ | ||
{ | ||
"extends": "../../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "build", | ||
"rootDir": "." | ||
}, | ||
"include": ["./index.ts"], | ||
"references": [ | ||
{ | ||
"path": "../../../api" | ||
}, | ||
{ | ||
"path": "../../../experimental/packages/api-logs" | ||
}, | ||
{ | ||
"path": "../../../experimental/packages/sdk-logs" | ||
} | ||
] | ||
} |
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
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.config.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.