Skip to content

Commit a3e40da

Browse files
authored
Revert #3134 - remove anchored clock (#3359)
1 parent f31448e commit a3e40da

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ All notable changes to this project will be documented in this file.
1717
[#3327](https://github.com/open-telemetry/opentelemetry-js/pull/3327) @dyladan
1818
* fix(resources): fix EnvDetector throwing errors when attribute values contain spaces
1919
[#3295](https://github.com/open-telemetry/opentelemetry-js/issues/3295)
20+
* fix(trace): fix an issue which caused negative span durations in web based spans
21+
[#3359](https://github.com/open-telemetry/opentelemetry-js/pull/3359) @dyladan
2022
* fix(resources): strict OTEL_RESOURCE_ATTRIBUTES baggage octet decoding
2123
[#3341](https://github.com/open-telemetry/opentelemetry-js/pull/3341) @legendecas
2224

packages/opentelemetry-sdk-trace-base/src/Tracer.ts

-16
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import {
1919
InstrumentationLibrary,
2020
sanitizeAttributes,
2121
isTracingSuppressed,
22-
AnchoredClock,
23-
otperformance,
2422
} from '@opentelemetry/core';
2523
import { Resource } from '@opentelemetry/resources';
2624
import { BasicTracerProvider } from './BasicTracerProvider';
@@ -74,22 +72,10 @@ export class Tracer implements api.Tracer {
7472
context = api.trace.deleteSpan(context);
7573
}
7674
const parentSpan = api.trace.getSpan(context);
77-
let clock: AnchoredClock | undefined;
78-
if (parentSpan) {
79-
clock = (parentSpan as any)['_clock'];
80-
}
81-
82-
if (!clock) {
83-
clock = new AnchoredClock(Date, otperformance);
84-
if (parentSpan) {
85-
(parentSpan as any)['_clock'] = clock;
86-
}
87-
}
8875

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

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

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

0 commit comments

Comments
 (0)