1414 * limitations under the License.
1515 */
1616
17+ 'use strict' ;
18+
1719// Setup telemetry for tracing and Bunyan logging.
1820//
1921// This writes OTel spans and log records to the console for simplicity. In a
2022// real setup you would configure exporters to send to remote observability apps
2123// for viewing and analysis.
2224
23- const { NodeSDK, tracing, logs, api } = require ( '@opentelemetry/sdk-node' ) ;
24- const { envDetectorSync, hostDetectorSync, processDetectorSync } = require ( '@opentelemetry/resources' ) ;
25+ const { NodeSDK, tracing, logs } = require ( '@opentelemetry/sdk-node' ) ;
26+ const {
27+ envDetectorSync,
28+ hostDetectorSync,
29+ processDetectorSync,
30+ } = require ( '@opentelemetry/resources' ) ;
2531// api.diag.setLogger(new api.DiagConsoleLogger(), api.DiagLogLevel.DEBUG);
2632
27- const { BunyanInstrumentation } = require ( '@opentelemetry/instrumentation-bunyan' ) ;
33+ const {
34+ BunyanInstrumentation,
35+ } = require ( '@opentelemetry/instrumentation-bunyan' ) ;
2836
2937const sdk = new NodeSDK ( {
3038 serviceName : 'bunyan-example' ,
@@ -36,20 +44,22 @@ const sdk = new NodeSDK({
3644 // The HostDetector adds `host.name` and `host.arch` fields. `host.name`
3745 // replaces the usual Bunyan `hostname` field. HostDetector is *not* a
3846 // default detector of the `NodeSDK`.
39- hostDetectorSync
47+ hostDetectorSync ,
4048 ] ,
41- spanProcessor : new tracing . SimpleSpanProcessor ( new tracing . ConsoleSpanExporter ( ) ) ,
42- logRecordProcessor : new logs . SimpleLogRecordProcessor ( new logs . ConsoleLogRecordExporter ( ) ) ,
43- instrumentations : [
44- new BunyanInstrumentation ( ) ,
45- ]
46- } )
47- process . on ( "SIGTERM" , ( ) => {
49+ spanProcessor : new tracing . SimpleSpanProcessor (
50+ new tracing . ConsoleSpanExporter ( )
51+ ) ,
52+ logRecordProcessor : new logs . SimpleLogRecordProcessor (
53+ new logs . ConsoleLogRecordExporter ( )
54+ ) ,
55+ instrumentations : [ new BunyanInstrumentation ( ) ] ,
56+ } ) ;
57+ process . on ( 'SIGTERM' , ( ) => {
4858 sdk
4959 . shutdown ( )
5060 . then (
5161 ( ) => { } ,
52- ( err ) => console . log ( " warning: error shutting down OTel SDK" , err )
62+ err => console . log ( ' warning: error shutting down OTel SDK' , err )
5363 )
5464 . finally ( ( ) => process . exit ( 0 ) ) ;
5565} ) ;
0 commit comments