@sebspark/otel 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +22 -8
- package/dist/index.mjs +22 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -233,8 +233,8 @@ function formatSpans(spans) {
|
|
|
233
233
|
const totalDuration = rootEnd - rootStart;
|
|
234
234
|
const service = formatService(rootSpan.resource);
|
|
235
235
|
const timestamp = formatTimestamp(rootSpan.startTime);
|
|
236
|
-
const
|
|
237
|
-
const lines = [`${service} ${timestamp} ${
|
|
236
|
+
const traceId = colors.gray(`[${rootSpan.spanContext().traceId}]`);
|
|
237
|
+
const lines = [`${service} ${timestamp} ${traceId}`];
|
|
238
238
|
for (const span of spans) {
|
|
239
239
|
const offset = hrTimeToMillis(span.startTime) - rootStart;
|
|
240
240
|
const depth = computeDepth(span, spans);
|
|
@@ -255,8 +255,8 @@ function formatSpan(span, opts) {
|
|
|
255
255
|
const desc = formatDescription(span);
|
|
256
256
|
const status = formatStatus(span);
|
|
257
257
|
const duration = formatDuration(span, opts?.offsetMs);
|
|
258
|
-
const
|
|
259
|
-
return `${label} ${barColor(bar)} ${desc} ${status} ${duration} ${
|
|
258
|
+
const spanId = colors.gray(`[${span.spanContext().spanId}]`);
|
|
259
|
+
return `${label} ${barColor(bar)} ${desc} ${status} ${duration} ${spanId}`;
|
|
260
260
|
}
|
|
261
261
|
function formatLabel(span, depth) {
|
|
262
262
|
const indent = " ".repeat(depth);
|
|
@@ -539,13 +539,27 @@ var TreeSpanProcessor = class {
|
|
|
539
539
|
|
|
540
540
|
// src/providers.ts
|
|
541
541
|
var getLogProvider = (resource, otlpEndpoint) => {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
542
|
+
if (otlpEndpoint) {
|
|
543
|
+
const exporter2 = new import_exporter_logs_otlp_http.OTLPLogExporter({ url: `${otlpEndpoint}/v1/logs` });
|
|
544
|
+
const processors = [
|
|
545
|
+
new import_sdk_logs.BatchLogRecordProcessor(exporter2)
|
|
546
|
+
];
|
|
547
|
+
if (process.env.LOG_LEVEL) {
|
|
548
|
+
processors.push(
|
|
549
|
+
new import_sdk_logs.SimpleLogRecordProcessor(new ConsoleLogPrettyExporter())
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
return new import_sdk_logs.LoggerProvider({
|
|
553
|
+
resource,
|
|
554
|
+
processors
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
const exporter = new ConsoleLogPrettyExporter();
|
|
558
|
+
const processor = new import_sdk_logs.SimpleLogRecordProcessor(exporter);
|
|
559
|
+
return new import_sdk_logs.LoggerProvider({
|
|
545
560
|
resource,
|
|
546
561
|
processors: [processor]
|
|
547
562
|
});
|
|
548
|
-
return provider;
|
|
549
563
|
};
|
|
550
564
|
var getSpanProcessor = (otlpEndpoint) => {
|
|
551
565
|
const exporter = otlpEndpoint ? new import_exporter_trace_otlp_http.OTLPTraceExporter({
|
package/dist/index.mjs
CHANGED
|
@@ -204,8 +204,8 @@ function formatSpans(spans) {
|
|
|
204
204
|
const totalDuration = rootEnd - rootStart;
|
|
205
205
|
const service = formatService(rootSpan.resource);
|
|
206
206
|
const timestamp = formatTimestamp(rootSpan.startTime);
|
|
207
|
-
const
|
|
208
|
-
const lines = [`${service} ${timestamp} ${
|
|
207
|
+
const traceId = colors.gray(`[${rootSpan.spanContext().traceId}]`);
|
|
208
|
+
const lines = [`${service} ${timestamp} ${traceId}`];
|
|
209
209
|
for (const span of spans) {
|
|
210
210
|
const offset = hrTimeToMillis(span.startTime) - rootStart;
|
|
211
211
|
const depth = computeDepth(span, spans);
|
|
@@ -226,8 +226,8 @@ function formatSpan(span, opts) {
|
|
|
226
226
|
const desc = formatDescription(span);
|
|
227
227
|
const status = formatStatus(span);
|
|
228
228
|
const duration = formatDuration(span, opts?.offsetMs);
|
|
229
|
-
const
|
|
230
|
-
return `${label} ${barColor(bar)} ${desc} ${status} ${duration} ${
|
|
229
|
+
const spanId = colors.gray(`[${span.spanContext().spanId}]`);
|
|
230
|
+
return `${label} ${barColor(bar)} ${desc} ${status} ${duration} ${spanId}`;
|
|
231
231
|
}
|
|
232
232
|
function formatLabel(span, depth) {
|
|
233
233
|
const indent = " ".repeat(depth);
|
|
@@ -510,13 +510,27 @@ var TreeSpanProcessor = class {
|
|
|
510
510
|
|
|
511
511
|
// src/providers.ts
|
|
512
512
|
var getLogProvider = (resource, otlpEndpoint) => {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
513
|
+
if (otlpEndpoint) {
|
|
514
|
+
const exporter2 = new OTLPLogExporter({ url: `${otlpEndpoint}/v1/logs` });
|
|
515
|
+
const processors = [
|
|
516
|
+
new BatchLogRecordProcessor(exporter2)
|
|
517
|
+
];
|
|
518
|
+
if (process.env.LOG_LEVEL) {
|
|
519
|
+
processors.push(
|
|
520
|
+
new SimpleLogRecordProcessor(new ConsoleLogPrettyExporter())
|
|
521
|
+
);
|
|
522
|
+
}
|
|
523
|
+
return new LoggerProvider({
|
|
524
|
+
resource,
|
|
525
|
+
processors
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
const exporter = new ConsoleLogPrettyExporter();
|
|
529
|
+
const processor = new SimpleLogRecordProcessor(exporter);
|
|
530
|
+
return new LoggerProvider({
|
|
516
531
|
resource,
|
|
517
532
|
processors: [processor]
|
|
518
533
|
});
|
|
519
|
-
return provider;
|
|
520
534
|
};
|
|
521
535
|
var getSpanProcessor = (otlpEndpoint) => {
|
|
522
536
|
const exporter = otlpEndpoint ? new OTLPTraceExporter({
|