dd-trace 6.0.0-pre-efcd0a3 → 6.0.0-pre-bf9f356

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dd-trace",
3
- "version": "6.0.0-pre-efcd0a3",
3
+ "version": "6.0.0-pre-bf9f356",
4
4
  "description": "Datadog APM tracing client for JavaScript",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -114,6 +114,10 @@ function getCommitsToUpload ({ url, repositoryUrl, latestCommits, isEvpProxy, ev
114
114
 
115
115
  const commitsToUpload = getCommitsRevList(alreadySeenCommits, commitsToInclude)
116
116
 
117
+ if (commitsToUpload === null) {
118
+ return callback(new Error('git rev-list failed'))
119
+ }
120
+
117
121
  callback(null, commitsToUpload)
118
122
  })
119
123
  }
@@ -252,9 +256,8 @@ function sendGitMetadata (url, { isEvpProxy, evpProxyPrefix }, configRepositoryU
252
256
  return callback(new Error('Repository URL is empty'))
253
257
  }
254
258
 
255
- const latestCommits = getLatestCommits()
259
+ let latestCommits = getLatestCommits()
256
260
  log.debug(`There were ${latestCommits.length} commits since last month.`)
257
- const [headCommit] = latestCommits
258
261
 
259
262
  const getOnFinishGetCommitsToUpload = (hasCheckedShallow) => (err, commitsToUpload) => {
260
263
  if (err) {
@@ -268,6 +271,7 @@ function sendGitMetadata (url, { isEvpProxy, evpProxyPrefix }, configRepositoryU
268
271
 
269
272
  // If it has already unshallowed or the clone is not shallow, we move on
270
273
  if (hasCheckedShallow || !isShallowRepository()) {
274
+ const [headCommit] = latestCommits
271
275
  return generateAndUploadPackFiles({
272
276
  url,
273
277
  isEvpProxy,
@@ -280,6 +284,9 @@ function sendGitMetadata (url, { isEvpProxy, evpProxyPrefix }, configRepositoryU
280
284
  // Otherwise we unshallow and get commits to upload again
281
285
  log.debug('It is shallow clone, unshallowing...')
282
286
  unshallowRepository()
287
+
288
+ // The latest commits change after unshallowing
289
+ latestCommits = getLatestCommits()
283
290
  getCommitsToUpload({
284
291
  url,
285
292
  repositoryUrl,
@@ -28,7 +28,7 @@ const {
28
28
  const { filterSensitiveInfoFromRepository } = require('./url')
29
29
  const { storage } = require('../../../../datadog-core')
30
30
 
31
- const GIT_REV_LIST_MAX_BUFFER = 8 * 1024 * 1024 // 8MB
31
+ const GIT_REV_LIST_MAX_BUFFER = 12 * 1024 * 1024 // 12MB
32
32
 
33
33
  function sanitizedExec (
34
34
  cmd,
@@ -53,11 +53,15 @@ function sanitizedExec (
53
53
  distributionMetric(durationMetric.name, durationMetric.tags, Date.now() - startTime)
54
54
  }
55
55
  return result
56
- } catch (e) {
56
+ } catch (err) {
57
57
  if (errorMetric) {
58
- incrementCountMetric(errorMetric.name, { ...errorMetric.tags, exitCode: e.status })
58
+ incrementCountMetric(errorMetric.name, {
59
+ ...errorMetric.tags,
60
+ errorType: err.code,
61
+ exitCode: err.status || err.errno
62
+ })
59
63
  }
60
- log.error(e)
64
+ log.error(err)
61
65
  return ''
62
66
  } finally {
63
67
  storage.enterWith(store)
@@ -129,7 +133,10 @@ function unshallowRepository () {
129
133
  } catch (err) {
130
134
  // If the local HEAD is a commit that has not been pushed to the remote, the above command will fail.
131
135
  log.error(err)
132
- incrementCountMetric(TELEMETRY_GIT_COMMAND_ERRORS, { command: 'unshallow', exitCode: err.status })
136
+ incrementCountMetric(
137
+ TELEMETRY_GIT_COMMAND_ERRORS,
138
+ { command: 'unshallow', errorType: err.code, exitCode: err.status || err.errno }
139
+ )
133
140
  const upstreamRemote = sanitizedExec('git', ['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{upstream}'])
134
141
  try {
135
142
  cp.execFileSync('git', [
@@ -139,7 +146,10 @@ function unshallowRepository () {
139
146
  } catch (err) {
140
147
  // If the CI is working on a detached HEAD or branch tracking hasn’t been set up, the above command will fail.
141
148
  log.error(err)
142
- incrementCountMetric(TELEMETRY_GIT_COMMAND_ERRORS, { command: 'unshallow', exitCode: err.status })
149
+ incrementCountMetric(
150
+ TELEMETRY_GIT_COMMAND_ERRORS,
151
+ { command: 'unshallow', errorType: err.code, exitCode: err.status || err.errno }
152
+ )
143
153
  // We use sanitizedExec here because if this last option fails, we'll give up.
144
154
  sanitizedExec(
145
155
  'git',
@@ -175,13 +185,16 @@ function getLatestCommits () {
175
185
  return result
176
186
  } catch (err) {
177
187
  log.error(`Get latest commits failed: ${err.message}`)
178
- incrementCountMetric(TELEMETRY_GIT_COMMAND_ERRORS, { command: 'get_local_commits', errorType: err.status })
188
+ incrementCountMetric(
189
+ TELEMETRY_GIT_COMMAND_ERRORS,
190
+ { command: 'get_local_commits', errorType: err.status }
191
+ )
179
192
  return []
180
193
  }
181
194
  }
182
195
 
183
196
  function getCommitsRevList (commitsToExclude, commitsToInclude) {
184
- let result = []
197
+ let result = null
185
198
 
186
199
  const commitsToExcludeString = commitsToExclude.map(commit => `^${commit}`)
187
200
 
@@ -205,7 +218,10 @@ function getCommitsRevList (commitsToExclude, commitsToInclude) {
205
218
  .filter(commit => commit)
206
219
  } catch (err) {
207
220
  log.error(`Get commits to upload failed: ${err.message}`)
208
- incrementCountMetric(TELEMETRY_GIT_COMMAND_ERRORS, { command: 'get_objects', errorType: err.status })
221
+ incrementCountMetric(
222
+ TELEMETRY_GIT_COMMAND_ERRORS,
223
+ { command: 'get_objects', errorType: err.code, exitCode: err.status || err.errno } // err.status might be null
224
+ )
209
225
  }
210
226
  distributionMetric(TELEMETRY_GIT_COMMAND_MS, { command: 'get_objects' }, Date.now() - startTime)
211
227
  return result
@@ -245,7 +261,10 @@ function generatePackFilesForCommits (commitsToUpload) {
245
261
  result = execGitPackObjects(temporaryPath)
246
262
  } catch (err) {
247
263
  log.error(err)
248
- incrementCountMetric(TELEMETRY_GIT_COMMAND_ERRORS, { command: 'pack_objects', errorType: err.status })
264
+ incrementCountMetric(
265
+ TELEMETRY_GIT_COMMAND_ERRORS,
266
+ { command: 'pack_objects', exitCode: err.status || err.errno, errorType: err.code }
267
+ )
249
268
  /**
250
269
  * The generation of pack files in the temporary folder (from `os.tmpdir()`)
251
270
  * sometimes fails in certain CI setups with the error message
@@ -262,7 +281,10 @@ function generatePackFilesForCommits (commitsToUpload) {
262
281
  result = execGitPackObjects(cwdPath)
263
282
  } catch (err) {
264
283
  log.error(err)
265
- incrementCountMetric(TELEMETRY_GIT_COMMAND_ERRORS, { command: 'pack_objects', errorType: err.status })
284
+ incrementCountMetric(
285
+ TELEMETRY_GIT_COMMAND_ERRORS,
286
+ { command: 'pack_objects', exitCode: err.status || err.errno, errorType: err.code }
287
+ )
266
288
  }
267
289
  }
268
290
  distributionMetric(TELEMETRY_GIT_COMMAND_MS, { command: 'pack_objects' }, Date.now() - startTime)