Skip to content

Commit 3b80900

Browse files
committed
examples/bunyan changes to get 'npm run lint' passing
1 parent f1122e9 commit 3b80900

File tree

3 files changed

+28
-17
lines changed

3 files changed

+28
-17
lines changed

examples/bunyan/app.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,18 @@
1414
* limitations under the License.
1515
*/
1616

17+
'use strict';
18+
1719
// A small example that shows using OpenTelemetry's instrumentation of
1820
// Bunyan loggers. Usage:
1921
// node --require ./telemetry.js app.js
2022

2123
const otel = require('@opentelemetry/api');
2224
const bunyan = require('bunyan');
2325

24-
const log = bunyan.createLogger({name: 'myapp', level: 'debug'});
26+
const log = bunyan.createLogger({ name: 'myapp', level: 'debug' });
2527

26-
log.debug({foo: 'bar'}, 'hi');
28+
log.debug({ foo: 'bar' }, 'hi');
2729

2830
const tracer = otel.trace.getTracer('example');
2931
tracer.startActiveSpan('manual-span', span => {

examples/bunyan/app.mjs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@
2121
import { trace } from '@opentelemetry/api';
2222
import bunyan from 'bunyan';
2323

24-
const log = bunyan.createLogger({name: 'myapp', level: 'debug'});
24+
const log = bunyan.createLogger({ name: 'myapp', level: 'debug' });
2525

26-
log.debug({foo: 'bar'}, 'hi');
26+
log.debug({ foo: 'bar' }, 'hi');
2727

2828
const tracer = trace.getTracer('example');
2929
tracer.startActiveSpan('manual-span', span => {
3030
log.info('this record will have trace_id et al fields for the current span');
3131
span.end();
3232
});
33-

examples/bunyan/telemetry.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,25 @@
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

2937
const 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

Comments
 (0)