Skip to content

Commit b553fea

Browse files
committed
fix: remove reduntant methods
1 parent c2febb1 commit b553fea

File tree

8 files changed

+9
-47
lines changed

8 files changed

+9
-47
lines changed

Diff for: packages/commons/src/config/ConfigService.ts

-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
*/
1010
abstract class ConfigService {
1111

12-
/**
13-
* @see https://awslabs.github.io/aws-lambda-powertools-typescript/latest/#environment-variables
14-
* @protected
15-
*/
16-
protected serviceNameVariable = 'POWERTOOLS_SERVICE_NAME';
17-
1812
/**
1913
* It returns the value of an environment variable that has given name.
2014
*

Diff for: packages/commons/src/config/EnvironmentVariablesService.ts

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ import { ConfigService } from '.';
1515
*/
1616
class EnvironmentVariablesService extends ConfigService {
1717

18+
/**
19+
* @see https://awslabs.github.io/aws-lambda-powertools-typescript/latest/#environment-variables
20+
* @protected
21+
*/
22+
protected serviceNameVariable = 'POWERTOOLS_SERVICE_NAME';
1823
// Reserved environment variables
1924
private xRayTraceIdVariable = '_X_AMZN_TRACE_ID';
2025

Diff for: packages/logger/src/config/EnvironmentVariablesService.ts

-18
Original file line numberDiff line numberDiff line change
@@ -105,24 +105,6 @@ class EnvironmentVariablesService extends CommonEnvironmentVariablesService impl
105105
return (value && value.length > 0) ? Number(value) : undefined;
106106
}
107107

108-
/**
109-
* It returns the value of the POWERTOOLS_SERVICE_NAME environment variable.
110-
*
111-
* @returns {string}
112-
*/
113-
public getServiceName(): string {
114-
return this.get(this.serviceNameVariable);
115-
}
116-
117-
/**
118-
* It returns the value of the _X_AMZN_TRACE_ID environment variable.
119-
*
120-
* @returns {string}
121-
*/
122-
public getXrayTraceId(): string {
123-
return super.getXrayTraceId();
124-
}
125-
126108
}
127109

128110
export {

Diff for: packages/metrics/src/Metrics.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,8 @@ class Metrics extends Utility implements MetricsInterface {
450450

451451
private setService(service: string | undefined): void {
452452
const targetService = (service ||
453-
this.getCustomConfigService()?.getService() ||
454-
this.getEnvVarsService().getService()) as string;
453+
this.getCustomConfigService()?.getServiceName() ||
454+
this.getEnvVarsService().getServiceName()) as string;
455455
if (targetService.length > 0) {
456456
this.addDimension('service', targetService);
457457
}

Diff for: packages/metrics/src/config/ConfigServiceInterface.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ interface ConfigServiceInterface {
22

33
get?(name: string): string
44
getNamespace(): string
5-
getService(): string
5+
getServiceName(): string
66

77
}
88

Diff for: packages/metrics/src/config/EnvironmentVariablesService.ts

-8
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,10 @@ import { EnvironmentVariablesService as CommonEnvironmentVariablesService } from
44
class EnvironmentVariablesService extends CommonEnvironmentVariablesService implements ConfigServiceInterface {
55

66
private namespaceVariable = 'POWERTOOLS_METRICS_NAMESPACE';
7-
private serviceVariable = 'POWERTOOLS_SERVICE_NAME';
8-
9-
public get(name: string): string {
10-
return process.env[name]?.trim() || '';
11-
}
127

138
public getNamespace(): string {
149
return this.get(this.namespaceVariable);
1510
}
16-
public getService(): string {
17-
return this.get(this.serviceVariable);
18-
}
1911

2012
}
2113

Diff for: packages/metrics/tests/unit/Metrics.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ describe('Class: Metrics', () => {
684684
const serviceName = 'Custom Provider Service Name';
685685
const namespace = 'Custom Provider namespace';
686686
const customConfigService = {
687-
getService: () => serviceName,
687+
getServiceName: () => serviceName,
688688
getNamespace: () => namespace,
689689
};
690690

Diff for: packages/tracer/src/config/EnvironmentVariablesService.ts

-11
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ class EnvironmentVariablesService extends CommonEnvironmentVariablesService impl
1111
private tracerCaptureResponseVariable = 'POWERTOOLS_TRACER_CAPTURE_RESPONSE';
1212
private tracingEnabledVariable = 'POWERTOOLS_TRACE_ENABLED';
1313

14-
public get(name: string): string {
15-
return process.env[name]?.trim() || '';
16-
}
17-
1814
public getAwsExecutionEnv(): string {
1915
return this.get(this.awsExecutionEnv);
2016
}
@@ -27,10 +23,6 @@ class EnvironmentVariablesService extends CommonEnvironmentVariablesService impl
2723
return this.get(this.samLocalVariable);
2824
}
2925

30-
public getServiceName(): string {
31-
return this.get(this.serviceNameVariable);
32-
}
33-
3426
public getTracingCaptureError(): string {
3527
return this.get(this.tracerCaptureErrorVariable);
3628
}
@@ -43,9 +35,6 @@ class EnvironmentVariablesService extends CommonEnvironmentVariablesService impl
4335
return this.get(this.tracingEnabledVariable);
4436
}
4537

46-
public getXrayTraceId(): string {
47-
return super.getXrayTraceId();
48-
}
4938
}
5039

5140
export {

0 commit comments

Comments
 (0)