serverless-plugin-datadog 5.11.0 → 5.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. package/README.md +1 -1
  2. package/dist/package.json +1 -1
  3. package/dist/src/git-metadata/interfaces.d.ts +10 -0
  4. package/dist/src/git-metadata/interfaces.d.ts.map +1 -0
  5. package/dist/src/git-metadata/interfaces.js +43 -0
  6. package/dist/src/git-metadata/interfaces.js.map +1 -0
  7. package/dist/src/helpers/apikey.d.ts +13 -0
  8. package/dist/src/helpers/apikey.d.ts.map +1 -0
  9. package/dist/src/helpers/apikey.js +74 -0
  10. package/dist/src/helpers/apikey.js.map +1 -0
  11. package/dist/src/helpers/errors.d.ts +3 -0
  12. package/dist/src/helpers/errors.d.ts.map +1 -0
  13. package/dist/src/helpers/errors.js +7 -0
  14. package/dist/src/helpers/errors.js.map +1 -0
  15. package/dist/src/helpers/interfaces.d.ts +20 -0
  16. package/dist/src/helpers/interfaces.d.ts.map +1 -0
  17. package/dist/src/helpers/interfaces.js +3 -0
  18. package/dist/src/helpers/interfaces.js.map +1 -0
  19. package/dist/src/helpers/retry.d.ts +3 -0
  20. package/dist/src/helpers/retry.d.ts.map +1 -0
  21. package/dist/src/helpers/retry.js +39 -0
  22. package/dist/src/helpers/retry.js.map +1 -0
  23. package/dist/src/helpers/tags.d.ts +29 -0
  24. package/dist/src/helpers/tags.d.ts.map +1 -0
  25. package/dist/src/helpers/tags.js +50 -0
  26. package/dist/src/helpers/tags.js.map +1 -0
  27. package/dist/src/helpers/upload.d.ts +45 -0
  28. package/dist/src/helpers/upload.d.ts.map +1 -0
  29. package/dist/src/helpers/upload.js +70 -0
  30. package/dist/src/helpers/upload.js.map +1 -0
  31. package/dist/src/helpers/utils.d.ts +31 -0
  32. package/dist/src/helpers/utils.d.ts.map +1 -0
  33. package/dist/src/helpers/utils.js +115 -0
  34. package/dist/src/helpers/utils.js.map +1 -0
  35. package/dist/src/index.js +8 -1
  36. package/dist/src/index.js.map +1 -1
  37. package/dist/src/layer.d.ts.map +1 -1
  38. package/dist/src/layer.js +1 -0
  39. package/dist/src/layer.js.map +1 -1
  40. package/dist/src/layers-gov.json +22 -20
  41. package/dist/src/layers.json +277 -249
  42. package/dist/src/source-code-integration.d.ts +15 -0
  43. package/dist/src/source-code-integration.d.ts.map +1 -0
  44. package/dist/src/source-code-integration.js +76 -0
  45. package/dist/src/source-code-integration.js.map +1 -0
  46. package/package.json +1 -1
@@ -0,0 +1,15 @@
1
+ import { SimpleGit } from "simple-git";
2
+ export declare class SourceCodeIntegration {
3
+ repositoryURL?: string;
4
+ private apiKey;
5
+ private datadogSite;
6
+ private simpleGit;
7
+ constructor(apiKey: string, datadogSite: string, simpleGit: SimpleGit, repositoryURL?: string);
8
+ uploadGitMetadata(): Promise<{
9
+ hash: string;
10
+ remote: string;
11
+ }>;
12
+ private getRequestBuilder;
13
+ private uploadRepository;
14
+ }
15
+ //# sourceMappingURL=source-code-integration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-code-integration.d.ts","sourceRoot":"","sources":["../../src/source-code-integration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAUvC,qBAAa,qBAAqB;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAY;gBAEjB,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,CAAC,EAAE,MAAM;IAOhF,iBAAiB;;;;IAiC9B,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,gBAAgB;CASzB"}
@@ -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,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAEY,iBAAiB;;YAC5B,MAAM,eAAe,GAAG,IAAA,2BAAkB,EAAC;gBACzC,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,WAAW,EAAE,IAAI,CAAC,WAAW;aAC9B,CAAC,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAA,mBAAa,EAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;YACxE,IAAI,OAAO,KAAK,SAAS,EAAE;gBACzB,MAAM,KAAK,CAAC,sCAAsC,CAAC,CAAC;aACrD;YACD,IAAI;gBACF,MAAM,cAAc,GAAG,IAAI,C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,6 @@
1
1
  {
2
2
  "name": "serverless-plugin-datadog",
3
- "version": "5.11.0",
3
+ "version": "5.13.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",