Skip to content

Commit 0cbcadf

Browse files
authored
Merge pull request #81 from liammclennan/add-traceid-spanid
Add traceid spanid
2 parents 560e964 + c6cc52a commit 0cbcadf

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export interface RemoteConfig {
2020
export interface SeqEvent {
2121
timestamp: Date
2222
level?: string
23+
traceId?: string
24+
spanId?: string
2325
messageTemplate?: string
2426
properties?: object
2527
exception?: string

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "seq-logging",
3-
"version": "2.1.1",
3+
"version": "2.2.0",
44
"description": "Sends structured log events to the Seq HTTP ingestion API",
55
"keywords": [
66
"seq",

seq_logger.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ module.exports = function (safeGlobalBlob, safeGlobalFetch, safeGlobalAbortContr
117117
return {
118118
Timestamp: timestamp,
119119
Level: level,
120+
TraceId: event.traceId?.toString(),
121+
SpanId: event.spanId?.toString(),
120122
MessageTemplate: messageTemplate,
121123
Exception: exception,
122124
Properties: properties

test/seq_logger_integration_tests.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const serverUrlHttp = '[CONFIGURE_URL_HERE]';
1010
const serverUrlHttps = '[CONFIGURE_URL_HERE]';
1111
const storeGracePeriodInMs = 1000;
1212
// required if authentication is turned on
13-
const apiKeyWithUserLevelPermissions = null;
13+
const apiKeyWithUserLevelPermissions = null;
1414

1515
describe('SeqLogger', () => {
1616

@@ -47,21 +47,23 @@ function testEmitAndVerifyStored(url, apiKey, done) {
4747
logger.emit(event);
4848

4949
setTimeout(() => {
50-
verifyMarkerStored(event.properties.testMarker, url, apiKey, done);
50+
verifyMarkerStored(event.properties.testMarker, event.traceId, event.spanId, url, apiKey, done);
5151
}, storeGracePeriodInMs);
5252
}
5353

5454
function makeTestEvent() {
5555
return {
5656
level: 'Error',
5757
timestamp: new Date(),
58+
traceId: '6112be4ab9f113c499dbf4817e503a69',
59+
spanId: '2f2b39a596fc76cd',
5860
messageTemplate: 'Event produced by integration test',
5961
exception: 'Some error at some file on some line',
6062
properties: { testMarker: uuid.v4() }
6163
};
6264
}
6365

64-
function verifyMarkerStored(testMarker, url, apiKey, callback) {
66+
function verifyMarkerStored(testMarker, traceId, spanId, url, apiKey, callback) {
6567

6668
request.get(url + '/api/events')
6769
.query({count: 1, filter: 'Equal(testMarker, @"' + testMarker + '")'})
@@ -71,11 +73,14 @@ function verifyMarkerStored(testMarker, url, apiKey, callback) {
7173
callback(err);
7274
return;
7375
}
74-
76+
7577
if(res.body instanceof Array
7678
&& res.body.length === 1
7779
&& res.body[0].Properties
78-
&& res.body[0].Properties.some(item => item.Name === "testMarker" && item.Value === testMarker)) {
80+
&& res.body[0].Properties.some(item => item.Name === "testMarker" && item.Value === testMarker)
81+
&& res.body[0].TraceId === traceId
82+
&& res.body[0].SpanId === spanId
83+
) {
7984
callback();
8085
return;
8186
}

0 commit comments

Comments
 (0)