Skip to content

Commit

Permalink
chore: adjust linting
Browse files Browse the repository at this point in the history
  • Loading branch information
pragmaticivan committed Nov 25, 2021
1 parent 3735c81 commit 48f724e
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Expand Up @@ -21,5 +21,7 @@ module.exports = {
'new-cap': 'off',
'class-methods-use-this': 'off',
'no-case-declarations': 'off',
'no-promise-executor-return': 'off',
'no-unsafe-optional-chaining': 'off',
},
};
4 changes: 3 additions & 1 deletion src/metrics/decorators/common.ts
Expand Up @@ -31,7 +31,9 @@ export const OtelInstanceCounter = (
export const OtelMethodCounter = (
options?: MetricOptions,
) => (
target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<(...args: any[]
target: Object,
propertyKey: string | symbol,
descriptor: TypedPropertyDescriptor<(...args: any[]
) => any>,
) => {
const className = target.constructor.name;
Expand Down
8 changes: 2 additions & 6 deletions src/metrics/decorators/counter.ts
Expand Up @@ -2,18 +2,14 @@ import { createParamDecorator } from '@nestjs/common';
import { MetricOptions } from '@opentelemetry/api-metrics';
import { getOrCreateCounter, getOrCreateValueRecorder, MetricType } from '../metric-data';

export const OtelCounter = createParamDecorator((
name: string, options?: MetricOptions,
) => {
export const OtelCounter = createParamDecorator((name: string, options?: MetricOptions) => {
if (!name || name.length === 0) {
throw new Error('OtelCounter need a name argument');
}
return getOrCreateCounter(name, MetricType.Counter, options);
});

export const OtelUpDownCounter = createParamDecorator((
name: string, options?: MetricOptions,
) => {
export const OtelUpDownCounter = createParamDecorator((name: string, options?: MetricOptions) => {
if (!name || name.length === 0) {
throw new Error('OtelUpDownCounter need a name argument');
}
Expand Down
4 changes: 1 addition & 3 deletions src/metrics/decorators/value-recorder.ts
Expand Up @@ -2,9 +2,7 @@ import { createParamDecorator } from '@nestjs/common';
import { MetricOptions } from '@opentelemetry/api-metrics';
import { getOrCreateValueRecorder, MetricType } from '../metric-data';

export const OtelValueRecorder = createParamDecorator((
name: string, options?: MetricOptions,
) => {
export const OtelValueRecorder = createParamDecorator((name: string, options?: MetricOptions) => {
if (!name || name.length === 0) {
throw new Error('OtelValueRecorder need a name argument');
}
Expand Down
8 changes: 6 additions & 2 deletions src/metrics/metric-data.ts
Expand Up @@ -14,7 +14,9 @@ export enum MetricType {
export const meterData: Map<string, GenericMetric> = new Map();

export function getOrCreateValueRecorder(
name: string, type: MetricType, options: MetricOptions,
name: string,
type: MetricType,
options: MetricOptions,
): ValueRecorder {
if (meterData.has(name)) {
return meterData.get(name) as ValueRecorder;
Expand All @@ -33,7 +35,9 @@ export function getOrCreateValueRecorder(
}

export function getOrCreateCounter(
name: string, type: MetricType, options: MetricOptions,
name: string,
type: MetricType,
options: MetricOptions,
): Counter | UpDownCounter {
if (meterData.has(name)) {
return meterData.get(name) as Counter | UpDownCounter;
Expand Down
8 changes: 6 additions & 2 deletions src/metrics/metric.service.ts
Expand Up @@ -21,13 +21,17 @@ export class MetricService {
}

private getOrCreateValueRecorder(
name: string, type: MetricType, options: MetricOptions,
name: string,
type: MetricType,
options: MetricOptions,
): ValueRecorder {
return getOrCreateValueRecorder(name, type, options);
}

private getOrCreateCounter(
name: string, type: MetricType, options: MetricOptions,
name: string,
type: MetricType,
options: MetricOptions,
): Counter | UpDownCounter {
return getOrCreateCounter(name, type, options);
}
Expand Down
6 changes: 3 additions & 3 deletions src/opentelemetry-core.module.ts
Expand Up @@ -27,7 +27,7 @@ export class OpenTelemetryCoreModule implements OnApplicationBootstrap {

constructor(
@Inject(OPENTELEMETRY_MODULE_OPTIONS) private readonly options: OpenTelemetryModuleOptions = {},
) {}
) { }

/**
* Bootstraps the internal OpenTelemetry Module with the given options
Expand Down Expand Up @@ -93,8 +93,8 @@ export class OpenTelemetryCoreModule implements OnApplicationBootstrap {
}

async onApplicationBootstrap() {
let defaultMetrics:boolean = false;
let hostMetrics:boolean = false;
let defaultMetrics: boolean = false;
let hostMetrics: boolean = false;

if (this.options?.metrics) {
defaultMetrics = this.options.metrics.defaultMetrics
Expand Down

0 comments on commit 48f724e

Please sign in to comment.