Skip to content

Commit a72ca10

Browse files
authored
chore(otel-v2-tests): Fix formatting and linting errors (#16546)
turns out repo-wide auto formatting (`yarn fix:prettier` in the root) changed some files here causing unrelated changes in other PRs. Also I added lint and fix commands to this package.
1 parent 70a57e6 commit a72ca10

File tree

5 files changed

+44
-45
lines changed

5 files changed

+44
-45
lines changed

dev-packages/opentelemetry-v2-tests/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
"node": ">=18"
88
},
99
"scripts": {
10+
"lint": "eslint . --format stylish",
11+
"fix": "eslint . --format stylish --fix",
1012
"test": "vitest run",
1113
"test:watch": "vitest --watch"
1214
},

dev-packages/opentelemetry-v2-tests/test/helpers/isSpan.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Span } from '@opentelemetry/api';
2-
import { INVALID_TRACEID, INVALID_SPANID, type SpanContext } from '@opentelemetry/api';
2+
import { type SpanContext, INVALID_SPANID, INVALID_TRACEID } from '@opentelemetry/api';
33

44
export const isSpan = (value: unknown): value is Span => {
55
return (

dev-packages/opentelemetry-v2-tests/test/helpers/mockSdkInit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { BasicTracerProvider } from '@opentelemetry/sdk-trace-base';
33
import type { ClientOptions, Options } from '@sentry/core';
44
import { flush, getClient, getCurrentScope, getGlobalScope, getIsolationScope } from '@sentry/core';
55
import { setOpenTelemetryContextAsyncContextStrategy } from '../../../../packages/opentelemetry/src/asyncContextStrategy';
6+
import { SentrySpanProcessor } from '../../../../packages/opentelemetry/src/spanProcessor';
67
import type { OpenTelemetryClient } from '../../../../packages/opentelemetry/src/types';
78
import { clearOpenTelemetrySetupCheck } from '../../../../packages/opentelemetry/src/utils/setupCheck';
89
import { initOtel } from './initOtel';
910
import { init as initTestClient } from './TestClient';
10-
import { SentrySpanProcessor } from '../../../../packages/opentelemetry/src/spanProcessor';
1111

1212
const PUBLIC_DSN = 'https://username@domain/123';
1313

dev-packages/opentelemetry-v2-tests/test/integration/transactions.test.ts

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest';
1616
import { SENTRY_TRACE_STATE_DSC } from '../../../../packages/opentelemetry/src/constants';
1717
import { startInactiveSpan, startSpan } from '../../../../packages/opentelemetry/src/trace';
1818
import { makeTraceState } from '../../../../packages/opentelemetry/src/utils/makeTraceState';
19-
import { cleanupOtel, getProvider, getSpanProcessor, mockSdkInit } from '../helpers/mockSdkInit';
19+
import { cleanupOtel, getSpanProcessor, mockSdkInit } from '../helpers/mockSdkInit';
2020
import type { TestClientInterface } from '../helpers/TestClient';
2121

2222
describe('Integration | Transactions', () => {
@@ -514,7 +514,6 @@ describe('Integration | Transactions', () => {
514514
},
515515
});
516516

517-
const provider = getProvider();
518517
const spanProcessor = getSpanProcessor();
519518

520519
const exporter = spanProcessor ? spanProcessor['_exporter'] : undefined;
@@ -548,57 +547,56 @@ describe('Integration | Transactions', () => {
548547
expect(finishedSpans.length).toBe(0);
549548
});
550549

551-
it('collects child spans that are finished within 5 minutes their parent span has been sent', async () => {
552-
const timeout = 5 * 60 * 1000;
553-
const now = Date.now();
554-
vi.useFakeTimers();
555-
vi.setSystemTime(now);
550+
it('collects child spans that are finished within 5 minutes their parent span has been sent', async () => {
551+
const timeout = 5 * 60 * 1000;
552+
const now = Date.now();
553+
vi.useFakeTimers();
554+
vi.setSystemTime(now);
556555

557-
const logs: unknown[] = [];
558-
vi.spyOn(logger, 'log').mockImplementation(msg => logs.push(msg));
556+
const logs: unknown[] = [];
557+
vi.spyOn(logger, 'log').mockImplementation(msg => logs.push(msg));
559558

560-
const transactions: Event[] = [];
559+
const transactions: Event[] = [];
561560

562-
mockSdkInit({
563-
tracesSampleRate: 1,
564-
beforeSendTransaction: event => {
565-
transactions.push(event);
566-
return null;
567-
},
568-
});
561+
mockSdkInit({
562+
tracesSampleRate: 1,
563+
beforeSendTransaction: event => {
564+
transactions.push(event);
565+
return null;
566+
},
567+
});
569568

570-
const provider = getProvider();
571-
const spanProcessor = getSpanProcessor();
569+
const spanProcessor = getSpanProcessor();
572570

573-
const exporter = spanProcessor ? spanProcessor['_exporter'] : undefined;
571+
const exporter = spanProcessor ? spanProcessor['_exporter'] : undefined;
574572

575-
if (!exporter) {
576-
throw new Error('No exporter found, aborting test...');
577-
}
573+
if (!exporter) {
574+
throw new Error('No exporter found, aborting test...');
575+
}
578576

579-
startSpanManual({ name: 'test name' }, async span => {
580-
const subSpan = startInactiveSpan({ name: 'inner span 1' });
581-
subSpan.end();
577+
startSpanManual({ name: 'test name' }, async span => {
578+
const subSpan = startInactiveSpan({ name: 'inner span 1' });
579+
subSpan.end();
582580

583-
const subSpan2 = startInactiveSpan({ name: 'inner span 2' });
581+
const subSpan2 = startInactiveSpan({ name: 'inner span 2' });
584582

585-
span.end();
583+
span.end();
586584

587-
setTimeout(() => {
588-
subSpan2.end();
589-
}, timeout - 2);
590-
});
585+
setTimeout(() => {
586+
subSpan2.end();
587+
}, timeout - 2);
588+
});
591589

592-
vi.advanceTimersByTime(timeout - 1);
590+
vi.advanceTimersByTime(timeout - 1);
593591

594-
expect(transactions).toHaveLength(2);
595-
expect(transactions[0]?.spans).toHaveLength(1);
592+
expect(transactions).toHaveLength(2);
593+
expect(transactions[0]?.spans).toHaveLength(1);
596594

597-
const finishedSpans: any = exporter['_finishedSpanBuckets'].flatMap(bucket =>
598-
bucket ? Array.from(bucket.spans) : [],
599-
);
600-
expect(finishedSpans.length).toBe(0);
601-
});
595+
const finishedSpans: any = exporter['_finishedSpanBuckets'].flatMap(bucket =>
596+
bucket ? Array.from(bucket.spans) : [],
597+
);
598+
expect(finishedSpans.length).toBe(0);
599+
});
602600

603601
it('discards child spans that are finished after 5 minutes their parent span has been sent', async () => {
604602
const timeout = 5 * 60 * 1000;
@@ -619,7 +617,6 @@ it('collects child spans that are finished within 5 minutes their parent span ha
619617
},
620618
});
621619

622-
const provider = getProvider();
623620
const spanProcessor = getSpanProcessor();
624621

625622
const exporter = spanProcessor ? spanProcessor['_exporter'] : undefined;

dev-packages/opentelemetry-v2-tests/test/trace.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ import {
2828
} from '../../../packages/opentelemetry/src/trace';
2929
import type { AbstractSpan } from '../../../packages/opentelemetry/src/types';
3030
import { getActiveSpan } from '../../../packages/opentelemetry/src/utils/getActiveSpan';
31+
import { getParentSpanId } from '../../../packages/opentelemetry/src/utils/getParentSpanId';
3132
import { getSamplingDecision } from '../../../packages/opentelemetry/src/utils/getSamplingDecision';
3233
import { getSpanKind } from '../../../packages/opentelemetry/src/utils/getSpanKind';
3334
import { makeTraceState } from '../../../packages/opentelemetry/src/utils/makeTraceState';
3435
import { spanHasAttributes, spanHasName } from '../../../packages/opentelemetry/src/utils/spanTypes';
35-
import { cleanupOtel, mockSdkInit } from './helpers/mockSdkInit';
3636
import { isSpan } from './helpers/isSpan';
37-
import { getParentSpanId } from '../../../packages/opentelemetry/src/utils/getParentSpanId';
37+
import { cleanupOtel, mockSdkInit } from './helpers/mockSdkInit';
3838

3939
describe('trace', () => {
4040
beforeEach(() => {

0 commit comments

Comments
 (0)