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: Remove extension hello check as it's redundant #516

Merged
merged 4 commits into from
Mar 18, 2024
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
11 changes: 0 additions & 11 deletions src/metrics/extension.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,9 @@ describe("isAgentRunning", () => {
mock({
"/opt/extensions/datadog-agent": Buffer.from([0]),
});
const scope = nock(AGENT_URL).get("/lambda/hello").reply(200);
const ran = await isAgentRunning();
expect(scope.isDone()).toBeTruthy();
expect(ran).toBeTruthy();
});
it("returns false when agent doesn't respond", async () => {
mock({
"/opt/extensions/datadog-agent": Buffer.from([0]),
});
const scope = nock(AGENT_URL).get("/lambda/hello").replyWithError("Unreachable");
const ran = await isAgentRunning();
expect(scope.isDone()).toBeTruthy();
expect(ran).toBeFalsy();
});
it("returns false when agent doesn't exist", async () => {
mock({});
const scope = nock(AGENT_URL).get("/lambda/hello").replyWithError("Unreachable");
Expand Down
10 changes: 1 addition & 9 deletions src/metrics/extension.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { URL } from "url";
import { get, post, logDebug, logError } from "../utils";
import { post, logDebug, logError } from "../utils";
import fs from "fs";

export const AGENT_URL = "http://127.0.0.1:8124";
const HELLO_PATH = "/lambda/hello";
const FLUSH_PATH = "/lambda/flush";
const EXTENSION_PATH = "/opt/extensions/datadog-agent";
const AGENT_TIMEOUT_MS = 100;
Expand All @@ -14,13 +13,6 @@ export async function isAgentRunning() {
logDebug(`Agent isn't present in sandbox`);
return false;
}

const url = new URL(HELLO_PATH, AGENT_URL);
const result = await get(url, { timeout: AGENT_TIMEOUT_MS });
if (!result.success) {
logDebug(`Could not connect to agent. ${result.errorMessage}`);
return false;
}
return true;
}

Expand Down
2 changes: 0 additions & 2 deletions src/metrics/listener.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ describe("MetricsListener", () => {
expect(spy).toHaveBeenCalledWith(`{"e":1487076708,"m":"my-metric","t":["tag:a","tag:b"],"v":10}\n`);
});
it("always sends metrics to statsD when extension is enabled, ignoring logForwarding=true", async () => {
const helloScope = nock(AGENT_URL).get("/lambda/hello").reply(200);
const flushScope = nock(AGENT_URL).post("/lambda/flush", JSON.stringify({})).reply(200);
mock({
"/opt/extensions/datadog-agent": Buffer.from([0]),
Expand Down Expand Up @@ -135,7 +134,6 @@ describe("MetricsListener", () => {
await listener.onStartInvocation({});
listener.sendDistributionMetric("my-metric", 10, false, "tag:a", "tag:b");
await listener.onCompleteInvocation();
expect(helloScope.isDone()).toBeTruthy();
expect(flushScope.isDone()).toBeTruthy();
expect(distributionMock).toHaveBeenCalledWith("my-metric", 10, undefined, ["tag:a", "tag:b"]);
});
Expand Down
Loading