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

Commit ce628e4

Browse files
novemberbornkjin
authored andcommitted
feat: map span attributes to labels for stackdriver export (#84)
* feat: Map Span attributes to labels for Stackdriver export * fixup! feat: Map Span attributes to labels for Stackdriver export
1 parent 40c73b2 commit ce628e4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ type TranslatedSpan = {
3333
kind: string,
3434
spanId: string,
3535
startTime: Date,
36-
endTime: Date
36+
endTime: Date,
37+
labels: Record<string, string>
3738
};
3839

3940

@@ -118,7 +119,14 @@ export class StackdriverTraceExporter implements Exporter {
118119
kind: 'SPAN_KIND_UNSPECIFIED',
119120
spanId: span.id,
120121
startTime: span.startTime,
121-
endTime: span.endTime
122+
endTime: span.endTime,
123+
labels: Object.keys(span.attributes)
124+
.reduce(
125+
(acc, k) => {
126+
acc[k] = String(span.attributes[k]);
127+
return acc;
128+
},
129+
{} as Record<string, string>)
122130
};
123131
}
124132

0 commit comments

Comments
 (0)