From 663d92bfcd5aa0a3b6c6a8fa295dc5a667e10bb1 Mon Sep 17 00:00:00 2001 From: Chengzhong Wu Date: Wed, 26 Nov 2025 11:04:04 +0000 Subject: [PATCH 1/2] feat: apply rule @typescript-eslint/explicit-member-accessibility --- eslint.config.mjs | 19 +++++++++++++++++- .../src/baggage-log-record-processor.ts | 6 +++--- .../src/baggage-span-processor.ts | 8 ++++---- .../contrib-test-utils/src/test-fixtures.ts | 16 +++++++-------- packages/host-metrics/src/metric.ts | 2 +- .../platform/browser/AWSXRayIdGenerator.ts | 4 ++-- .../src/platform/node/AWSXRayIdGenerator.ts | 4 ++-- .../src/BaseOpenTelemetryComponent.ts | 8 ++++---- .../src/AWSXRayLambdaPropagator.ts | 6 +++--- .../src/AWSXRayPropagator.ts | 6 +++--- .../src/InstanaPropagator.ts | 6 +++--- .../src/OTTracePropagator.ts | 6 +++--- .../src/detectors/AlibabaCloudEcsDetector.ts | 12 +++++------ .../src/detectors/AwsBeanstalkDetector.ts | 6 +++--- .../src/detectors/AwsEc2Detector.ts | 18 ++++++++--------- .../src/detectors/AwsEcsDetector.ts | 8 ++++---- .../src/detectors/AwsEksDetector.ts | 20 +++++++++---------- .../src/detectors/AwsLambdaDetector.ts | 2 +- .../src/detectors/AzureAppServiceDetector.ts | 2 +- .../src/detectors/AzureFunctionsDetector.ts | 2 +- .../src/detectors/AzureVmDetector.ts | 4 ++-- .../src/detectors/ContainerDetector.ts | 18 +++++++---------- .../src/detectors/GcpDetector.ts | 2 +- .../src/detectors/GitHubDetector.ts | 2 +- .../src/detectors/InstanaAgentDetector.ts | 6 +++--- .../sampler-aws-xray/src/fallback-sampler.ts | 2 +- .../src/rate-limiting-sampler.ts | 2 +- .../src/sampling-rule-applier.ts | 2 +- 28 files changed, 106 insertions(+), 93 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 783a185ee1..4f551db492 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -156,6 +156,12 @@ const baseConfig = tseslint.config( '@typescript-eslint/no-empty-function': ['off'], '@typescript-eslint/no-shadow': ['warn'], 'prefer-rest-params': 'off', + '@typescript-eslint/explicit-member-accessibility': ['error', { + overrides: { + // `constructor` is public by default. + 'constructors': 'no-public', + }, + }], }, }, @@ -184,6 +190,7 @@ const baseConfig = tseslint.config( 'warn', { argsIgnorePattern: '^_' }, ], + '@typescript-eslint/explicit-member-accessibility': 'off', 'no-empty': 'off', }, }, @@ -213,7 +220,17 @@ const baseConfig = tseslint.config( Task: 'readonly', }, }, - } + }, + + // Gradual adoption of explicit-member-accessibility + { + files: [ + '**/packages/instrumentation-*/**', + ], + rules: { + '@typescript-eslint/explicit-member-accessibility': 'off', + }, + }, ); export default baseConfig; diff --git a/packages/baggage-log-record-processor/src/baggage-log-record-processor.ts b/packages/baggage-log-record-processor/src/baggage-log-record-processor.ts index d2f5022569..102ebc04d1 100644 --- a/packages/baggage-log-record-processor/src/baggage-log-record-processor.ts +++ b/packages/baggage-log-record-processor/src/baggage-log-record-processor.ts @@ -44,7 +44,7 @@ export class BaggageLogRecordProcessor implements LogRecordProcessor { /** * Forces to export all finished log records. */ - forceFlush(): Promise { + public forceFlush(): Promise { // no-op return Promise.resolve(); } @@ -54,7 +54,7 @@ export class BaggageLogRecordProcessor implements LogRecordProcessor { * @param logRecord the ReadWriteLogRecord that just emitted. * @param context the current Context, or an empty Context if the Logger was obtained with include_trace_context=false */ - onEmit(logRecord: SdkLogRecord, context?: Context): void { + public onEmit(logRecord: SdkLogRecord, context?: Context): void { if (context) { (propagation.getBaggage(context)?.getAllEntries() ?? []) .filter(entry => this._keyPredicate(entry[0])) @@ -66,7 +66,7 @@ export class BaggageLogRecordProcessor implements LogRecordProcessor { * Shuts down the processor. Called when SDK is shut down. This is an * opportunity for processor to do any cleanup required. */ - shutdown(): Promise { + public shutdown(): Promise { // no-op return Promise.resolve(); } diff --git a/packages/baggage-span-processor/src/baggage-span-processor.ts b/packages/baggage-span-processor/src/baggage-span-processor.ts index ddec06a20a..acb40f258f 100644 --- a/packages/baggage-span-processor/src/baggage-span-processor.ts +++ b/packages/baggage-span-processor/src/baggage-span-processor.ts @@ -57,7 +57,7 @@ export class BaggageSpanProcessor implements SpanProcessor { /** * Forces to export all finished spans */ - forceFlush(): Promise { + public forceFlush(): Promise { // no-op return Promise.resolve(); } @@ -67,7 +67,7 @@ export class BaggageSpanProcessor implements SpanProcessor { * returns true. * @param span the Span that just started. */ - onStart(span: Span, parentContext: Context): void { + public onStart(span: Span, parentContext: Context): void { (propagation.getBaggage(parentContext)?.getAllEntries() ?? []) .filter(entry => this._keyPredicate(entry[0])) .forEach(entry => span.setAttribute(entry[0], entry[1].value)); @@ -78,7 +78,7 @@ export class BaggageSpanProcessor implements SpanProcessor { * returns true. * @param span the Span that just ended. */ - onEnd(_: ReadableSpan): void { + public onEnd(_: ReadableSpan): void { // no-op } @@ -86,7 +86,7 @@ export class BaggageSpanProcessor implements SpanProcessor { * Shuts down the processor. Called when SDK is shut down. This is an * opportunity for processor to do any cleanup required. */ - shutdown(): Promise { + public shutdown(): Promise { // no-op return Promise.resolve(); } diff --git a/packages/contrib-test-utils/src/test-fixtures.ts b/packages/contrib-test-utils/src/test-fixtures.ts index c96c5927b5..666e4a25ca 100644 --- a/packages/contrib-test-utils/src/test-fixtures.ts +++ b/packages/contrib-test-utils/src/test-fixtures.ts @@ -67,8 +67,8 @@ export type TestSpan = ISpan & { * There is little error checking here; we are assuming valid OTLP. */ export class TestCollector { - endpointUrl?: string; - spans: Array = []; + public endpointUrl?: string; + public spans: Array = []; private _http; constructor() { @@ -76,12 +76,12 @@ export class TestCollector { this._http = createServer(this._onRequest.bind(this)); } - clear(): void { + public clear(): void { this.spans = []; } // Start listening and set address to `endpointUrl`. - async start(): Promise { + public async start(): Promise { return new Promise(resolve => { this._http.listen(() => { this.endpointUrl = `http://localhost:${ @@ -92,7 +92,7 @@ export class TestCollector { }); } - close() { + public close() { this.endpointUrl = undefined; return this._http.close(); } @@ -106,7 +106,7 @@ export class TestCollector { * same, this attempts to get the correct ordering using `parentSpanId` -- a * parent span starts before any of its direct children. This isn't perfect. */ - get sortedSpans(): Array { + public get sortedSpans(): Array { return this.spans.slice().sort((a, b) => { assert(typeof a.startTimeUnixNano === 'string'); assert(typeof b.startTimeUnixNano === 'string'); @@ -132,7 +132,7 @@ export class TestCollector { }); } - _onRequest(req: IncomingMessage, res: ServerResponse) { + private _onRequest(req: IncomingMessage, res: ServerResponse) { const parsedUrl = new URL(req.url as string, this.endpointUrl); let instream: EventEmitter; if (req.headers['content-encoding'] === 'gzip') { @@ -171,7 +171,7 @@ export class TestCollector { }); } - _ingestTraces(body: string) { + private _ingestTraces(body: string) { const data = JSON.parse(body); // Read an OTLP `resourceSpans` body into `this.spans`. for (const resourceSpan of data.resourceSpans) { diff --git a/packages/host-metrics/src/metric.ts b/packages/host-metrics/src/metric.ts index 0a37ab09dc..b424180615 100644 --- a/packages/host-metrics/src/metric.ts +++ b/packages/host-metrics/src/metric.ts @@ -334,7 +334,7 @@ export class HostMetrics extends BaseMetrics { /** * Starts collecting metrics */ - start() { + public start() { this._createMetrics(); } diff --git a/packages/id-generator-aws-xray/src/platform/browser/AWSXRayIdGenerator.ts b/packages/id-generator-aws-xray/src/platform/browser/AWSXRayIdGenerator.ts index e8892e1912..c6128124df 100644 --- a/packages/id-generator-aws-xray/src/platform/browser/AWSXRayIdGenerator.ts +++ b/packages/id-generator-aws-xray/src/platform/browser/AWSXRayIdGenerator.ts @@ -32,7 +32,7 @@ export class AWSXRayIdGenerator implements IdGenerator { * characters corresponding to 128 bits. The first 4 bytes correspond to the current * time, in seconds, as per X-Ray trace ID format. */ - generateTraceId(): string { + public generateTraceId(): string { return generateTraceId(generateRandomBytes); } @@ -40,7 +40,7 @@ export class AWSXRayIdGenerator implements IdGenerator { * Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex * characters corresponding to 64 bits. */ - generateSpanId(): string { + public generateSpanId(): string { return generateSpanId(generateRandomBytes); } } diff --git a/packages/id-generator-aws-xray/src/platform/node/AWSXRayIdGenerator.ts b/packages/id-generator-aws-xray/src/platform/node/AWSXRayIdGenerator.ts index 3f768748e2..40f7b4a442 100644 --- a/packages/id-generator-aws-xray/src/platform/node/AWSXRayIdGenerator.ts +++ b/packages/id-generator-aws-xray/src/platform/node/AWSXRayIdGenerator.ts @@ -32,7 +32,7 @@ export class AWSXRayIdGenerator implements IdGenerator { * characters corresponding to 128 bits. The first 4 bytes correspond to the current * time, in seconds, as per X-Ray trace ID format. */ - generateTraceId(): string { + public generateTraceId(): string { return generateTraceId(generateRandomBytes); } @@ -40,7 +40,7 @@ export class AWSXRayIdGenerator implements IdGenerator { * Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex * characters corresponding to 64 bits. */ - generateSpanId(): string { + public generateSpanId(): string { return generateSpanId(generateRandomBytes); } } diff --git a/packages/plugin-react-load/src/BaseOpenTelemetryComponent.ts b/packages/plugin-react-load/src/BaseOpenTelemetryComponent.ts index 2c5a5c9ba7..bb9c3fba99 100644 --- a/packages/plugin-react-load/src/BaseOpenTelemetryComponent.ts +++ b/packages/plugin-react-load/src/BaseOpenTelemetryComponent.ts @@ -36,8 +36,8 @@ import { * This class is the base component for a React component with lifecycle instrumentation */ export class BaseOpenTelemetryComponent extends React.Component { - readonly component: string = 'react-load'; - moduleName = this.component; + private readonly component: string = 'react-load'; + private moduleName = this.component; private _parentSpanMap: WeakMap; private static _tracer: api.Tracer; private static _logger: api.DiagLogger = api.diag; @@ -56,7 +56,7 @@ export class BaseOpenTelemetryComponent extends React.Component { * @param name Name of tracer * @param version Version of tracer, this is optional. When not provided it will use the latest. */ - static setTracer(name: string, version?: string): void { + public static setTracer(name: string, version?: string): void { BaseOpenTelemetryComponent._tracer = api.trace.getTracer( name, version ? version : PACKAGE_VERSION @@ -67,7 +67,7 @@ export class BaseOpenTelemetryComponent extends React.Component { * Sets the logger for all components being instrumented * @param logger */ - static setLogger(logger: api.DiagLogger): void { + public static setLogger(logger: api.DiagLogger): void { api.diag.setLogger(logger); BaseOpenTelemetryComponent._logger = logger; } diff --git a/packages/propagator-aws-xray-lambda/src/AWSXRayLambdaPropagator.ts b/packages/propagator-aws-xray-lambda/src/AWSXRayLambdaPropagator.ts index 51d7ca4889..bee3014f53 100644 --- a/packages/propagator-aws-xray-lambda/src/AWSXRayLambdaPropagator.ts +++ b/packages/propagator-aws-xray-lambda/src/AWSXRayLambdaPropagator.ts @@ -40,11 +40,11 @@ export const AWSXRAY_TRACE_ID_ENV_VAR = '_X_AMZN_TRACE_ID'; export class AWSXRayLambdaPropagator implements TextMapPropagator { private _awsXrayPropagator = new AWSXRayPropagator(); - inject(context: Context, carrier: unknown, setter: TextMapSetter) { + public inject(context: Context, carrier: unknown, setter: TextMapSetter) { this._awsXrayPropagator.inject(context, carrier, setter); } - extract(context: Context, carrier: unknown, getter: TextMapGetter): Context { + public extract(context: Context, carrier: unknown, getter: TextMapGetter): Context { const xrayContext = this._awsXrayPropagator.extract( context, carrier, @@ -68,7 +68,7 @@ export class AWSXRayLambdaPropagator implements TextMapPropagator { ); } - fields(): string[] { + public fields(): string[] { return this._awsXrayPropagator.fields(); } } diff --git a/packages/propagator-aws-xray/src/AWSXRayPropagator.ts b/packages/propagator-aws-xray/src/AWSXRayPropagator.ts index a0def93418..a73ee7e75e 100644 --- a/packages/propagator-aws-xray/src/AWSXRayPropagator.ts +++ b/packages/propagator-aws-xray/src/AWSXRayPropagator.ts @@ -58,7 +58,7 @@ const NOT_SAMPLED = '0'; * X-Amzn-Trace-Id: Root=1-5759e988-bd862e3fe1be46a994272793;Parent=53995c3f42cd8ad8;Sampled=1 */ export class AWSXRayPropagator implements TextMapPropagator { - inject(context: Context, carrier: unknown, setter: TextMapSetter) { + public inject(context: Context, carrier: unknown, setter: TextMapSetter) { const spanContext = trace.getSpan(context)?.spanContext(); if (!spanContext || !isSpanContextValid(spanContext)) return; @@ -77,7 +77,7 @@ export class AWSXRayPropagator implements TextMapPropagator { setter.set(carrier, AWSXRAY_TRACE_ID_HEADER, traceHeader); } - extract(context: Context, carrier: unknown, getter: TextMapGetter): Context { + public extract(context: Context, carrier: unknown, getter: TextMapGetter): Context { const spanContext = this.getSpanContextFromHeader(carrier, getter); if (!isSpanContextValid(spanContext)) return context; @@ -90,7 +90,7 @@ export class AWSXRayPropagator implements TextMapPropagator { return trace.setSpan(context, trace.wrapSpanContext(spanContext)); } - fields(): string[] { + public fields(): string[] { return [AWSXRAY_TRACE_ID_HEADER]; } diff --git a/packages/propagator-instana/src/InstanaPropagator.ts b/packages/propagator-instana/src/InstanaPropagator.ts index 29ec3b152e..1cd455a2e4 100644 --- a/packages/propagator-instana/src/InstanaPropagator.ts +++ b/packages/propagator-instana/src/InstanaPropagator.ts @@ -61,7 +61,7 @@ export class InstanaPropagator implements TextMapPropagator { * Injects the current span context into Instana's vendor specific trace correlation headers (X-INSTANA-T, X-INSTANA-S * and X-INSTANA-L). */ - inject(context: Context, carrier: unknown, setter: TextMapSetter) { + public inject(context: Context, carrier: unknown, setter: TextMapSetter) { const spanContext = trace.getSpan(context)?.spanContext(); if (!spanContext || !isSpanContextValid(spanContext)) { return; @@ -78,7 +78,7 @@ export class InstanaPropagator implements TextMapPropagator { * Extracts the span context from Instana's vendor specific trace correlation headers (X-INSTANA-T, X-INSTANA-S * and X-INSTANA-L). */ - extract(context: Context, carrier: unknown, getter: TextMapGetter): Context { + public extract(context: Context, carrier: unknown, getter: TextMapGetter): Context { let traceId = readHeader(carrier, getter, INSTANA_TRACE_ID_HEADER); if (traceId && traceId.length < 32) { traceId = traceId.padStart(32, '0'); @@ -119,7 +119,7 @@ export class InstanaPropagator implements TextMapPropagator { return context; } - fields(): string[] { + public fields(): string[] { return FIELDS.slice(); } } diff --git a/packages/propagator-ot-trace/src/OTTracePropagator.ts b/packages/propagator-ot-trace/src/OTTracePropagator.ts index 362c2bddba..56e161a1a3 100644 --- a/packages/propagator-ot-trace/src/OTTracePropagator.ts +++ b/packages/propagator-ot-trace/src/OTTracePropagator.ts @@ -63,7 +63,7 @@ function isValidHeaderValue(value: string): boolean { * Propagator for the ot-trace HTTP format from OpenTracing. */ export class OTTracePropagator implements TextMapPropagator { - inject(context: Context, carrier: unknown, setter: TextMapSetter) { + public inject(context: Context, carrier: unknown, setter: TextMapSetter) { const spanContext = trace.getSpan(context)?.spanContext(); if (!spanContext || !isSpanContextValid(spanContext)) return; @@ -85,7 +85,7 @@ export class OTTracePropagator implements TextMapPropagator { }); } - extract(context: Context, carrier: unknown, getter: TextMapGetter): Context { + public extract(context: Context, carrier: unknown, getter: TextMapGetter): Context { let traceId = readHeader(carrier, getter, OT_TRACE_ID_HEADER); if (traceId.length === 16) traceId = `${PADDING}${traceId}`; const spanId = readHeader(carrier, getter, OT_SPAN_ID_HEADER); @@ -128,7 +128,7 @@ export class OTTracePropagator implements TextMapPropagator { * carrier instance. Attempting to reuse a carrier by clearing fields could * result in a memory leak. */ - fields(): string[] { + public fields(): string[] { return FIELDS.slice(); } } diff --git a/packages/resource-detector-alibaba-cloud/src/detectors/AlibabaCloudEcsDetector.ts b/packages/resource-detector-alibaba-cloud/src/detectors/AlibabaCloudEcsDetector.ts index 398be96038..2634b9a37a 100644 --- a/packages/resource-detector-alibaba-cloud/src/detectors/AlibabaCloudEcsDetector.ts +++ b/packages/resource-detector-alibaba-cloud/src/detectors/AlibabaCloudEcsDetector.ts @@ -46,12 +46,12 @@ class AlibabaCloudEcsDetector implements ResourceDetector { * See https://www.alibabacloud.com/help/doc-detail/67254.htm for * documentation about the AlibabaCloud instance identity document. */ - readonly ALIBABA_CLOUD_IDMS_ENDPOINT = '100.100.100.200'; - readonly ALIBABA_CLOUD_INSTANCE_IDENTITY_DOCUMENT_PATH = + public readonly ALIBABA_CLOUD_IDMS_ENDPOINT = '100.100.100.200'; + public readonly ALIBABA_CLOUD_INSTANCE_IDENTITY_DOCUMENT_PATH = '/latest/dynamic/instance-identity/document'; - readonly ALIBABA_CLOUD_INSTANCE_HOST_DOCUMENT_PATH = + public readonly ALIBABA_CLOUD_INSTANCE_HOST_DOCUMENT_PATH = '/latest/meta-data/hostname'; - readonly MILLISECONDS_TIME_OUT = 1000; + public readonly MILLISECONDS_TIME_OUT = 1000; /** * Attempts to connect and obtain an AlibabaCloud instance Identity document. @@ -60,7 +60,7 @@ class AlibabaCloudEcsDetector implements ResourceDetector { * * @param config (unused) The resource detection config */ - detect(): DetectedResource { + public detect(): DetectedResource { const dataPromise = context.with(suppressTracing(context.active()), () => this._gatherData() ); @@ -86,7 +86,7 @@ class AlibabaCloudEcsDetector implements ResourceDetector { } /** Gets identity and host info and returns them as attribs. Empty object if fails */ - async _gatherData(): Promise { + private async _gatherData(): Promise { try { const { 'owner-account-id': accountId, diff --git a/packages/resource-detector-aws/src/detectors/AwsBeanstalkDetector.ts b/packages/resource-detector-aws/src/detectors/AwsBeanstalkDetector.ts index f3c19a5f52..26857d6045 100644 --- a/packages/resource-detector-aws/src/detectors/AwsBeanstalkDetector.ts +++ b/packages/resource-detector-aws/src/detectors/AwsBeanstalkDetector.ts @@ -52,7 +52,7 @@ const WIN_OS_BEANSTALK_CONF_PATH = 'C:\\Program Files\\Amazon\\XRay\\environment.conf'; export class AwsBeanstalkDetector implements ResourceDetector { - BEANSTALK_CONF_PATH: string; + private BEANSTALK_CONF_PATH: string; private static readFileAsync = util.promisify(fs.readFile); private static fileAccessAsync = util.promisify(fs.access); @@ -64,7 +64,7 @@ export class AwsBeanstalkDetector implements ResourceDetector { } } - detect(): DetectedResource { + public detect(): DetectedResource { const dataPromise = context.with(suppressTracing(context.active()), () => this._gatherData() ); @@ -89,7 +89,7 @@ export class AwsBeanstalkDetector implements ResourceDetector { /** * Async resource attributes for AWS Beanstalk configuration read from file. */ - async _gatherData(): Promise { + private async _gatherData(): Promise { try { await AwsBeanstalkDetector.fileAccessAsync( this.BEANSTALK_CONF_PATH, diff --git a/packages/resource-detector-aws/src/detectors/AwsEc2Detector.ts b/packages/resource-detector-aws/src/detectors/AwsEc2Detector.ts index 66cb20262b..56617bdcf9 100644 --- a/packages/resource-detector-aws/src/detectors/AwsEc2Detector.ts +++ b/packages/resource-detector-aws/src/detectors/AwsEc2Detector.ts @@ -45,16 +45,16 @@ class AwsEc2Detector implements ResourceDetector { * for documentation about the AWS instance identity document * and standard of IMDSv2. */ - readonly AWS_IDMS_ENDPOINT = '169.254.169.254'; - readonly AWS_INSTANCE_TOKEN_DOCUMENT_PATH = '/latest/api/token'; - readonly AWS_INSTANCE_IDENTITY_DOCUMENT_PATH = + public readonly AWS_IDMS_ENDPOINT = '169.254.169.254'; + public readonly AWS_INSTANCE_TOKEN_DOCUMENT_PATH = '/latest/api/token'; + public readonly AWS_INSTANCE_IDENTITY_DOCUMENT_PATH = '/latest/dynamic/instance-identity/document'; - readonly AWS_INSTANCE_HOST_DOCUMENT_PATH = '/latest/meta-data/hostname'; - readonly AWS_METADATA_TTL_HEADER = 'X-aws-ec2-metadata-token-ttl-seconds'; - readonly AWS_METADATA_TOKEN_HEADER = 'X-aws-ec2-metadata-token'; - readonly MILLISECOND_TIME_OUT = 5000; + public readonly AWS_INSTANCE_HOST_DOCUMENT_PATH = '/latest/meta-data/hostname'; + public readonly AWS_METADATA_TTL_HEADER = 'X-aws-ec2-metadata-token-ttl-seconds'; + public readonly AWS_METADATA_TOKEN_HEADER = 'X-aws-ec2-metadata-token'; + public readonly MILLISECOND_TIME_OUT = 5000; - detect(): DetectedResource { + public detect(): DetectedResource { const dataPromise = context.with(suppressTracing(context.active()), () => this._gatherData() ); @@ -82,7 +82,7 @@ class AwsEc2Detector implements ResourceDetector { /** * Attempts to connect and obtain an AWS instance Identity document. */ - async _gatherData(): Promise { + private async _gatherData(): Promise { try { const token = await this._fetchToken(); const { accountId, instanceId, instanceType, region, availabilityZone } = diff --git a/packages/resource-detector-aws/src/detectors/AwsEcsDetector.ts b/packages/resource-detector-aws/src/detectors/AwsEcsDetector.ts index 971488adb7..4f0f9dc405 100644 --- a/packages/resource-detector-aws/src/detectors/AwsEcsDetector.ts +++ b/packages/resource-detector-aws/src/detectors/AwsEcsDetector.ts @@ -62,13 +62,13 @@ interface AwsLogOptions { * plugins of AWS X-Ray. Returns an empty Resource if detection fails. */ export class AwsEcsDetector implements ResourceDetector { - static readonly CONTAINER_ID_LENGTH = 64; - static readonly CONTAINER_ID_LENGTH_MIN = 32; - static readonly DEFAULT_CGROUP_PATH = '/proc/self/cgroup'; + private static readonly CONTAINER_ID_LENGTH = 64; + private static readonly CONTAINER_ID_LENGTH_MIN = 32; + private static readonly DEFAULT_CGROUP_PATH = '/proc/self/cgroup'; private static readFileAsync = util.promisify(fs.readFile); - detect(): DetectedResource { + public detect(): DetectedResource { const attributes = context.with(suppressTracing(context.active()), () => this._getAttributes() ); diff --git a/packages/resource-detector-aws/src/detectors/AwsEksDetector.ts b/packages/resource-detector-aws/src/detectors/AwsEksDetector.ts index 5e289c7470..520320d7aa 100644 --- a/packages/resource-detector-aws/src/detectors/AwsEksDetector.ts +++ b/packages/resource-detector-aws/src/detectors/AwsEksDetector.ts @@ -44,24 +44,24 @@ import { diag } from '@opentelemetry/api'; */ export class AwsEksDetector implements ResourceDetector { - readonly K8S_SVC_URL = 'kubernetes.default.svc'; - readonly K8S_TOKEN_PATH = + public readonly K8S_SVC_URL = 'kubernetes.default.svc'; + public readonly K8S_TOKEN_PATH = '/var/run/secrets/kubernetes.io/serviceaccount/token'; - readonly K8S_CERT_PATH = + public readonly K8S_CERT_PATH = '/var/run/secrets/kubernetes.io/serviceaccount/ca.crt'; - readonly AUTH_CONFIGMAP_PATH = + public readonly AUTH_CONFIGMAP_PATH = '/api/v1/namespaces/kube-system/configmaps/aws-auth'; - readonly CW_CONFIGMAP_PATH = + public readonly CW_CONFIGMAP_PATH = '/api/v1/namespaces/amazon-cloudwatch/configmaps/cluster-info'; - readonly CONTAINER_ID_LENGTH = 64; - readonly DEFAULT_CGROUP_PATH = '/proc/self/cgroup'; - readonly TIMEOUT_MS = 2000; - readonly UTF8_UNICODE = 'utf8'; + public readonly CONTAINER_ID_LENGTH = 64; + public readonly DEFAULT_CGROUP_PATH = '/proc/self/cgroup'; + public readonly TIMEOUT_MS = 2000; + public readonly UTF8_UNICODE = 'utf8'; private static readFileAsync = util.promisify(fs.readFile); private static fileAccessAsync = util.promisify(fs.access); - detect(): DetectedResource { + public detect(): DetectedResource { const dataPromise = context.with(suppressTracing(context.active()), () => this._gatherData() ); diff --git a/packages/resource-detector-aws/src/detectors/AwsLambdaDetector.ts b/packages/resource-detector-aws/src/detectors/AwsLambdaDetector.ts index 2a96aa963a..f3819770ce 100644 --- a/packages/resource-detector-aws/src/detectors/AwsLambdaDetector.ts +++ b/packages/resource-detector-aws/src/detectors/AwsLambdaDetector.ts @@ -38,7 +38,7 @@ import { * Returns an empty Resource if detection fails. */ export class AwsLambdaDetector implements ResourceDetector { - detect(): DetectedResource { + public detect(): DetectedResource { // Check if running inside AWS Lambda environment const executionEnv = process.env.AWS_EXECUTION_ENV; if (!executionEnv?.startsWith('AWS_Lambda_')) { diff --git a/packages/resource-detector-azure/src/detectors/AzureAppServiceDetector.ts b/packages/resource-detector-azure/src/detectors/AzureAppServiceDetector.ts index ea32b99b0c..4e1d06ef63 100644 --- a/packages/resource-detector-azure/src/detectors/AzureAppServiceDetector.ts +++ b/packages/resource-detector-azure/src/detectors/AzureAppServiceDetector.ts @@ -51,7 +51,7 @@ const APP_SERVICE_ATTRIBUTE_ENV_VARS = { * @returns a {@link Resource} populated with data about the environment or an empty Resource if detection fails. */ class AzureAppServiceDetector implements ResourceDetector { - detect(): DetectedResource { + public detect(): DetectedResource { let attributes = {}; const websiteSiteName = process.env[WEBSITE_SITE_NAME]; if (websiteSiteName && !isAzureFunction()) { diff --git a/packages/resource-detector-azure/src/detectors/AzureFunctionsDetector.ts b/packages/resource-detector-azure/src/detectors/AzureFunctionsDetector.ts index 545391672f..8929d02b20 100644 --- a/packages/resource-detector-azure/src/detectors/AzureFunctionsDetector.ts +++ b/packages/resource-detector-azure/src/detectors/AzureFunctionsDetector.ts @@ -46,7 +46,7 @@ const AZURE_FUNCTIONS_ATTRIBUTE_ENV_VARS = { * @returns a {@link Resource} populated with data about the environment or an empty Resource if detection fails. */ class AzureFunctionsDetector implements ResourceDetector { - detect(): DetectedResource { + public detect(): DetectedResource { let attributes = {}; const serviceName = process.env[WEBSITE_SITE_NAME]; diff --git a/packages/resource-detector-azure/src/detectors/AzureVmDetector.ts b/packages/resource-detector-azure/src/detectors/AzureVmDetector.ts index 456caf05d1..a138ab43f6 100644 --- a/packages/resource-detector-azure/src/detectors/AzureVmDetector.ts +++ b/packages/resource-detector-azure/src/detectors/AzureVmDetector.ts @@ -48,7 +48,7 @@ import { * @returns a {@link Resource} populated with data about the environment or an empty Resource if detection fails. */ class AzureVmResourceDetector implements ResourceDetector { - detect(): DetectedResource { + public detect(): DetectedResource { const dataPromise = context.with(suppressTracing(context.active()), () => this.getAzureVmMetadata() ); @@ -75,7 +75,7 @@ class AzureVmResourceDetector implements ResourceDetector { return { attributes }; } - async getAzureVmMetadata(): Promise { + private async getAzureVmMetadata(): Promise { try { const options = { host: AZURE_VM_METADATA_HOST, diff --git a/packages/resource-detector-container/src/detectors/ContainerDetector.ts b/packages/resource-detector-container/src/detectors/ContainerDetector.ts index a17dc69575..6bf765d0e1 100644 --- a/packages/resource-detector-container/src/detectors/ContainerDetector.ts +++ b/packages/resource-detector-container/src/detectors/ContainerDetector.ts @@ -24,20 +24,16 @@ import { extractContainerIdFromLine } from './utils'; import { ATTR_CONTAINER_ID } from '../semconv'; export class ContainerDetector implements ResourceDetector { - readonly CONTAINER_ID_LENGTH = 64; - readonly DEFAULT_CGROUP_V1_PATH = '/proc/self/cgroup'; - readonly DEFAULT_CGROUP_V2_PATH = '/proc/self/mountinfo'; - readonly UTF8_UNICODE = 'utf8'; - readonly HOSTNAME = 'hostname'; - readonly MARKING_PREFIX = ['containers', 'overlay-containers']; - readonly CRIO = 'crio-'; - readonly CRI_CONTAINERD = 'cri-containerd-'; - readonly DOCKER = 'docker-'; - readonly HEX_STRING_REGEX: RegExp = /^[a-f0-9]+$/i; + private readonly CONTAINER_ID_LENGTH = 64; + private readonly DEFAULT_CGROUP_V1_PATH = '/proc/self/cgroup'; + private readonly DEFAULT_CGROUP_V2_PATH = '/proc/self/mountinfo'; + private readonly UTF8_UNICODE = 'utf8'; + private readonly HOSTNAME = 'hostname'; + private readonly MARKING_PREFIX = ['containers', 'overlay-containers']; private static readFileAsync = util.promisify(fs.readFile); - detect(): DetectedResource { + public detect(): DetectedResource { const attributes = { [ATTR_CONTAINER_ID]: this._getContainerIdWithSuppressedTracing(), }; diff --git a/packages/resource-detector-gcp/src/detectors/GcpDetector.ts b/packages/resource-detector-gcp/src/detectors/GcpDetector.ts index a5258a4fc3..57aad8e922 100644 --- a/packages/resource-detector-gcp/src/detectors/GcpDetector.ts +++ b/packages/resource-detector-gcp/src/detectors/GcpDetector.ts @@ -216,7 +216,7 @@ export class GcpDetector implements ResourceDetector { return resource.attributes; } - detect(): DetectedResource { + public detect(): DetectedResource { const asyncAttributes = this._asyncAttributes(); const attributes = {} as DetectedResourceAttributes; ATTRIBUTE_NAMES.forEach(name => { diff --git a/packages/resource-detector-github/src/detectors/GitHubDetector.ts b/packages/resource-detector-github/src/detectors/GitHubDetector.ts index d78611b67c..ae71f8b5d6 100644 --- a/packages/resource-detector-github/src/detectors/GitHubDetector.ts +++ b/packages/resource-detector-github/src/detectors/GitHubDetector.ts @@ -25,7 +25,7 @@ import { ResourceDetector, DetectedResource } from '@opentelemetry/resources'; * https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables */ class GitHubDetector implements ResourceDetector { - detect(): DetectedResource { + public detect(): DetectedResource { const attributes = { 'github.workflow': process.env.GITHUB_WORKFLOW || undefined, 'github.run_id': process.env.GITHUB_RUN_ID || undefined, diff --git a/packages/resource-detector-instana/src/detectors/InstanaAgentDetector.ts b/packages/resource-detector-instana/src/detectors/InstanaAgentDetector.ts index 9f839fb56a..82f2e280f2 100644 --- a/packages/resource-detector-instana/src/detectors/InstanaAgentDetector.ts +++ b/packages/resource-detector-instana/src/detectors/InstanaAgentDetector.ts @@ -25,10 +25,10 @@ import { ATTR_PROCESS_PID, ATTR_SERVICE_INSTANCE_ID } from '../semconv'; import * as http from 'http'; class InstanaAgentDetector implements ResourceDetector { - readonly INSTANA_AGENT_DEFAULT_HOST = 'localhost'; - readonly INSTANA_AGENT_DEFAULT_PORT = 42699; + private readonly INSTANA_AGENT_DEFAULT_HOST = 'localhost'; + private readonly INSTANA_AGENT_DEFAULT_PORT = 42699; - detect(): DetectedResource { + public detect(): DetectedResource { const dataPromise = context.with(suppressTracing(context.active()), () => this._gatherData() ); diff --git a/packages/sampler-aws-xray/src/fallback-sampler.ts b/packages/sampler-aws-xray/src/fallback-sampler.ts index 11aabd0ac7..77fe4d2b18 100644 --- a/packages/sampler-aws-xray/src/fallback-sampler.ts +++ b/packages/sampler-aws-xray/src/fallback-sampler.ts @@ -37,7 +37,7 @@ export class FallbackSampler implements Sampler { this.rateLimitingSampler = new RateLimitingSampler(quota); } - shouldSample( + public shouldSample( context: Context, traceId: string, spanName: string, diff --git a/packages/sampler-aws-xray/src/rate-limiting-sampler.ts b/packages/sampler-aws-xray/src/rate-limiting-sampler.ts index c384ced22e..e8689f9cf4 100644 --- a/packages/sampler-aws-xray/src/rate-limiting-sampler.ts +++ b/packages/sampler-aws-xray/src/rate-limiting-sampler.ts @@ -35,7 +35,7 @@ export class RateLimitingSampler implements Sampler { this.reservoir = new RateLimiter(quota); } - shouldSample( + public shouldSample( context: Context, traceId: string, spanName: string, diff --git a/packages/sampler-aws-xray/src/sampling-rule-applier.ts b/packages/sampler-aws-xray/src/sampling-rule-applier.ts index cf75ad9cdf..f759375c22 100644 --- a/packages/sampler-aws-xray/src/sampling-rule-applier.ts +++ b/packages/sampler-aws-xray/src/sampling-rule-applier.ts @@ -187,7 +187,7 @@ export class SamplingRuleApplier { ); } - shouldSample( + public shouldSample( context: Context, traceId: string, spanName: string, From 89b76502887aca73dda2636ba4e599f971025864 Mon Sep 17 00:00:00 2001 From: Chengzhong Wu Date: Thu, 4 Dec 2025 14:10:10 +0000 Subject: [PATCH 2/2] fixup! feat: apply rule @typescript-eslint/explicit-member-accessibility --- .../src/BaseOpenTelemetryComponent.ts | 4 ++-- .../src/detectors/AwsBeanstalkDetector.ts | 2 +- .../src/detectors/AwsEcsDetector.ts | 6 +++--- .../src/detectors/AzureVmDetector.ts | 2 +- .../src/detectors/ContainerDetector.ts | 12 ++++++------ .../src/detectors/InstanaAgentDetector.ts | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/plugin-react-load/src/BaseOpenTelemetryComponent.ts b/packages/plugin-react-load/src/BaseOpenTelemetryComponent.ts index bb9c3fba99..07bbe6f573 100644 --- a/packages/plugin-react-load/src/BaseOpenTelemetryComponent.ts +++ b/packages/plugin-react-load/src/BaseOpenTelemetryComponent.ts @@ -36,8 +36,8 @@ import { * This class is the base component for a React component with lifecycle instrumentation */ export class BaseOpenTelemetryComponent extends React.Component { - private readonly component: string = 'react-load'; - private moduleName = this.component; + public readonly component: string = 'react-load'; + public moduleName = this.component; private _parentSpanMap: WeakMap; private static _tracer: api.Tracer; private static _logger: api.DiagLogger = api.diag; diff --git a/packages/resource-detector-aws/src/detectors/AwsBeanstalkDetector.ts b/packages/resource-detector-aws/src/detectors/AwsBeanstalkDetector.ts index 26857d6045..f7d2d2b4b6 100644 --- a/packages/resource-detector-aws/src/detectors/AwsBeanstalkDetector.ts +++ b/packages/resource-detector-aws/src/detectors/AwsBeanstalkDetector.ts @@ -52,7 +52,7 @@ const WIN_OS_BEANSTALK_CONF_PATH = 'C:\\Program Files\\Amazon\\XRay\\environment.conf'; export class AwsBeanstalkDetector implements ResourceDetector { - private BEANSTALK_CONF_PATH: string; + public BEANSTALK_CONF_PATH: string; private static readFileAsync = util.promisify(fs.readFile); private static fileAccessAsync = util.promisify(fs.access); diff --git a/packages/resource-detector-aws/src/detectors/AwsEcsDetector.ts b/packages/resource-detector-aws/src/detectors/AwsEcsDetector.ts index 4f0f9dc405..dccd64eb2d 100644 --- a/packages/resource-detector-aws/src/detectors/AwsEcsDetector.ts +++ b/packages/resource-detector-aws/src/detectors/AwsEcsDetector.ts @@ -62,9 +62,9 @@ interface AwsLogOptions { * plugins of AWS X-Ray. Returns an empty Resource if detection fails. */ export class AwsEcsDetector implements ResourceDetector { - private static readonly CONTAINER_ID_LENGTH = 64; - private static readonly CONTAINER_ID_LENGTH_MIN = 32; - private static readonly DEFAULT_CGROUP_PATH = '/proc/self/cgroup'; + public static readonly CONTAINER_ID_LENGTH = 64; + public static readonly CONTAINER_ID_LENGTH_MIN = 32; + public static readonly DEFAULT_CGROUP_PATH = '/proc/self/cgroup'; private static readFileAsync = util.promisify(fs.readFile); diff --git a/packages/resource-detector-azure/src/detectors/AzureVmDetector.ts b/packages/resource-detector-azure/src/detectors/AzureVmDetector.ts index a138ab43f6..007e1db66a 100644 --- a/packages/resource-detector-azure/src/detectors/AzureVmDetector.ts +++ b/packages/resource-detector-azure/src/detectors/AzureVmDetector.ts @@ -75,7 +75,7 @@ class AzureVmResourceDetector implements ResourceDetector { return { attributes }; } - private async getAzureVmMetadata(): Promise { + public async getAzureVmMetadata(): Promise { try { const options = { host: AZURE_VM_METADATA_HOST, diff --git a/packages/resource-detector-container/src/detectors/ContainerDetector.ts b/packages/resource-detector-container/src/detectors/ContainerDetector.ts index 6bf765d0e1..36f6a8d25d 100644 --- a/packages/resource-detector-container/src/detectors/ContainerDetector.ts +++ b/packages/resource-detector-container/src/detectors/ContainerDetector.ts @@ -24,12 +24,12 @@ import { extractContainerIdFromLine } from './utils'; import { ATTR_CONTAINER_ID } from '../semconv'; export class ContainerDetector implements ResourceDetector { - private readonly CONTAINER_ID_LENGTH = 64; - private readonly DEFAULT_CGROUP_V1_PATH = '/proc/self/cgroup'; - private readonly DEFAULT_CGROUP_V2_PATH = '/proc/self/mountinfo'; - private readonly UTF8_UNICODE = 'utf8'; - private readonly HOSTNAME = 'hostname'; - private readonly MARKING_PREFIX = ['containers', 'overlay-containers']; + public readonly CONTAINER_ID_LENGTH = 64; + public readonly DEFAULT_CGROUP_V1_PATH = '/proc/self/cgroup'; + public readonly DEFAULT_CGROUP_V2_PATH = '/proc/self/mountinfo'; + public readonly UTF8_UNICODE = 'utf8'; + public readonly HOSTNAME = 'hostname'; + public readonly MARKING_PREFIX = ['containers', 'overlay-containers']; private static readFileAsync = util.promisify(fs.readFile); diff --git a/packages/resource-detector-instana/src/detectors/InstanaAgentDetector.ts b/packages/resource-detector-instana/src/detectors/InstanaAgentDetector.ts index 82f2e280f2..998f4d67b1 100644 --- a/packages/resource-detector-instana/src/detectors/InstanaAgentDetector.ts +++ b/packages/resource-detector-instana/src/detectors/InstanaAgentDetector.ts @@ -25,8 +25,8 @@ import { ATTR_PROCESS_PID, ATTR_SERVICE_INSTANCE_ID } from '../semconv'; import * as http from 'http'; class InstanaAgentDetector implements ResourceDetector { - private readonly INSTANA_AGENT_DEFAULT_HOST = 'localhost'; - private readonly INSTANA_AGENT_DEFAULT_PORT = 42699; + public readonly INSTANA_AGENT_DEFAULT_HOST = 'localhost'; + public readonly INSTANA_AGENT_DEFAULT_PORT = 42699; public detect(): DetectedResource { const dataPromise = context.with(suppressTracing(context.active()), () =>