Skip to content

Commit 904d2e9

Browse files
astuyveduncanista
andauthored
feat: Remove extension hello check as it's redundant (#516)
* feat: Remove extension hello check as it's redundant * feat: lint --------- Co-authored-by: jordan gonzález <[email protected]>
1 parent 9c44eab commit 904d2e9

File tree

3 files changed

+1
-22
lines changed

3 files changed

+1
-22
lines changed

src/metrics/extension.spec.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,9 @@ describe("isAgentRunning", () => {
1111
mock({
1212
"/opt/extensions/datadog-agent": Buffer.from([0]),
1313
});
14-
const scope = nock(AGENT_URL).get("/lambda/hello").reply(200);
1514
const ran = await isAgentRunning();
16-
expect(scope.isDone()).toBeTruthy();
1715
expect(ran).toBeTruthy();
1816
});
19-
it("returns false when agent doesn't respond", async () => {
20-
mock({
21-
"/opt/extensions/datadog-agent": Buffer.from([0]),
22-
});
23-
const scope = nock(AGENT_URL).get("/lambda/hello").replyWithError("Unreachable");
24-
const ran = await isAgentRunning();
25-
expect(scope.isDone()).toBeTruthy();
26-
expect(ran).toBeFalsy();
27-
});
2817
it("returns false when agent doesn't exist", async () => {
2918
mock({});
3019
const scope = nock(AGENT_URL).get("/lambda/hello").replyWithError("Unreachable");

src/metrics/extension.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { URL } from "url";
2-
import { get, post, logDebug, logError } from "../utils";
2+
import { post, logDebug, logError } from "../utils";
33
import fs from "fs";
44

55
export const AGENT_URL = "http://127.0.0.1:8124";
6-
const HELLO_PATH = "/lambda/hello";
76
const FLUSH_PATH = "/lambda/flush";
87
const EXTENSION_PATH = "/opt/extensions/datadog-agent";
98
const AGENT_TIMEOUT_MS = 100;
@@ -14,13 +13,6 @@ export async function isAgentRunning() {
1413
logDebug(`Agent isn't present in sandbox`);
1514
return false;
1615
}
17-
18-
const url = new URL(HELLO_PATH, AGENT_URL);
19-
const result = await get(url, { timeout: AGENT_TIMEOUT_MS });
20-
if (!result.success) {
21-
logDebug(`Could not connect to agent. ${result.errorMessage}`);
22-
return false;
23-
}
2416
return true;
2517
}
2618

src/metrics/listener.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ describe("MetricsListener", () => {
105105
expect(spy).toHaveBeenCalledWith(`{"e":1487076708,"m":"my-metric","t":["tag:a","tag:b"],"v":10}\n`);
106106
});
107107
it("always sends metrics to statsD when extension is enabled, ignoring logForwarding=true", async () => {
108-
const helloScope = nock(AGENT_URL).get("/lambda/hello").reply(200);
109108
const flushScope = nock(AGENT_URL).post("/lambda/flush", JSON.stringify({})).reply(200);
110109
mock({
111110
"/opt/extensions/datadog-agent": Buffer.from([0]),
@@ -135,7 +134,6 @@ describe("MetricsListener", () => {
135134
await listener.onStartInvocation({});
136135
listener.sendDistributionMetric("my-metric", 10, false, "tag:a", "tag:b");
137136
await listener.onCompleteInvocation();
138-
expect(helloScope.isDone()).toBeTruthy();
139137
expect(flushScope.isDone()).toBeTruthy();
140138
expect(distributionMock).toHaveBeenCalledWith("my-metric", 10, undefined, ["tag:a", "tag:b"]);
141139
});

0 commit comments

Comments
 (0)