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

Commit

Permalink
feat: Expand OpenCensus span data export to Instana (#91)
Browse files Browse the repository at this point in the history
- expose error state based on `span.status`
- correctly map `span.kind` to Instana's span kinds
- remove now unnecessary binary operation
  • Loading branch information
bripkens authored and kjin committed Aug 7, 2018
1 parent 703eed0 commit 6ec40aa
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/opencensus-exporter-instana/src/instana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ import {Exporter, ExporterBuffer, ExporterConfig, RootSpan, Span} from '@opencen
import {logger, Logger} from '@opencensus/core';
import {request} from 'http';

const spanKindTranslation: {[k: string]: string} = {
CLIENT: 'EXIT',
SERVER: 'ENTRY',
LOCAL: 'INTERMEDIATE',
};

type InstanaSpan = {
spanId: string,
parentId: string|undefined,
Expand Down Expand Up @@ -101,12 +107,10 @@ export class InstanaTraceExporter implements Exporter {
parentId: span.parentSpanId ? span.parentSpanId : undefined,
traceId: span.traceId.substring(0, 8),
timestamp: span.startTime.getTime(),
// API requires an integer/long
duration: span.duration | 0,
duration: span.duration,
name: span.name,
type: span.kind,
// No translatable counterpart in OpenCensus as of 2018-06-14
error: false,
type: spanKindTranslation[span.kind] || span.kind,
error: span.status != null && span.status !== 0,
data: Object.keys(span.attributes)
.reduce(
(agg: {[k: string]: string}, key) => {
Expand Down

0 comments on commit 6ec40aa

Please sign in to comment.