serverless-plugin-datadog 5.5.0 → 5.6.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/package.json +1 -1
- package/dist/src/git-metadata/interfaces.d.ts +10 -0
- package/dist/src/git-metadata/interfaces.d.ts.map +1 -0
- package/dist/src/git-metadata/interfaces.js +43 -0
- package/dist/src/git-metadata/interfaces.js.map +1 -0
- package/dist/src/helpers/apikey.d.ts +13 -0
- package/dist/src/helpers/apikey.d.ts.map +1 -0
- package/dist/src/helpers/apikey.js +74 -0
- package/dist/src/helpers/apikey.js.map +1 -0
- package/dist/src/helpers/errors.d.ts +3 -0
- package/dist/src/helpers/errors.d.ts.map +1 -0
- package/dist/src/helpers/errors.js +7 -0
- package/dist/src/helpers/errors.js.map +1 -0
- package/dist/src/helpers/interfaces.d.ts +20 -0
- package/dist/src/helpers/interfaces.d.ts.map +1 -0
- package/dist/src/helpers/interfaces.js +3 -0
- package/dist/src/helpers/interfaces.js.map +1 -0
- package/dist/src/helpers/retry.d.ts +3 -0
- package/dist/src/helpers/retry.d.ts.map +1 -0
- package/dist/src/helpers/retry.js +39 -0
- package/dist/src/helpers/retry.js.map +1 -0
- package/dist/src/helpers/tags.d.ts +29 -0
- package/dist/src/helpers/tags.d.ts.map +1 -0
- package/dist/src/helpers/tags.js +50 -0
- package/dist/src/helpers/tags.js.map +1 -0
- package/dist/src/helpers/upload.d.ts +45 -0
- package/dist/src/helpers/upload.d.ts.map +1 -0
- package/dist/src/helpers/upload.js +70 -0
- package/dist/src/helpers/upload.js.map +1 -0
- package/dist/src/helpers/utils.d.ts +31 -0
- package/dist/src/helpers/utils.d.ts.map +1 -0
- package/dist/src/helpers/utils.js +115 -0
- package/dist/src/helpers/utils.js.map +1 -0
- package/dist/src/layers-gov.json +16 -16
- package/dist/src/layers.json +178 -168
- package/dist/src/source-code-integration.d.ts +15 -0
- package/dist/src/source-code-integration.d.ts.map +1 -0
- package/dist/src/source-code-integration.js +76 -0
- package/dist/src/source-code-integration.js.map +1 -0
- package/package.json +1 -1
@@ -0,0 +1,76 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.SourceCodeIntegration = void 0;
|
13
|
+
const package_json_1 = require("../package.json");
|
14
|
+
const git_1 = require("./git");
|
15
|
+
const apikey_1 = require("./helpers/apikey");
|
16
|
+
const errors_1 = require("./helpers/errors");
|
17
|
+
const upload_1 = require("./helpers/upload");
|
18
|
+
const utils_1 = require("./helpers/utils");
|
19
|
+
class SourceCodeIntegration {
|
20
|
+
constructor(apiKey, datadogSite, simpleGit, repositoryURL) {
|
21
|
+
this.apiKey = apiKey;
|
22
|
+
this.datadogSite = datadogSite;
|
23
|
+
this.simpleGit = simpleGit;
|
24
|
+
this.repositoryURL = repositoryURL;
|
25
|
+
}
|
26
|
+
uploadGitMetadata() {
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
28
|
+
const apiKeyValidator = (0, apikey_1.newApiKeyValidator)({
|
29
|
+
apiKey: this.apiKey,
|
30
|
+
datadogSite: this.datadogSite,
|
31
|
+
});
|
32
|
+
const payload = yield (0, git_1.getCommitInfo)(this.simpleGit, this.repositoryURL);
|
33
|
+
if (payload === undefined) {
|
34
|
+
throw Error("Couldn't get git commit information.");
|
35
|
+
}
|
36
|
+
try {
|
37
|
+
const requestBuilder = this.getRequestBuilder();
|
38
|
+
const status = yield this.uploadRepository(requestBuilder)(payload, {
|
39
|
+
apiKeyValidator,
|
40
|
+
onError: (e) => {
|
41
|
+
throw e;
|
42
|
+
},
|
43
|
+
onRetry: (_) => { },
|
44
|
+
onUpload: () => {
|
45
|
+
return;
|
46
|
+
},
|
47
|
+
retries: 5,
|
48
|
+
});
|
49
|
+
if (status !== upload_1.UploadStatus.Success) {
|
50
|
+
throw new Error("Error uploading commit information.");
|
51
|
+
}
|
52
|
+
return { hash: payload.hash, remote: payload.remote };
|
53
|
+
}
|
54
|
+
catch (error) {
|
55
|
+
throw error;
|
56
|
+
}
|
57
|
+
});
|
58
|
+
}
|
59
|
+
getRequestBuilder() {
|
60
|
+
if (!this.apiKey) {
|
61
|
+
throw new errors_1.InvalidConfigurationError("Missing DATADOG_API_KEY in your environment.");
|
62
|
+
}
|
63
|
+
return (0, utils_1.getRequestBuilder)({
|
64
|
+
apiKey: this.apiKey,
|
65
|
+
baseUrl: "https://sourcemap-intake." + this.datadogSite,
|
66
|
+
});
|
67
|
+
}
|
68
|
+
uploadRepository(requestBuilder) {
|
69
|
+
return (commitInfo, opts) => __awaiter(this, void 0, void 0, function* () {
|
70
|
+
const payload = commitInfo.asMultipartPayload(`serverless-plugin-datadog-${package_json_1.version}`);
|
71
|
+
return (0, upload_1.upload)(requestBuilder)(payload, opts);
|
72
|
+
});
|
73
|
+
}
|
74
|
+
}
|
75
|
+
exports.SourceCodeIntegration = SourceCodeIntegration;
|
76
|
+
//# sourceMappingURL=source-code-integration.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"source-code-integration.js","sourceRoot":"","sources":["../../src/source-code-integration.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,kDAA0C;AAC1C,+BAAsC;AAEtC,6CAAsD;AACtD,6CAA6D;AAE7D,6CAAuE;AACvE,2CAAoD;AAEpD,MAAa,qBAAqB;IAMhC,YAAY,MAAc,EAAE,WAAmB,EAAE,SAAoB,EAAE,aAAsB;QAC3F,IAAI,CAAC,M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AAC,MAAM,EAAE;YAChB,MAAM,IAAI,kCAAyB,CAAC,8CAA8C,CAAC,CAAC;SACrF;QAED,OAAO,IAAA,yBAAiB,EAAC;YACvB,MAAM,EAAE,IAAI,CAAC,MAAO;YACpB,OAAO,EAAE,2BAA2B,GAAG,IAAI,CAAC,WAAW;SACxD,CAAC,CAAC;IACL,CAAC;IAEO,gBAAgB,CACtB,cAA8B;QAE9B,OAAO,CAAO,UAAsB,EAAE,IAAmB,EAAE,EAAE;YAC3D,MAAM,OAAO,GAAG,UAAU,CAAC,kBAAkB,CAAC,6BAA6B,sBAAO,EAAE,CAAC,CAAC;YAEtF,OAAO,IAAA,eAAM,EAAC,cAAc,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC/C,CAAC,CAAA,CAAC;IACJ,CAAC;CACF;AAlED,sDAkEC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "serverless-plugin-datadog",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.6.0",
|
4
4
|
"description": "Serverless plugin to automatically instrument python and node functions with datadog tracing",
|
5
5
|
"main": "dist/src/index.js",
|
6
6
|
"repository": "https://github.com/DataDog/serverless-plugin-datadog",
|