Skip to content
Open
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
19 changes: 18 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
}],
},
},

Expand Down Expand Up @@ -184,6 +190,7 @@ const baseConfig = tseslint.config(
'warn',
{ argsIgnorePattern: '^_' },
],
'@typescript-eslint/explicit-member-accessibility': 'off',
'no-empty': 'off',
},
},
Expand Down Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class BaggageLogRecordProcessor implements LogRecordProcessor {
/**
* Forces to export all finished log records.
*/
forceFlush(): Promise<void> {
public forceFlush(): Promise<void> {
// no-op
return Promise.resolve();
}
Expand All @@ -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]))
Expand All @@ -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<void> {
public shutdown(): Promise<void> {
// no-op
return Promise.resolve();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class BaggageSpanProcessor implements SpanProcessor {
/**
* Forces to export all finished spans
*/
forceFlush(): Promise<void> {
public forceFlush(): Promise<void> {
// no-op
return Promise.resolve();
}
Expand All @@ -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));
Expand All @@ -78,15 +78,15 @@ export class BaggageSpanProcessor implements SpanProcessor {
* returns true.
* @param span the Span that just ended.
*/
onEnd(_: ReadableSpan): void {
public onEnd(_: ReadableSpan): void {
// no-op
}

/**
* Shuts down the processor. Called when SDK is shut down. This is an
* opportunity for processor to do any cleanup required.
*/
shutdown(): Promise<void> {
public shutdown(): Promise<void> {
// no-op
return Promise.resolve();
}
Expand Down
16 changes: 8 additions & 8 deletions packages/contrib-test-utils/src/test-fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,21 @@ export type TestSpan = ISpan & {
* There is little error checking here; we are assuming valid OTLP.
*/
export class TestCollector {
endpointUrl?: string;
spans: Array<TestSpan> = [];
public endpointUrl?: string;
public spans: Array<TestSpan> = [];
private _http;

constructor() {
this.clear();
this._http = createServer(this._onRequest.bind(this));
}

clear(): void {
public clear(): void {
this.spans = [];
}

// Start listening and set address to `endpointUrl`.
async start(): Promise<void> {
public async start(): Promise<void> {
return new Promise(resolve => {
this._http.listen(() => {
this.endpointUrl = `http://localhost:${
Expand All @@ -92,7 +92,7 @@ export class TestCollector {
});
}

close() {
public close() {
this.endpointUrl = undefined;
return this._http.close();
}
Expand All @@ -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<TestSpan> {
public get sortedSpans(): Array<TestSpan> {
return this.spans.slice().sort((a, b) => {
assert(typeof a.startTimeUnixNano === 'string');
assert(typeof b.startTimeUnixNano === 'string');
Expand All @@ -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') {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/host-metrics/src/metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ export class HostMetrics extends BaseMetrics {
/**
* Starts collecting metrics
*/
start() {
public start() {
this._createMetrics();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ 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);
}

/**
* 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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ 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);
}

/**
* 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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
public readonly component: string = 'react-load';
public moduleName = this.component;
private _parentSpanMap: WeakMap<React.Component, api.Span>;
private static _tracer: api.Tracer;
private static _logger: api.DiagLogger = api.diag;
Expand All @@ -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
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -68,7 +68,7 @@ export class AWSXRayLambdaPropagator implements TextMapPropagator {
);
}

fields(): string[] {
public fields(): string[] {
return this._awsXrayPropagator.fields();
}
}
6 changes: 3 additions & 3 deletions packages/propagator-aws-xray/src/AWSXRayPropagator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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];
}

Expand Down
6 changes: 3 additions & 3 deletions packages/propagator-instana/src/InstanaPropagator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
Expand Down Expand Up @@ -119,7 +119,7 @@ export class InstanaPropagator implements TextMapPropagator {
return context;
}

fields(): string[] {
public fields(): string[] {
return FIELDS.slice();
}
}
6 changes: 3 additions & 3 deletions packages/propagator-ot-trace/src/OTTracePropagator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()
);
Expand All @@ -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<DetectedResourceAttributes> {
private async _gatherData(): Promise<DetectedResourceAttributes> {
try {
const {
'owner-account-id': accountId,
Expand Down
Loading
Loading