Skip to content

Commit

Permalink
chore: Fix lint warnings in propagator-jaeger, propagator-b3, resourc…
Browse files Browse the repository at this point in the history
…es, and sdk-metrics-base packages (#2406)

Co-authored-by: Valentin Marchaud <[email protected]>
  • Loading branch information
alisabzevari and vmarchaud authored Aug 14, 2021
1 parent 33e6f71 commit bdb12da
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 17 deletions.
4 changes: 2 additions & 2 deletions packages/opentelemetry-propagator-b3/src/B3MultiPropagator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function isValidSampledValue(sampled: TraceFlags | undefined): boolean {
return sampled === TraceFlags.SAMPLED || sampled === TraceFlags.NONE;
}

export function parseHeader(header: unknown) {
function parseHeader(header: unknown) {
return Array.isArray(header) ? header[0] : header;
}

Expand Down Expand Up @@ -93,7 +93,7 @@ function getTraceFlags(
* Based on: https://github.com/openzipkin/b3-propagation
*/
export class B3MultiPropagator implements TextMapPropagator {
inject(context: Context, carrier: unknown, setter: TextMapSetter) {
inject(context: Context, carrier: unknown, setter: TextMapSetter): void {
const spanContext = trace.getSpanContext(context);
if (
!spanContext ||
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-propagator-b3/src/B3Propagator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class B3Propagator implements TextMapPropagator {
}
}

inject(context: Context, carrier: unknown, setter: TextMapSetter) {
inject(context: Context, carrier: unknown, setter: TextMapSetter): void {
if (isTracingSuppressed(context)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function convertToTraceFlags(samplingState: string | undefined): TraceFlags {
* Based on: https://github.com/openzipkin/b3-propagation
*/
export class B3SinglePropagator implements TextMapPropagator {
inject(context: Context, carrier: unknown, setter: TextMapSetter) {
inject(context: Context, carrier: unknown, setter: TextMapSetter): void {
const spanContext = trace.getSpanContext(context);
if (
!spanContext ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class JaegerPropagator implements TextMapPropagator {
this._jaegerTraceHeader = customTraceHeader || UBER_TRACE_ID_HEADER;
}

inject(context: Context, carrier: unknown, setter: TextMapSetter) {
inject(context: Context, carrier: unknown, setter: TextMapSetter): void {
const spanContext = trace.getSpanContext(context);
const baggage = propagation.getBaggage(context);
if (spanContext && isTracingSuppressed(context) === false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
* limitations under the License.
*/

export function defaultServiceName() {
export function defaultServiceName(): string {
return 'unknown_service';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
* limitations under the License.
*/

export function defaultServiceName() {
export function defaultServiceName(): string {
return `unknown_service:${process.argv0}`;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/
import * as api from '@opentelemetry/api-metrics';
import { Observation } from '@opentelemetry/api-metrics';
import { InstrumentationLibrary } from '@opentelemetry/core';
import { Resource } from '@opentelemetry/resources';
import { BoundObserver } from './BoundInstrument';
Expand Down Expand Up @@ -64,14 +65,14 @@ export abstract class BaseObserverMetric
return super.getMetricRecord();
}

protected _processResults(observerResult: ObserverResult) {
protected _processResults(observerResult: ObserverResult): void {
observerResult.values.forEach((value, labels) => {
const instrument = this.bind(labels);
instrument.update(value);
});
}

observation(value: number) {
observation(value: number): Observation {
return {
value,
observer: this as BaseObserverMetric,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class BatchObserverResult implements api.BatchObserverResult {
* updated
* @param [callback]
*/
onObserveCalled(callback?: () => void) {
onObserveCalled(callback?: () => void): void {
this._callback = callback;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class CounterMetric extends Metric<BoundCounter> implements api.Counter {
* @param [labels = {}] key-values pairs that are associated with a specific metric
* that you want to record.
*/
add(value: number, labels: api.Labels = {}) {
add(value: number, labels: api.Labels = {}): void {
this.bind(labels).add(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class MeterProvider implements api.MeterProvider {
);
}

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return this._meters.get(key)!;
}

Expand Down
3 changes: 2 additions & 1 deletion packages/opentelemetry-sdk-metrics-base/src/Metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export abstract class Metric<T extends BaseBoundInstrument>
*/
bind(labels: api.Labels): T {
const hash = hashLabels(labels);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
if (this._instruments.has(hash)) return this._instruments.get(hash)!;

const instrument = this._makeInstrument(labels);
Expand Down Expand Up @@ -88,7 +89,7 @@ export abstract class Metric<T extends BaseBoundInstrument>
return this._kind;
}

getAggregationTemporality() {
getAggregationTemporality(): api.AggregationTemporality {
return this._aggregationTemporality;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class SumObserverMetric
);
}

protected override _processResults(observerResult: ObserverResult) {
protected override _processResults(observerResult: ObserverResult): void {
observerResult.values.forEach((value, labels) => {
const instrument = this.bind(labels);
// SumObserver is monotonic which means it should only accept values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class UpDownCounterMetric
* @param [labels = {}] key-values pairs that are associated with a specific
* metric that you want to record.
*/
add(value: number, labels: api.Labels = {}) {
add(value: number, labels: api.Labels = {}): void {
this.bind(labels).add(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class ValueRecorderMetric
);
}

record(value: number, labels: api.Labels = {}) {
record(value: number, labels: api.Labels = {}): void {
this.bind(labels).record(value);
}
}

0 comments on commit bdb12da

Please sign in to comment.