Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Move datadog hook back to before:package:createDeploymentArtifa… #404

Merged
merged 4 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,16 @@ custom:

- The Datadog Lambda Extension is now the default mechanism for transmitting telemetry to Datadog.

## Working with serverless-plugin-warmup
This library is compatible at best effort with [serverless-plugin-warmup](https://github.com/juanjoDiaz/serverless-plugin-warmup). If you want to exclude the warmer function from Datadog, use the `exclude` feature of this library.

To properly package your application, this plugin *must* be listed _after_ `serverless-plugin-warmup` in your `serverless.yml` file:
```yaml
plugins:
- serverless-plugin-warmup
- serverless-plugin-datadog
```

## Opening Issues

If you encounter a bug with this package, let us know by filing an issue! Before opening a new issue, please search the existing issues to avoid duplicates.
Expand Down
40 changes: 20 additions & 20 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe("ServerlessPlugin", () => {
};

const plugin = new ServerlessPlugin(serverless, {});
await plugin.hooks["after:package:initialize"]();
await plugin.hooks["before:package:createDeploymentArtifacts"]();
expect(serverless).toMatchObject({
service: {
functions: {
Expand Down Expand Up @@ -134,7 +134,7 @@ describe("ServerlessPlugin", () => {
};

const plugin = new ServerlessPlugin(serverless, {});
await plugin.hooks["after:package:initialize"]();
await plugin.hooks["before:package:createDeploymentArtifacts"]();
expect(serverless).toMatchObject({
service: {
functions: {
Expand Down Expand Up @@ -181,7 +181,7 @@ describe("ServerlessPlugin", () => {
};

const plugin = new ServerlessPlugin(serverless, {});
await plugin.hooks["after:package:initialize"]();
await plugin.hooks["before:package:createDeploymentArtifacts"]();
expect(serverless).toMatchObject({
service: {
functions: {
Expand Down Expand Up @@ -230,7 +230,7 @@ describe("ServerlessPlugin", () => {
};

const plugin = new ServerlessPlugin(serverless, {});
await plugin.hooks["after:package:initialize"]();
await plugin.hooks["before:package:createDeploymentArtifacts"]();
expect(serverless).toMatchObject({
service: {
functions: {
Expand Down Expand Up @@ -275,7 +275,7 @@ describe("ServerlessPlugin", () => {
};

const plugin = new ServerlessPlugin(serverless, {});
await plugin.hooks["after:package:initialize"]();
await plugin.hooks["before:package:createDeploymentArtifacts"]();
expect(serverless).toMatchObject({
service: {
functions: {
Expand Down Expand Up @@ -321,7 +321,7 @@ describe("ServerlessPlugin", () => {
};

const plugin = new ServerlessPlugin(serverless, {});
await plugin.hooks["after:package:initialize"]();
await plugin.hooks["before:package:createDeploymentArtifacts"]();
expect(serverless).toMatchObject({
service: {
functions: {
Expand Down Expand Up @@ -374,7 +374,7 @@ describe("ServerlessPlugin", () => {
};

const plugin = new ServerlessPlugin(serverless, {});
await plugin.hooks["after:package:initialize"]();
await plugin.hooks["before:package:createDeploymentArtifacts"]();
expect(serverless).toMatchObject({
service: {
functions: {
Expand Down Expand Up @@ -422,7 +422,7 @@ describe("ServerlessPlugin", () => {
};

const plugin = new ServerlessPlugin(serverless, {});
await plugin.hooks["after:package:initialize"]();
await plugin.hooks["before:package:createDeploymentArtifacts"]();
expect(serverless).toMatchObject({
service: {
functions: {
Expand Down Expand Up @@ -470,7 +470,7 @@ describe("ServerlessPlugin", () => {
};

const plugin = new ServerlessPlugin(serverless, {});
await plugin.hooks["after:package:initialize"]();
await plugin.hooks["before:package:createDeploymentArtifacts"]();
expect(serverless).toMatchObject({
service: {
functions: {
Expand Down Expand Up @@ -518,7 +518,7 @@ describe("ServerlessPlugin", () => {
};

const plugin = new ServerlessPlugin(serverless, {});
await plugin.hooks["after:package:initialize"]();
await plugin.hooks["before:package:createDeploymentArtifacts"]();
expect(serverless).toMatchObject({
service: {
functions: {
Expand Down Expand Up @@ -578,7 +578,7 @@ describe("ServerlessPlugin", () => {
let threwError: boolean = false;
let thrownErrorMessage: string | undefined;
try {
await plugin.hooks["after:package:initialize"]();
await plugin.hooks["before:package:createDeploymentArtifacts"]();
} catch (e) {
threwError = true;
if (e instanceof Error) {
Expand Down Expand Up @@ -620,7 +620,7 @@ describe("ServerlessPlugin", () => {
let threwError: boolean = false;
let thrownErrorMessage: string | undefined;
try {
await plugin.hooks["after:package:initialize"]();
await plugin.hooks["before:package:createDeploymentArtifacts"]();
} catch (e) {
threwError = true;
if (e instanceof Error) {
Expand Down Expand Up @@ -660,7 +660,7 @@ describe("ServerlessPlugin", () => {
let threwError: boolean = false;
let thrownErrorMessage: string | undefined;
try {
await plugin.hooks["after:package:initialize"]();
await plugin.hooks["before:package:createDeploymentArtifacts"]();
} catch (e) {
threwError = true;
if (e instanceof Error) {
Expand Down Expand Up @@ -700,7 +700,7 @@ describe("ServerlessPlugin", () => {
let threwError: boolean = false;
let thrownErrorMessage: string | undefined;
try {
await plugin.hooks["after:package:initialize"]();
await plugin.hooks["before:package:createDeploymentArtifacts"]();
} catch (e) {
threwError = true;
if (e instanceof Error) {
Expand Down Expand Up @@ -739,7 +739,7 @@ describe("ServerlessPlugin", () => {
let threwError: boolean = false;
let thrownErrorMessage: string | undefined;
try {
await plugin.hooks["after:package:initialize"]();
await plugin.hooks["before:package:createDeploymentArtifacts"]();
} catch (e) {
threwError = true;
if (e instanceof Error) {
Expand Down Expand Up @@ -783,7 +783,7 @@ describe("ServerlessPlugin", () => {
const plugin = new ServerlessPlugin(serverless, {});
let threwError: boolean = false;
try {
await plugin.hooks["after:package:initialize"]();
await plugin.hooks["before:package:createDeploymentArtifacts"]();
} catch (e) {
threwError = true;
if (e instanceof Error) {
Expand Down Expand Up @@ -822,7 +822,7 @@ describe("ServerlessPlugin", () => {
let threwError: boolean = false;
let thrownErrorMessage: string | undefined;
try {
await plugin.hooks["after:package:initialize"]();
await plugin.hooks["before:package:createDeploymentArtifacts"]();
} catch (e) {
threwError = true;
if (e instanceof Error) {
Expand Down Expand Up @@ -869,7 +869,7 @@ describe("ServerlessPlugin", () => {
const plugin = new ServerlessPlugin(serverless, {});
let threwError: boolean = false;
try {
await plugin.hooks["after:package:initialize"]();
await plugin.hooks["before:package:createDeploymentArtifacts"]();
} catch (e) {
threwError = true;
}
Expand Down Expand Up @@ -909,7 +909,7 @@ describe("ServerlessPlugin", () => {
const plugin = new ServerlessPlugin(serverless, {});
let threwError: boolean = false;
try {
await plugin.hooks["after:package:initialize"]();
await plugin.hooks["before:package:createDeploymentArtifacts"]();
} catch (e) {
threwError = true;
}
Expand Down Expand Up @@ -947,7 +947,7 @@ describe("ServerlessPlugin", () => {
let threwError: boolean = false;
let thrownErrorMessage: string | undefined;
try {
await plugin.hooks["after:package:initialize"]();
await plugin.hooks["before:package:createDeploymentArtifacts"]();
} catch (e) {
threwError = true;
if (e instanceof Error) {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module.exports = class ServerlessPlugin {
"after:datadog:generate:init": this.beforePackageFunction.bind(this),
"after:deploy:function:packageFunction": this.afterPackageFunction.bind(this),
"after:package:createDeploymentArtifacts": this.afterPackageFunction.bind(this),
"after:package:initialize": this.beforePackageFunction.bind(this),
"before:package:createDeploymentArtifacts": this.beforePackageFunction.bind(this),
"after:package:compileFunctions": this.afterPackageCompileFunctions.bind(this),
"before:deploy:function:packageFunction": this.beforePackageFunction.bind(this),
"before:offline:start:init": this.beforePackageFunction.bind(this),
Expand Down