Skip to content

Commit

Permalink
refactor after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
chradek committed Sep 24, 2019
1 parent 0dd9fcb commit d39c136
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions sdk/core/core-tracing/lib/utils/extractSpanContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ export function extractSpanContextFromTraceParent(traceParent: string): SpanCont
throw new Error(`Unable to extract span context from traceparent "${traceParent}".`);
}

const [_, traceId, spanId, traceFlags] = parts;
const [_, traceId, spanId, traceOptions] = parts;

const traceOptions = parseInt(traceFlags, 16);
const traceFlags = parseInt(traceOptions, 16);

const spanContext: SpanContext = {
spanId,
traceId,
traceOptions
traceFlags
};

return spanContext;
Expand Down
6 changes: 3 additions & 3 deletions sdk/core/core-tracing/lib/utils/getTraceParent.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SpanContext } from "../interfaces/span_context";
import { TraceOptions } from '../interfaces/trace_options';
import { TraceFlags } from '../interfaces/trace_flags';

const VERSION = "00";

Expand All @@ -13,8 +13,8 @@ export function getTraceParent(spanContext: SpanContext): string {
throw new Error(`Missing required fields "traceId" or "spanId" from spanContext.`);
}

const traceOptions = spanContext.traceOptions || TraceOptions.UNSAMPLED;
const traceFlags = (traceOptions < 10) ? `0${traceOptions.toString(16)}` : traceOptions.toString(16);
const flags = spanContext.traceFlags || TraceFlags.UNSAMPLED;
const traceFlags = (flags < 10) ? `0${flags.toString(16)}` : flags.toString(16);

// https://www.w3.org/TR/trace-context/#traceparent-header-field-values
return `${VERSION}-${spanContext.traceId}-${spanContext.spanId}-${traceFlags}`;
Expand Down
10 changes: 6 additions & 4 deletions sdk/core/core-tracing/review/core-tracing.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export interface Event {
name: string;
}

// @public
export function extractSpanContextFromTraceParent(traceParent: string): SpanContext;

// @public
export function getTraceParent(spanContext: SpanContext): string;

// @public
export type HrTime = [number, number];

Expand All @@ -51,10 +57,6 @@ export interface HttpTextFormat {
extract(format: string, carrier: unknown): SpanContext | null;
inject(spanContext: SpanContext, format: string, carrier: unknown): void;
}
export function extractSpanContextFromTraceParent(traceParent: string): SpanContext;

// @public
export function getTraceParent(spanContext: SpanContext): string;

// @public
export interface Link {
Expand Down
2 changes: 1 addition & 1 deletion sdk/eventhub/event-hubs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@azure/abort-controller": "1.0.0-preview.2",
"@azure/core-amqp": "1.0.0-preview.4",
"@azure/core-asynciterator-polyfill": "1.0.0-preview.1",
"@azure/core-tracing": "1.0.0-preview.2",
"@azure/core-tracing": "1.0.0-preview.3",
"async-lock": "^1.1.3",
"buffer": "^5.2.1",
"debug": "^4.1.1",
Expand Down
1 change: 0 additions & 1 deletion sdk/eventhub/event-hubs/src/diagnostics/messageSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export function createMessageSpan(parentSpan?: Span | SpanContext): Span {
kind: SpanKind.INTERNAL,
parent: parentSpan
});
span.start(); // TODO: remove once #5182 is merged

return span;
}
1 change: 0 additions & 1 deletion sdk/eventhub/event-hubs/src/sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ export class EventHubProducer {


const sendSpan = this._createSendSpan(options.parentSpan);
sendSpan.start(); // TODO: remove once #5182 is merged
for (const spanContext of spanContextsToLink) {
sendSpan.addLink(spanContext);
}
Expand Down

0 comments on commit d39c136

Please sign in to comment.