Skip to content

Commit

Permalink
fix(jaeger-exporter): export SpanKind as Tag (open-telemetry#596)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurkale22 authored Dec 10, 2019
1 parent 811d7a6 commit daff102
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
7 changes: 6 additions & 1 deletion packages/opentelemetry-exporter-jaeger/src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { Link, CanonicalCode } from '@opentelemetry/types';
import { Link, CanonicalCode, SpanKind } from '@opentelemetry/types';
import { ReadableSpan } from '@opentelemetry/tracing';
import {
hrTimeToMilliseconds,
Expand Down Expand Up @@ -59,6 +59,11 @@ export function spanToThrift(span: ReadableSpan): ThriftSpan {
if (span.status.code !== CanonicalCode.OK) {
tags.push({ key: 'error', value: true });
}

if (span.kind !== undefined) {
tags.push({ key: 'span.kind', value: SpanKind[span.kind] });
}

const spanTags: ThriftTag[] = ThriftUtils.getThriftTags(tags);

const logs = span.events.map(
Expand Down
14 changes: 10 additions & 4 deletions packages/opentelemetry-exporter-jaeger/test/transform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ describe('transform', () => {
thriftSpan.startTime,
Utils.encodeInt64(hrTimeToMicroseconds(readableSpan.startTime))
);
assert.strictEqual(thriftSpan.tags.length, 5);
const [tag1, tag2, tag3, tag4, tag5] = thriftSpan.tags;
assert.strictEqual(thriftSpan.tags.length, 6);
const [tag1, tag2, tag3, tag4, tag5, tag6] = thriftSpan.tags;
assert.strictEqual(tag1.key, 'testBool');
assert.strictEqual(tag1.vType, 'BOOL');
assert.strictEqual(tag1.vBool, true);
Expand All @@ -107,6 +107,9 @@ describe('transform', () => {
assert.strictEqual(tag5.key, 'status.name');
assert.strictEqual(tag5.vType, 'STRING');
assert.strictEqual(tag5.vStr, 'OK');
assert.strictEqual(tag6.key, 'span.kind');
assert.strictEqual(tag6.vType, 'STRING');
assert.strictEqual(tag6.vStr, 'INTERNAL');
assert.strictEqual(thriftSpan.references.length, 0);

assert.strictEqual(thriftSpan.logs.length, 1);
Expand Down Expand Up @@ -157,8 +160,8 @@ describe('transform', () => {
assert.deepStrictEqual(thriftSpan.parentSpanId, ThriftUtils.emptyBuffer);
assert.deepStrictEqual(thriftSpan.flags, 1);
assert.strictEqual(thriftSpan.references.length, 0);
assert.strictEqual(thriftSpan.tags.length, 4);
const [tag1, tag2, tag3, tag4] = thriftSpan.tags;
assert.strictEqual(thriftSpan.tags.length, 5);
const [tag1, tag2, tag3, tag4, tag5] = thriftSpan.tags;
assert.strictEqual(tag1.key, 'status.code');
assert.strictEqual(tag1.vType, 'DOUBLE');
assert.strictEqual(tag1.vDouble, 15);
Expand All @@ -171,6 +174,9 @@ describe('transform', () => {
assert.strictEqual(tag4.key, 'error');
assert.strictEqual(tag4.vType, 'BOOL');
assert.strictEqual(tag4.vBool, true);
assert.strictEqual(tag5.key, 'span.kind');
assert.strictEqual(tag5.vType, 'STRING');
assert.strictEqual(tag5.vStr, 'CLIENT');
assert.strictEqual(thriftSpan.logs.length, 0);
});

Expand Down

0 comments on commit daff102

Please sign in to comment.