Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 2fd1a7b

Browse files
authored
Exporter/Stackdriver: Update childSpanCount (#380)
1 parent cc980f2 commit 2fd1a7b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

packages/opencensus-exporter-stackdriver/src/stackdriver-cloudtrace.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ export class StackdriverTraceExporter implements Exporter {
7777
const spanList: Span[] = [];
7878
rootSpans.forEach(rootSpan => {
7979
// RootSpan data
80-
spanList.push(this.createSpan(rootSpan, resourceLabel));
80+
spanList.push(
81+
this.createSpan(rootSpan, resourceLabel, rootSpan.numberOfChildren));
8182
rootSpan.spans.forEach(span => {
8283
// Builds spans data
8384
spanList.push(this.createSpan(span, resourceLabel));
@@ -87,7 +88,8 @@ export class StackdriverTraceExporter implements Exporter {
8788
}
8889

8990
private createSpan(
90-
span: OCSpan, resourceLabels: Record<string, AttributeValue>): Span {
91+
span: OCSpan, resourceLabels: Record<string, AttributeValue>,
92+
numberOfChildren = 0): Span {
9193
const spanName =
9294
`projects/${this.projectId}/traces/${span.traceId}/spans/${span.id}`;
9395

@@ -105,8 +107,8 @@ export class StackdriverTraceExporter implements Exporter {
105107
links: createLinks(span.links, span.droppedLinksCount),
106108
status: {code: span.status.code},
107109
sameProcessAsParentSpan: !span.remoteParent,
108-
childSpanCount: null, // TODO: Consider to add count after pull/332
109-
stackTrace: null, // Unsupported by nodejs
110+
childSpanCount: numberOfChildren,
111+
stackTrace: null, // Unsupported by nodejs
110112
};
111113
if (span.parentSpanId) {
112114
spanBuilder.parentSpanId = span.parentSpanId;

packages/opencensus-exporter-stackdriver/test/test-stackdriver-cloudtrace.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe('Stackdriver Trace Exporter', function() {
9494
},
9595
'droppedAttributesCount': 0
9696
},
97-
'childSpanCount': null,
97+
'childSpanCount': 1,
9898
'displayName': {'value': 'root-test'},
9999
'endTime': rootSpan.endTime.toISOString(),
100100
'links': {'droppedLinksCount': 0, 'link': []},
@@ -121,7 +121,7 @@ describe('Stackdriver Trace Exporter', function() {
121121
},
122122
'droppedAttributesCount': 0
123123
},
124-
'childSpanCount': null,
124+
'childSpanCount': 0,
125125
'displayName': {'value': 'spanTest'},
126126
'endTime': span.endTime.toISOString(),
127127
'links': {'droppedLinksCount': 0, 'link': []},

0 commit comments

Comments
 (0)