Skip to content

Commit

Permalink
Incorporate newly added TraceOptions & merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurkale22 committed Jul 11, 2019
1 parent 9109b76 commit b3c859c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { BinaryFormat, SpanContext } from '@opentelemetry/types';
import { BinaryFormat, SpanContext, TraceOptions } from '@opentelemetry/types';

const VERSION_ID = 0;
const TRACE_ID_FIELD_ID = 0;
Expand Down Expand Up @@ -61,7 +61,7 @@ export class BinaryTraceContext implements BinaryFormat {
result.write(spanContext.spanId, SPAN_ID_OFFSET, SPAN_ID_SIZE, 'hex');
result.writeUInt8(TRACE_OPTION_FIELD_ID, TRACE_OPTION_FIELD_ID_OFFSET);
result.writeUInt8(
Number(spanContext.traceOptions) || 0,
Number(spanContext.traceOptions) || TraceOptions.UNSAMPLED,
TRACE_OPTIONS_OFFSET
);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

import * as assert from 'assert';
import { BinaryTraceContext } from '../../../src/context/propagation/BinaryTraceContext';
import { SpanContext } from '@opentelemetry/types';
import { BinaryTraceContext } from '../../src/context/propagation/BinaryTraceContext';
import { SpanContext, TraceOptions } from '@opentelemetry/types';

describe('BinaryTraceContext', () => {
const binaryTraceContext = new BinaryTraceContext();
Expand All @@ -32,7 +32,7 @@ describe('BinaryTraceContext', () => {
structured: {
traceId: commonTraceId,
spanId: commonSpanId,
traceOptions: 1,
traceOptions: TraceOptions.SAMPLED,
},
binary: `0000${commonTraceId}01${commonSpanId}02${'01'}`,
description: 'span context with 64-bit span ID',
Expand Down Expand Up @@ -73,7 +73,10 @@ describe('BinaryTraceContext', () => {
assert.deepStrictEqual(
binaryTraceContext.fromBytes(Buffer.from(testCase.binary, 'hex')),
testCase.structured &&
Object.assign({ traceOptions: 0 }, testCase.structured)
Object.assign(
{ traceOptions: TraceOptions.UNSAMPLED },
testCase.structured
)
);
})
);
Expand Down

0 comments on commit b3c859c

Please sign in to comment.