Skip to content

Commit 9579106

Browse files
test(sdk-trace-base): pin core.hrtime dependencies on timeOrigin (#2768)
Co-authored-by: Valentin Marchaud <[email protected]>
1 parent def9ba3 commit 9579106

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

karma.webpack.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = {
2222
target: 'web',
2323
output: { filename: 'bundle.js' },
2424
resolve: { extensions: ['.ts', '.js'] },
25-
devtool: 'inline-source-map',
25+
devtool: 'eval-source-map',
2626
module: {
2727
rules: [
2828
{ test: /\.ts$/, use: 'ts-loader' },

packages/opentelemetry-sdk-trace-base/test/common/Span.test.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,32 @@ import {
2121
SpanContext,
2222
SpanKind,
2323
TraceFlags,
24+
HrTime,
2425
} from '@opentelemetry/api';
2526
import {
2627
DEFAULT_ATTRIBUTE_COUNT_LIMIT,
2728
DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT,
28-
hrTime,
2929
hrTimeDuration,
3030
hrTimeToMilliseconds,
3131
hrTimeToNanoseconds,
32+
otperformance as performance,
3233
} from '@opentelemetry/core';
3334
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
3435
import * as assert from 'assert';
36+
import * as sinon from 'sinon';
3537
import { BasicTracerProvider, Span, SpanProcessor } from '../../src';
3638

37-
const performanceTimeOrigin = hrTime();
39+
const performanceTimeOrigin: HrTime = [1, 1];
3840

3941
describe('Span', () => {
42+
beforeEach(() => {
43+
sinon.stub(performance, 'timeOrigin')
44+
.value(hrTimeToMilliseconds(performanceTimeOrigin));
45+
});
46+
afterEach(() => {
47+
sinon.restore();
48+
});
49+
4050
const tracer = new BasicTracerProvider({
4151
spanLimits: {
4252
attributeValueLengthLimit: 100,

0 commit comments

Comments
 (0)