Skip to content

Commit df21b74

Browse files
add docstring & refactor isAccountId
1 parent 0ffb21f commit df21b74

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

aws-distro-opentelemetry-node-autoinstrumentation/src/regional-resource-arn-parser.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import { AttributeValue } from '@opentelemetry/api';
55
import { isAccountId } from './utils';
66

77
export class RegionalResourceArnParser {
8+
/** Parses ARN with formats:
9+
* arn:partition:service:region:account-id:resource-type/resource-id or
10+
* arn:partition:service:region:account-id:resource-type:resource-id
11+
*/
812
private static parseArn(arn: AttributeValue | undefined): string[] | undefined {
913
if (typeof arn !== 'string') return undefined;
1014
const parts = arn.split(':');

aws-distro-opentelemetry-node-autoinstrumentation/src/sqs-url-parser.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ export class SqsUrlParser {
2424
* custom URLs. Essentially, we require that the URL should have exactly three parts, delimited by
2525
* /'s (excluding schema), the second part should be a account id consisting of digits, and the third part
2626
* should be a valid queue name, per SQS naming conventions.
27+
*
28+
* Unlike parseUrl which only handles new URLs and their queuename parsing, this
29+
* implements its own queue name parsing logic to support multiple URL formats.
2730
*/
2831
public static getQueueName(url: AttributeValue | undefined): string | undefined {
2932
if (typeof url !== 'string') {

aws-distro-opentelemetry-node-autoinstrumentation/src/utils.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,5 @@ export const checkDigits = (str: string): boolean => {
6161
};
6262

6363
export const isAccountId = (input: string): boolean => {
64-
if (input == null) {
65-
return false;
66-
}
67-
68-
if (!checkDigits(input)) {
69-
return false;
70-
}
71-
72-
return true;
64+
return input != null && checkDigits(input);
7365
};

0 commit comments

Comments
 (0)