Skip to content

Commit 9d4e68d

Browse files
authored
Merge pull request #83 from cloudgraphdev/feat-errors
feat: collect crawl error logs
2 parents 2f8cfb0 + bd58d1d commit 9d4e68d

File tree

4 files changed

+30
-11
lines changed

4 files changed

+30
-11
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"@azure/identity": "^2.0.4",
7474
"@azure/storage-blob": "^12.8.0",
7575
"@azure/storage-queue": "^12.9.0",
76-
"@cloudgraph/sdk": "0.22.1",
76+
"@cloudgraph/sdk": "0.23.0",
7777
"@graphql-tools/load-files": "^6.5.3",
7878
"@graphql-tools/merge": "^8.2.3",
7979
"@microsoft/microsoft-graph-client": "^3.0.2",
@@ -126,4 +126,4 @@
126126
"**/glob-parent": "^5.1.2",
127127
"**/uri-js": "^3.0.1"
128128
}
129-
}
129+
}

src/services/index.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
GLOBAL_REGION,
2626
} from '../config/constants'
2727
import { obfuscateSensitiveString } from '../utils/format'
28-
import { checkAndMergeConnections, sortResourcesDependencies } from '../utils'
28+
import { getAllProviderErrors, sortResourcesDependencies } from '../utils'
2929
import { createDiffSecs } from '../utils/dateutils'
3030
import {
3131
getClientSecretCredentials,
@@ -151,9 +151,10 @@ export default class Provider extends CloudGraph.Client {
151151
)}`
152152
)
153153
this.logger.success(
154-
`subscriptionIds: ${this.subscriptions.length > 1
155-
? this.subscriptions.join(', ')
156-
: this.subscriptions[0]
154+
`subscriptionIds: ${
155+
this.subscriptions.length > 1
156+
? this.subscriptions.join(', ')
157+
: this.subscriptions[0]
157158
}`
158159
)
159160
this.logger.success(
@@ -700,11 +701,15 @@ export default class Provider extends CloudGraph.Client {
700701
}
701702
}
702703

703-
return this.enhanceData({
704+
const enhancedData = await this.enhanceData({
704705
subscriptions: subscriptions.data[GLOBAL_REGION],
705706
configuredRegions,
706707
rawData,
707708
data: result,
708709
})
710+
711+
const errors = getAllProviderErrors()
712+
713+
return { ...enhancedData, errors }
709714
}
710715
}

src/utils/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import camelCase from 'lodash/camelCase'
33
import isEmpty from 'lodash/isEmpty'
44
import unionWith from 'lodash/unionWith'
55
import isEqual from 'lodash/isEqual'
6+
import { ProviderError } from '@cloudgraph/sdk/dist/src/types'
67
import relations from '../enums/relations'
78
import {
89
AzureDebugScope,
@@ -65,6 +66,12 @@ export function initTestConfig(): void {
6566
jest.setTimeout(900000)
6667
}
6768

69+
const errorsHistory: ProviderError[] = []
70+
71+
export function getAllProviderErrors(): ProviderError[] {
72+
return errorsHistory
73+
}
74+
6875
export function generateAzureErrorLog(
6976
service: string,
7077
functionName: string,
@@ -87,6 +94,13 @@ export function generateAzureErrorLog(
8794
} else {
8895
logger.debug(err.message)
8996
}
97+
if (err?.statusCode !== 429) {
98+
errorsHistory.push({
99+
service,
100+
function: functionName,
101+
message: err?.message || 'Unknown error',
102+
})
103+
}
90104
throw new Error()
91105
}
92106

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,10 +1282,10 @@
12821282
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
12831283
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
12841284

1285-
"@cloudgraph/sdk@0.22.1":
1286-
version "0.22.1"
1287-
resolved "https://registry.yarnpkg.com/@cloudgraph/sdk/-/sdk-0.22.1.tgz#bf5c2f263df17b085147a3ca234ac5b0a8806545"
1288-
integrity sha512-aMrnoTRRIODAVvgtmqGZPB7Z8x1kMgKjFtLjpiHa121o0GCEZCjbxDmU8T3DwmRwI1u4QD5iKbXf9dB0573mJA==
1285+
"@cloudgraph/sdk@0.23.0":
1286+
version "0.23.0"
1287+
resolved "https://registry.yarnpkg.com/@cloudgraph/sdk/-/sdk-0.23.0.tgz#3f6012c0e3573f527da27ebcccb8841bbeffd21b"
1288+
integrity sha512-c+Ozu8yLK3RlAcKy4d0fdTQc9JkdUJ2ESmrcW7oC5XdIARrDWQ5+Kr8AGPABOK1/UYtFyVR2JmUHnoSJdGAv6Q==
12891289
dependencies:
12901290
"@graphql-tools/load-files" "^6.5.3"
12911291
"@graphql-tools/merge" "^8.2.1"

0 commit comments

Comments
 (0)