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

fix: remove require usages in esm build #2467

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
WebTracerProvider,
} from '@opentelemetry/sdk-trace-web';
import * as assert from 'assert';
import * as sinon from 'sinon';
import sinon from 'sinon';
import {
FetchInstrumentation,
FetchInstrumentationConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
context,
propagation,
Span as ISpan,
SpanKind,
SpanKind,
trace,
SpanAttributes,
} from '@opentelemetry/api';
Expand All @@ -31,8 +31,8 @@ import {
NetTransportValues,
SemanticAttributes,
} from '@opentelemetry/semantic-conventions';
import * as assert from 'assert';
import * as nock from 'nock';
import assert from 'assert';
import nock from 'nock';
import * as path from 'path';
import { HttpInstrumentation } from '../../src/http';
import { HttpInstrumentationConfig } from '../../src/types';
Expand Down Expand Up @@ -507,7 +507,7 @@ describe('HttpInstrumentation', () => {
hostname: 'localhost',
pathname: '/',
forceStatus: {
code: SpanStatusCode.ERROR,
code: SpanStatusCode.ERROR,
message: err.message,
},
component: 'http',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ instrumentation.enable();
instrumentation.disable();

import * as http from 'http';
import * as request from 'request-promise-native';
import request from 'request-promise-native';
import * as superagent from 'superagent';
import * as got from 'got';
import got from 'got';
import * as nock from 'nock';
import axios, { AxiosResponse } from 'axios';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
import * as assert from 'assert';
import * as fs from 'fs';
import * as semver from 'semver';
import * as nock from 'nock';
import nock from 'nock';
import * as path from 'path';
import { HttpInstrumentation } from '../../src/http';
import { assertSpan } from '../utils/assertSpan';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ instrumentation.enable();
instrumentation.disable();

import * as http from 'http';
import * as request from 'request-promise-native';
import request from 'request-promise-native';
import * as superagent from 'superagent';
import * as got from 'got';
import got from 'got';
import * as nock from 'nock';
import axios, { AxiosResponse } from 'axios';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
parseUrl,
} from '@opentelemetry/sdk-trace-web';
import * as assert from 'assert';
import * as sinon from 'sinon';
import sinon from 'sinon';
import { EventNames } from '../src/enums/EventNames';
import {
XMLHttpRequestInstrumentation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import * as types from '../../types';
import * as path from 'path';
import * as RequireInTheMiddle from 'require-in-the-middle';
import RequireInTheMiddle from 'require-in-the-middle';
import { satisfies } from 'semver';
import { InstrumentationAbstract } from '../../instrumentation';
import { InstrumentationModuleDefinition } from './types';
Expand Down Expand Up @@ -67,7 +67,7 @@ export abstract class InstrumentationBase<T = any>
} catch (error) {
diag.warn('Failed extracting version', baseDir);
}

return undefined;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { diag } from '@opentelemetry/api';
import * as api from '@opentelemetry/api-metrics';
import { InstrumentationLibrary } from '@opentelemetry/core';
import { Resource } from '@opentelemetry/resources';
import merge from 'lodash.merge';
import { BatchObserver } from './BatchObserver';
import { BaseBoundInstrument } from './BoundInstrument';
import { CounterMetric } from './CounterMetric';
Expand All @@ -31,8 +32,6 @@ import { UpDownCounterMetric } from './UpDownCounterMetric';
import { UpDownSumObserverMetric } from './UpDownSumObserverMetric';
import { ValueObserverMetric } from './ValueObserverMetric';
import { ValueRecorderMetric } from './ValueRecorderMetric';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const merge = require('lodash.merge');

/**
* Meter is an implementation of the {@link Meter} interface.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@

import * as api from '@opentelemetry/api-metrics';
import { Resource } from '@opentelemetry/resources';
import merge from 'lodash.merge';
import { Meter } from '.';
import { DEFAULT_CONFIG, MeterConfig } from './types';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const merge = require('lodash.merge');

/**
* This class represents a meter provider which platform libraries can extend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* limitations under the License.
*/

import * as assert from 'assert';
import assert from 'assert';
import { HistogramAggregator } from '../../../src/export/aggregators';
import { Histogram } from '../../../src';
import { hrTime, hrTimeToMilliseconds } from '@opentelemetry/core';
import sinon = require('sinon');
import sinon from 'sinon';

describe('HistogramAggregator', () => {
describe('constructor()', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import * as assert from 'assert';
import assert from 'assert';
import {
AsyncHooksContextManager,
AsyncLocalStorageContextManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import 'zone.js';
import * as sinon from 'sinon';
import * as assert from 'assert';
import assert from 'assert';
import { ZoneContextManager } from '../src';
import { ROOT_CONTEXT, createContextKey } from '@opentelemetry/api';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as assert from 'assert';
import assert from 'assert';
import * as api from '@opentelemetry/api';
import { AlwaysOffSampler } from '../../src/trace/sampler/AlwaysOffSampler';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
} from '@opentelemetry/exporter-collector';
import * as metrics from '@opentelemetry/sdk-metrics-base';
import * as assert from 'assert';
import * as http from 'http';
import http from 'http';
import * as sinon from 'sinon';
import { CollectorMetricExporter } from '../src';
import { getExportRequestProto } from '../src/util';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from '@opentelemetry/exporter-collector';
import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
import * as assert from 'assert';
import * as http from 'http';
import http from 'http';
import * as sinon from 'sinon';
import { Stream } from 'stream';
import * as zlib from 'zlib';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
MetricRecord,
} from '@opentelemetry/sdk-metrics-base';
import * as assert from 'assert';
import * as http from 'http';
import http from 'http';
import * as sinon from 'sinon';
import {
CollectorExporterNodeConfigBase,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { diag } from '@opentelemetry/api';
import * as core from '@opentelemetry/core';
import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
import * as http from 'http';
import http from 'http';
import * as assert from 'assert';
import * as sinon from 'sinon';
import { PassThrough, Stream } from 'stream';
Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
* limitations under the License.
*/

import * as assert from 'assert';
import assert from 'assert';
import { JaegerExporter } from '../src';
import { ExportResult, ExportResultCode } from '@opentelemetry/core';
import * as api from '@opentelemetry/api';
import { ThriftProcess } from '../src/types';
import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
import { TraceFlags } from '@opentelemetry/api';
import { Resource } from '@opentelemetry/resources';
import * as nock from 'nock';
import nock from 'nock';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';

describe('JaegerExporter', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as assert from 'assert';
import assert from 'assert';
import { PrometheusLabelsBatcher } from '../src/PrometheusLabelsBatcher';
import {
CounterMetric,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
ValueObserverMetric,
} from '@opentelemetry/sdk-metrics-base';
import { diag, DiagLogLevel } from '@opentelemetry/api';
import * as assert from 'assert';
import assert from 'assert';
import { Labels } from '@opentelemetry/api-metrics';
import { PrometheusSerializer } from '../src/PrometheusSerializer';
import { PrometheusLabelsBatcher } from '../src/PrometheusLabelsBatcher';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
loggingErrorHandler,
} from '@opentelemetry/core';
import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
import * as assert from 'assert';
import assert from 'assert';
import * as sinon from 'sinon';
import { ZipkinExporter } from '../../src';
import * as zipkinTypes from '../../src/types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import * as assert from 'assert';
import * as nock from 'nock';
import nock from 'nock';
Flarna marked this conversation as resolved.
Show resolved Hide resolved
import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
import {
ExportResult,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
TraceFlags,
} from '@opentelemetry/api';
import { suppressTracing } from '@opentelemetry/core';
import * as assert from 'assert';
import assert from 'assert';
import {
JaegerPropagator,
UBER_TRACE_ID_HEADER,
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-sdk-node/test/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import {
HOST_ADDRESS,
SECONDARY_HOST_ADDRESS,
} from 'gcp-metadata';
import * as nock from 'nock';
import nock from 'nock';
import * as semver from 'semver';
import * as Sinon from 'sinon';
import { NodeSDK } from '../src';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@ import {
getEnv,
} from '@opentelemetry/core';
import { Resource } from '@opentelemetry/resources';
import merge from 'lodash.merge';
import { SpanProcessor, Tracer } from '.';
import { DEFAULT_CONFIG } from './config';
import { MultiSpanProcessor } from './MultiSpanProcessor';
import { NoopSpanProcessor } from './export/NoopSpanProcessor';
import { SDKRegistrationConfig, TracerConfig } from './types';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const merge = require('lodash.merge');
import { SpanExporter } from './export/SpanExporter';
import { BatchSpanProcessor } from './platform';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
TraceState,
} from '@opentelemetry/core';
import { Resource } from '@opentelemetry/resources';
import * as assert from 'assert';
import assert from 'assert';
import * as sinon from 'sinon';
import {
BasicTracerProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
InstrumentationLibrary,
suppressTracing
} from '@opentelemetry/core';
import * as assert from 'assert';
import assert from 'assert';
import { BasicTracerProvider, Span, Tracer } from '../../src';
import { TestStackContextManager } from './export/TestStackContextManager';
import * as sinon from 'sinon';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { createContextKey, ROOT_CONTEXT } from '@opentelemetry/api';
import * as assert from 'assert';
import assert from 'assert';
import { StackContextManager } from '../src';

describe('StackContextManager', () => {
Expand Down
1 change: 1 addition & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"composite": true,
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"module": "commonjs",
"noEmitOnError": true,
Expand Down