Skip to content

Commit

Permalink
agents: add nsolid.span_kind attribute to Spans
Browse files Browse the repository at this point in the history
PR-URL: #198
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
  • Loading branch information
santigimeno committed Oct 22, 2024
1 parent d8dfdbb commit 420bf1b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions agents/otlp/src/otlp_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ void fill_recordable(Recordable* recordable, const Tracer::SpanStor& s) {
}

recordable->SetAttribute("thread.id", s.thread_id);
recordable->SetAttribute("nsolid.span_type", s.type);

recordable->SetResource(*GetResource());
}
Expand Down
8 changes: 6 additions & 2 deletions test/agents/test-otlp-grpc-traces.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ if (process.argv[2] === 'child') {
const endTimeUnixNano = BigInt(serverSpan.endTimeUnixNano);
assert.ok(endTimeUnixNano);
validateArray(serverSpan.attributes, 'serverSpan.attributes');
assert.strictEqual(serverSpan.attributes.length, 5);
assert.strictEqual(serverSpan.attributes.length, 6);
assert.strictEqual(serverSpan.attributes[0].key, 'http.method');
assert.strictEqual(serverSpan.attributes[0].value.stringValue, 'GET');
assert.strictEqual(serverSpan.attributes[1].key, 'http.status_code');
Expand All @@ -172,6 +172,8 @@ if (process.argv[2] === 'child') {
`http://127.0.0.1:${port}/`);
assert.strictEqual(serverSpan.attributes[4].key, 'thread.id');
assert.strictEqual(serverSpan.attributes[4].value.intValue, `${threadId}`);
assert.strictEqual(serverSpan.attributes[5].key, 'nsolid.span_type');
assert.strictEqual(serverSpan.attributes[5].value.intValue, '8');

const clientSpan = spans[1];
validateId(serverSpan.traceId, 16);
Expand All @@ -183,7 +185,7 @@ if (process.argv[2] === 'child') {
const endTimeUnixNano2 = BigInt(clientSpan.endTimeUnixNano);
assert.ok(endTimeUnixNano2);
validateArray(clientSpan.attributes, 'clientSpan.attributes');
assert.strictEqual(clientSpan.attributes.length, 5);
assert.strictEqual(clientSpan.attributes.length, 6);
assert.strictEqual(clientSpan.attributes[0].key, 'http.method');
assert.strictEqual(clientSpan.attributes[0].value.stringValue, 'GET');
assert.strictEqual(clientSpan.attributes[1].key, 'http.status_code');
Expand All @@ -195,6 +197,8 @@ if (process.argv[2] === 'child') {
`http://127.0.0.1:${port}/`);
assert.strictEqual(clientSpan.attributes[4].key, 'thread.id');
assert.strictEqual(clientSpan.attributes[4].value.intValue, `${threadId}`);
assert.strictEqual(clientSpan.attributes[5].key, 'nsolid.span_type');
assert.strictEqual(clientSpan.attributes[5].value.intValue, '4');
}

function mergeResourceSpans(data, result) {
Expand Down
8 changes: 6 additions & 2 deletions test/agents/test-otlp-traces.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ if (process.argv[2] === 'child') {
const endTimeUnixNano = BigInt(serverSpan.endTimeUnixNano);
assert.ok(endTimeUnixNano);
validateArray(serverSpan.attributes, 'serverSpan.attributes');
assert.strictEqual(serverSpan.attributes.length, 5);
assert.strictEqual(serverSpan.attributes.length, 6);
assert.strictEqual(serverSpan.attributes[0].key, 'http.method');
assert.strictEqual(serverSpan.attributes[0].value.stringValue, 'GET');
assert.strictEqual(serverSpan.attributes[1].key, 'http.status_code');
Expand All @@ -157,6 +157,8 @@ if (process.argv[2] === 'child') {
`http://127.0.0.1:${port}/`);
assert.strictEqual(serverSpan.attributes[4].key, 'thread.id');
assert.strictEqual(serverSpan.attributes[4].value.intValue, `${threadId}`);
assert.strictEqual(serverSpan.attributes[5].key, 'nsolid.span_type');
assert.strictEqual(serverSpan.attributes[5].value.intValue, '8');

const clientSpan = spans[1];
validateString(clientSpan.traceId, 'clientSpan.traceId');
Expand All @@ -168,7 +170,7 @@ if (process.argv[2] === 'child') {
const endTimeUnixNano2 = BigInt(clientSpan.endTimeUnixNano);
assert.ok(endTimeUnixNano2);
validateArray(clientSpan.attributes, 'clientSpan.attributes');
assert.strictEqual(clientSpan.attributes.length, 5);
assert.strictEqual(clientSpan.attributes.length, 6);
assert.strictEqual(clientSpan.attributes[0].key, 'http.method');
assert.strictEqual(clientSpan.attributes[0].value.stringValue, 'GET');
assert.strictEqual(clientSpan.attributes[1].key, 'http.status_code');
Expand All @@ -180,6 +182,8 @@ if (process.argv[2] === 'child') {
`http://127.0.0.1:${port}/`);
assert.strictEqual(clientSpan.attributes[4].key, 'thread.id');
assert.strictEqual(clientSpan.attributes[4].value.intValue, `${threadId}`);
assert.strictEqual(clientSpan.attributes[5].key, 'nsolid.span_type');
assert.strictEqual(clientSpan.attributes[5].value.intValue, '4');
}

function mergeResourceSpans(data, result) {
Expand Down

0 comments on commit 420bf1b

Please sign in to comment.