Skip to content

Commit

Permalink
Revert #3134 - remove anchored clock (#3359)
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan authored Oct 28, 2022
1 parent f31448e commit a3e40da
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ All notable changes to this project will be documented in this file.
[#3327](https://github.com/open-telemetry/opentelemetry-js/pull/3327) @dyladan
* fix(resources): fix EnvDetector throwing errors when attribute values contain spaces
[#3295](https://github.com/open-telemetry/opentelemetry-js/issues/3295)
* fix(trace): fix an issue which caused negative span durations in web based spans
[#3359](https://github.com/open-telemetry/opentelemetry-js/pull/3359) @dyladan
* fix(resources): strict OTEL_RESOURCE_ATTRIBUTES baggage octet decoding
[#3341](https://github.com/open-telemetry/opentelemetry-js/pull/3341) @legendecas

Expand Down
16 changes: 0 additions & 16 deletions packages/opentelemetry-sdk-trace-base/src/Tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import {
InstrumentationLibrary,
sanitizeAttributes,
isTracingSuppressed,
AnchoredClock,
otperformance,
} from '@opentelemetry/core';
import { Resource } from '@opentelemetry/resources';
import { BasicTracerProvider } from './BasicTracerProvider';
Expand Down Expand Up @@ -74,22 +72,10 @@ export class Tracer implements api.Tracer {
context = api.trace.deleteSpan(context);
}
const parentSpan = api.trace.getSpan(context);
let clock: AnchoredClock | undefined;
if (parentSpan) {
clock = (parentSpan as any)['_clock'];
}

if (!clock) {
clock = new AnchoredClock(Date, otperformance);
if (parentSpan) {
(parentSpan as any)['_clock'] = clock;
}
}

if (isTracingSuppressed(context)) {
api.diag.debug('Instrumentation suppressed, returning Noop Span');
const nonRecordingSpan = api.trace.wrapSpanContext(api.INVALID_SPAN_CONTEXT);
(nonRecordingSpan as any)['_clock'] = clock;
return nonRecordingSpan;
}

Expand Down Expand Up @@ -134,7 +120,6 @@ export class Tracer implements api.Tracer {
if (samplingResult.decision === api.SamplingDecision.NOT_RECORD) {
api.diag.debug('Recording is off, propagating context in a non-recording span');
const nonRecordingSpan = api.trace.wrapSpanContext(spanContext);
(nonRecordingSpan as any)['_clock'] = clock;
return nonRecordingSpan;
}

Expand All @@ -147,7 +132,6 @@ export class Tracer implements api.Tracer {
parentSpanId,
links,
options.startTime,
clock,
);
// Set initial span attributes. The attributes object may have been mutated
// by the sampler, so we sanitize the merged attributes before setting them.
Expand Down

0 comments on commit a3e40da

Please sign in to comment.