Skip to content

Commit

Permalink
Merge branch 'master' into add-collector-upstream-error
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarchaud committed Nov 4, 2020
2 parents 485f4fc + b1e2bed commit 9561042
Show file tree
Hide file tree
Showing 33 changed files with 130 additions and 168 deletions.
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = {
"leadingUnderscore": "require"
}
],
"@typescript-eslint/no-unused-vars": ["error", {"argsIgnorePattern": "^_", "args": "after-used"}],
"@typescript-eslint/no-inferrable-types": ["error", { ignoreProperties: true }],
"arrow-parens": ["error", "as-needed"],
"prettier/prettier": ["error", { "singleQuote": true, "arrowParens": "avoid" }],
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
},
"husky": {
"hooks": {
"pre-commit": "lerna run --concurrency 1 --stream lint:fix --since HEAD --exclude-dependents",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-api/src/api/global-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ export function makeGetter<T>(
* version. If the global API is not compatible with the API package
* attempting to get it, a NOOP API implementation will be returned.
*/
export const API_BACKWARDS_COMPATIBILITY_VERSION = 1;
export const API_BACKWARDS_COMPATIBILITY_VERSION = 2;
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import { TextMapPropagator } from './TextMapPropagator';
*/
export class NoopTextMapPropagator implements TextMapPropagator {
/** Noop inject function does nothing */
inject(context: Context, carrier: unknown): void {}
inject(_context: Context, _carrier: unknown): void {}
/** Noop extract function does nothing and returns the input context */
extract(context: Context, carrier: unknown): Context {
extract(context: Context, _carrier: unknown): Context {
return context;
}
fields(): string[] {
Expand Down
30 changes: 15 additions & 15 deletions packages/opentelemetry-api/src/metrics/NoopMeter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class NoopMeter implements Meter {
* @param name the name of the metric.
* @param [options] the metric options.
*/
createValueRecorder(name: string, options?: MetricOptions): ValueRecorder {
createValueRecorder(_name: string, _options?: MetricOptions): ValueRecorder {
return NOOP_VALUE_RECORDER_METRIC;
}

Expand All @@ -57,7 +57,7 @@ export class NoopMeter implements Meter {
* @param name the name of the metric.
* @param [options] the metric options.
*/
createCounter(name: string, options?: MetricOptions): Counter {
createCounter(_name: string, _options?: MetricOptions): Counter {
return NOOP_COUNTER_METRIC;
}

Expand All @@ -66,7 +66,7 @@ export class NoopMeter implements Meter {
* @param name the name of the metric.
* @param [options] the metric options.
*/
createUpDownCounter(name: string, options?: MetricOptions): UpDownCounter {
createUpDownCounter(_name: string, _options?: MetricOptions): UpDownCounter {
return NOOP_COUNTER_METRIC;
}

Expand All @@ -77,9 +77,9 @@ export class NoopMeter implements Meter {
* @param [callback] the value observer callback
*/
createValueObserver(
name: string,
options?: MetricOptions,
callback?: (observerResult: ObserverResult) => void
_name: string,
_options?: MetricOptions,
_callback?: (observerResult: ObserverResult) => void
): ValueObserver {
return NOOP_VALUE_OBSERVER_METRIC;
}
Expand All @@ -90,8 +90,8 @@ export class NoopMeter implements Meter {
* @param callback the batch observer callback
*/
createBatchObserver(
name: string,
callback: (batchObserverResult: BatchObserverResult) => void
_name: string,
_callback: (batchObserverResult: BatchObserverResult) => void
): BatchObserver {
return NOOP_BATCH_OBSERVER_METRIC;
}
Expand All @@ -111,15 +111,15 @@ export class NoopMetric<T> implements UnboundMetric<T> {
* @param labels key-values pairs that are associated with a specific metric
* that you want to record.
*/
bind(labels: Labels): T {
bind(_labels: Labels): T {
return this._instrument;
}

/**
* Removes the Binding from the metric, if it is present.
* @param labels key-values pairs that are associated with a specific metric.
*/
unbind(labels: Labels): void {
unbind(_labels: Labels): void {
return;
}

Expand Down Expand Up @@ -163,23 +163,23 @@ export class NoopBatchObserverMetric
implements BatchObserver {}

export class NoopBoundCounter implements BoundCounter {
add(value: number): void {
add(_value: number): void {
return;
}
}

export class NoopBoundValueRecorder implements BoundValueRecorder {
record(
value: number,
correlationContext?: CorrelationContext,
spanContext?: SpanContext
_value: number,
_correlationContext?: CorrelationContext,
_spanContext?: SpanContext
): void {
return;
}
}

export class NoopBoundBaseObserver implements BoundBaseObserver {
update(value: number) {}
update(_value: number) {}
}

export const NOOP_METER = new NoopMeter();
Expand Down
8 changes: 4 additions & 4 deletions packages/opentelemetry-api/src/trace/NoopLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ import { Logger } from '../common/Logger';
/** No-op implementation of Logger */
export class NoopLogger implements Logger {
// By default does nothing
debug(message: string, ...args: unknown[]) {}
debug(_message: string, ..._args: unknown[]) {}

// By default does nothing
error(message: string, ...args: unknown[]) {}
error(_message: string, ..._args: unknown[]) {}

// By default does nothing
warn(message: string, ...args: unknown[]) {}
warn(_message: string, ..._args: unknown[]) {}

// By default does nothing
info(message: string, ...args: unknown[]) {}
info(_message: string, ..._args: unknown[]) {}
}
14 changes: 7 additions & 7 deletions packages/opentelemetry-api/src/trace/NoopSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,40 +38,40 @@ export class NoopSpan implements Span {
}

// By default does nothing
setAttribute(key: string, value: unknown): this {
setAttribute(_key: string, _value: unknown): this {
return this;
}

// By default does nothing
setAttributes(attributes: Attributes): this {
setAttributes(_attributes: Attributes): this {
return this;
}

// By default does nothing
addEvent(name: string, attributes?: Attributes): this {
addEvent(_name: string, _attributes?: Attributes): this {
return this;
}

// By default does nothing
setStatus(status: Status): this {
setStatus(_status: Status): this {
return this;
}

// By default does nothing
updateName(name: string): this {
updateName(_name: string): this {
return this;
}

// By default does nothing
end(endTime?: TimeInput): void {}
end(_endTime?: TimeInput): void {}

// isRecording always returns false for noopSpan.
isRecording(): boolean {
return false;
}

// By default does nothing
recordException(exception: Exception, time?: TimeInput): void {}
recordException(_exception: Exception, _time?: TimeInput): void {}
}

export const NOOP_SPAN = new NoopSpan();
13 changes: 8 additions & 5 deletions packages/opentelemetry-api/src/trace/NoopTracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ export class NoopTracer implements Tracer {

// startSpan starts a noop span.
startSpan(name: string, options?: SpanOptions, context?: Context): Span {
const parent = options?.parent;
const root = Boolean(options?.root);
if (root) {
return NOOP_SPAN;
}

const parentFromContext = context && getActiveSpan(context)?.context();
if (isSpanContext(parent) && isSpanContextValid(parent)) {
return new NoopSpan(parent);
} else if (

if (
isSpanContext(parentFromContext) &&
isSpanContextValid(parentFromContext)
) {
Expand All @@ -51,7 +54,7 @@ export class NoopTracer implements Tracer {
return fn();
}

bind<T>(target: T, span?: Span): T {
bind<T>(target: T, _span?: Span): T {
return target;
}
}
Expand Down
19 changes: 3 additions & 16 deletions packages/opentelemetry-api/src/trace/SpanOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import { Attributes } from './attributes';
import { Link } from './link';
import { SpanKind } from './span_kind';
import { Span } from './span';
import { SpanContext } from './span_context';

/**
* Options needed for span creation
Expand All @@ -36,20 +34,9 @@ export interface SpanOptions {
/** {@link Link}s span to other spans */
links?: Link[];

/**
* This option is NOT RECOMMENDED for normal use and should ONLY be used
* if your application manages context manually without the global context
* manager, or you are trying to override the parent extracted from context.
*
* A parent `SpanContext` (or `Span`, for convenience) that the newly-started
* span will be the child of. This overrides the parent span extracted from
* the currently active context.
*
* A null value here should prevent the SDK from extracting a parent from
* the current context, forcing the new span to be a root span.
*/
parent?: Span | SpanContext | null;

/** A manually specified start time for the created `Span` object. */
startTime?: number;

/** The new span should be a root span. (Ignore parent from context). */
root?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,6 @@ describe('NoopTracer', () => {
return patchedFn();
});

it('should propagate valid spanContext on the span (from parent)', () => {
const tracer = new NoopTracer();
const parent: SpanContext = {
traceId: 'd4cda95b652f4a1592b449d5929fda1b',
spanId: '6e0c63257de34c92',
traceFlags: TraceFlags.NONE,
};
const span = tracer.startSpan('test-1', { parent });
assert(span.context().traceId === parent.traceId);
assert(span.context().spanId === parent.spanId);
assert(span.context().traceFlags === parent.traceFlags);
});

it('should propagate valid spanContext on the span (from context)', () => {
const tracer = new NoopTracer();
const parent: SpanContext = {
Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-context-base/src/NoopContextManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ export class NoopContextManager implements types.ContextManager {
}

with<T extends (...args: unknown[]) => ReturnType<T>>(
context: types.Context,
_context: types.Context,
fn: T
): ReturnType<T> {
return fn();
}

bind<T>(target: T, context?: types.Context): T {
bind<T>(target: T, _context?: types.Context): T {
return target;
}

Expand Down
8 changes: 4 additions & 4 deletions packages/opentelemetry-core/src/common/ConsoleLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ export class ConsoleLogger implements Logger {
}
}

debug(message: string, ...args: unknown[]) {}
debug(_message: string, ..._args: unknown[]) {}

error(message: string, ...args: unknown[]) {}
error(_message: string, ..._args: unknown[]) {}

warn(message: string, ...args: unknown[]) {}
warn(_message: string, ..._args: unknown[]) {}

info(message: string, ...args: unknown[]) {}
info(_message: string, ..._args: unknown[]) {}
}
8 changes: 4 additions & 4 deletions packages/opentelemetry-core/src/common/NoopLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ import { Logger } from '@opentelemetry/api';
/** No-op implementation of Logger */
export class NoopLogger implements Logger {
// By default does nothing
debug(message: string, ...args: unknown[]) {}
debug(_message: string, ..._args: unknown[]) {}

// By default does nothing
error(message: string, ...args: unknown[]) {}
error(_message: string, ..._args: unknown[]) {}

// By default does nothing
warn(message: string, ...args: unknown[]) {}
warn(_message: string, ..._args: unknown[]) {}

// By default does nothing
info(message: string, ...args: unknown[]) {}
info(_message: string, ..._args: unknown[]) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export function unrefTimer(timer: number): void {}
export function unrefTimer(_timer: number): void {}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ export class AlwaysOffSampler implements Sampler {
}

toString(): string {
return `AlwaysOffSampler`;
return 'AlwaysOffSampler';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ export class AlwaysOnSampler implements Sampler {
}

toString(): string {
return `AlwaysOnSampler`;
return 'AlwaysOnSampler';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export abstract class CollectorExporterNodeBase<
parseHeaders(config.headers, this.logger) || this.DEFAULT_HEADERS;
}

onInit(config: CollectorExporterConfigBase): void {
onInit(_config: CollectorExporterConfigBase): void {
this._isShutdown = false;
}

Expand Down
1 change: 1 addition & 0 deletions packages/opentelemetry-exporter-jaeger/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
*/

export * from './jaeger';
export { ExporterConfig } from './types';
3 changes: 2 additions & 1 deletion packages/opentelemetry-exporter-zipkin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
* limitations under the License.
*/

export * from './zipkin';
export * from './platform';
export { ExporterConfig } from './types';
export * from './zipkin';
2 changes: 1 addition & 1 deletion packages/opentelemetry-metrics/src/export/Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class PushController extends Controller {

private async _collect(): Promise<void> {
await this._meter.collect();
return new Promise((resolve, reject) => {
return new Promise(resolve => {
this._exporter.export(
this._meter.getBatcher().checkPointSet(),
result => {
Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-metrics/src/export/NoopExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import { ExportResult } from '@opentelemetry/core';
export class NoopExporter implements MetricExporter {
// By default does nothing
export(
metrics: MetricRecord[],
resultCallback: (result: ExportResult) => void
_metrics: MetricRecord[],
_resultCallback: (result: ExportResult) => void
): void {}

// By default does nothing
Expand Down
Loading

0 comments on commit 9561042

Please sign in to comment.