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

Commit 6ec40aa

Browse files
bripkenskjin
authored andcommitted
feat: Expand OpenCensus span data export to Instana (#91)
- expose error state based on `span.status` - correctly map `span.kind` to Instana's span kinds - remove now unnecessary binary operation
1 parent 703eed0 commit 6ec40aa

File tree

1 file changed

+9
-5
lines changed
  • packages/opencensus-exporter-instana/src

1 file changed

+9
-5
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ import {Exporter, ExporterBuffer, ExporterConfig, RootSpan, Span} from '@opencen
1818
import {logger, Logger} from '@opencensus/core';
1919
import {request} from 'http';
2020

21+
const spanKindTranslation: {[k: string]: string} = {
22+
CLIENT: 'EXIT',
23+
SERVER: 'ENTRY',
24+
LOCAL: 'INTERMEDIATE',
25+
};
26+
2127
type InstanaSpan = {
2228
spanId: string,
2329
parentId: string|undefined,
@@ -101,12 +107,10 @@ export class InstanaTraceExporter implements Exporter {
101107
parentId: span.parentSpanId ? span.parentSpanId : undefined,
102108
traceId: span.traceId.substring(0, 8),
103109
timestamp: span.startTime.getTime(),
104-
// API requires an integer/long
105-
duration: span.duration | 0,
110+
duration: span.duration,
106111
name: span.name,
107-
type: span.kind,
108-
// No translatable counterpart in OpenCensus as of 2018-06-14
109-
error: false,
112+
type: spanKindTranslation[span.kind] || span.kind,
113+
error: span.status != null && span.status !== 0,
110114
data: Object.keys(span.attributes)
111115
.reduce(
112116
(agg: {[k: string]: string}, key) => {

0 commit comments

Comments
 (0)