diff --git a/src/metrics/extension.spec.ts b/src/metrics/extension.spec.ts index ebb72e07..25286f66 100644 --- a/src/metrics/extension.spec.ts +++ b/src/metrics/extension.spec.ts @@ -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"); diff --git a/src/metrics/extension.ts b/src/metrics/extension.ts index 52ec252d..67bcf0d0 100644 --- a/src/metrics/extension.ts +++ b/src/metrics/extension.ts @@ -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; @@ -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; } diff --git a/src/metrics/listener.spec.ts b/src/metrics/listener.spec.ts index 24a57f84..eaf31575 100644 --- a/src/metrics/listener.spec.ts +++ b/src/metrics/listener.spec.ts @@ -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]), @@ -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"]); });