Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions test/agents/test-grpc-tracing.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { threadId } from 'node:worker_threads';
import { setTimeout as delay } from 'node:timers/promises';
import {
checkExitData,
checkResource,
GRPCServer,
TestClient,
} from '../common/nsolid-grpc-agent/index.js';
Expand All @@ -14,11 +15,6 @@ const {
validateArray,
} = validators;

function checkResource(resource) {
validateArray(resource.attributes, 'resource.attributes');
assert.strictEqual(resource.attributes.length, 5);
}

// traceId: {
// type: 'Buffer',
// data: [
Expand Down Expand Up @@ -201,6 +197,7 @@ tests.push({
};
const child = new TestClient(['-t', 'http'], opts);
const agentId = await child.id();
const config = await child.config();
const resourceSpans = [];
let phase = 'initial';
grpcServer.on('spans', mustCallAtLeast(async (spans) => {
Expand All @@ -216,7 +213,7 @@ tests.push({
console.dir(resourceSpans, { depth: null });
const resourceSpan = resourceSpans[0];
const scopeSpans = resourceSpan.scopeSpans[0].spans;
checkResource(resourceSpan.resource);
checkResource(resourceSpan.resource, agentId, config);
checkHttpSpans(scopeSpans, threadId, 0);

resourceSpans.length = 0;
Expand All @@ -237,7 +234,7 @@ tests.push({
console.dir(resourceSpans, { depth: null });
const resourceSpan = resourceSpans[0];
const scopeSpans = resourceSpan.scopeSpans[0].spans;
checkResource(resourceSpan.resource);
checkResource(resourceSpan.resource, agentId, config);
checkHttpSpans(scopeSpans, threadId, 0);

phase = 'done';
Expand Down Expand Up @@ -269,6 +266,7 @@ tests.push({
};
const child = new TestClient(['-t', 'custom'], opts);
const agentId = await child.id();
const config = await child.config();
const resourceSpans = [];
let phase = 'initial';
grpcServer.on('spans', mustCallAtLeast(async (spans) => {
Expand All @@ -284,7 +282,7 @@ tests.push({
console.dir(resourceSpans, { depth: null });
const resourceSpan = resourceSpans[0];
const scopeSpans = resourceSpan.scopeSpans[0].spans;
checkResource(resourceSpan.resource);
checkResource(resourceSpan.resource, agentId, config);
checkCustomSpans(scopeSpans, threadId, 0);

resourceSpans.length = 0;
Expand All @@ -305,7 +303,7 @@ tests.push({
console.dir(resourceSpans, { depth: null });
const resourceSpan = resourceSpans[0];
const scopeSpans = resourceSpan.scopeSpans[0].spans;
checkResource(resourceSpan.resource);
checkResource(resourceSpan.resource, agentId, config);
checkCustomSpans(scopeSpans, threadId, 0);

phase = 'done';
Expand Down
1 change: 1 addition & 0 deletions test/common/nsolid-grpc-agent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function checkResource(resource, agentId, config, metrics) {
'telemetry.sdk.name': 'opentelemetry',
'service.instance.id': agentId,
'service.name': config.app,
'service.version': config.appVersion,
};

if (metrics) {
Expand Down
Loading