Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert #3134 - remove anchored clock #3359

Merged
merged 7 commits into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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