Skip to content

Commit

Permalink
Update Dependencies (#93)
Browse files Browse the repository at this point in the history
* Update dependencies
* Run latest prettier version for src dir

Co-authored-by: DarcyRaynerDD <[email protected]>
Co-authored-by: hghotra <[email protected]>
  • Loading branch information
3 people authored Aug 20, 2020
1 parent 69adaa9 commit 4360286
Show file tree
Hide file tree
Showing 12 changed files with 1,361 additions and 1,192 deletions.
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@
"check-formatting": "prettier --check src/**"
},
"devDependencies": {
"@types/aws-lambda": "^8.10.46",
"@types/aws-lambda": "^8.10.61",
"@types/aws-sdk": "^2.7.0",
"@types/jest": "^25.1.4",
"@types/jest": "^26.0.10",
"@types/nock": "^11.1.0",
"@types/node": "^13.9.1",
"@types/node": "^14.6.0",
"@types/promise-retry": "^1.1.3",
"@types/shimmer": "^1.0.1",
"dd-trace": "0.23.2",
"jest": "^25.1.0",
"nock": "12.0.2",
"prettier": "^1.19.1",
"ts-jest": "^25.2.1",
"tslint": "^6.1.0",
"typescript": "^3.8.3"
"dd-trace": "0.24.1",
"jest": "^26.4.1",
"nock": "13.0.4",
"prettier": "^2.0.5",
"ts-jest": "^26.2.0",
"tslint": "^6.1.3",
"typescript": "^3.9.7"
},
"dependencies": {
"aws-xray-sdk-core": "^3.0.0",
"aws-xray-sdk-core": "^3.1.0",
"bignumber.js": "^9.0.0",
"promise-retry": "^1.1.1",
"promise-retry": "^2.0.1",
"serialize-error": "^7.0.1",
"shimmer": "^1.2.1"
},
Expand Down
8 changes: 2 additions & 6 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ describe("datadog", () => {
});

it("patches http request when autoPatch enabled", async () => {
nock("http://www.example.com")
.get("/")
.reply(200, {});
nock("http://www.example.com").get("/").reply(200, {});
const wrapped = datadog(handler, { forceWrap: true });
await wrapped(
{
Expand All @@ -81,9 +79,7 @@ describe("datadog", () => {
expect(sampled).toEqual("2");
});
it("doesn't patch http requests when autoPatch is disabled", async () => {
nock("http://www.example.com")
.get("/")
.reply(200, {});
nock("http://www.example.com").get("/").reply(200, {});
const wrapped = datadog(handler, { autoPatchHTTP: false, forceWrap: true });
await wrapped(
{
Expand Down
12 changes: 10 additions & 2 deletions src/metrics/api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@ describe("APIClient", () => {
const input: APIMetric[] = [
{
metric: "a-metric",
points: [[1, [2]], [3, [4]], [5, [6]]],
points: [
[1, [2]],
[3, [4]],
[5, [6]],
],
tags: ["a", "b", "c"],
type: "distribution",
},
{
metric: "b-metric",
points: [[1, [2]], [3, [4]], [5, [6]]],
points: [
[1, [2]],
[3, [4]],
[5, [6]],
],
tags: ["a", "b", "c"],
type: "distribution",
},
Expand Down
21 changes: 17 additions & 4 deletions src/metrics/batcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ describe("Batcher", () => {
const timestamp = new Date(1559928315000);
const distribution1 = new Distribution(
"my-dist",
[{ timestamp, value: 1 }, { timestamp, value: 2 }],
[
{ timestamp, value: 1 },
{ timestamp, value: 2 },
],
"tag:a",
"tag:b",
"tag:c",
Expand All @@ -20,7 +23,11 @@ describe("Batcher", () => {
expect(metrics).toEqual([
{
metric: "my-dist",
points: [[1559928315, [1]], [1559928315, [2]], [1559928315, [3]]],
points: [
[1559928315, [1]],
[1559928315, [2]],
[1559928315, [3]],
],
tags: ["tag:a", "tag:b", "tag:c"],
type: "distribution",
},
Expand All @@ -32,7 +39,10 @@ describe("Batcher", () => {
const timestamp = new Date(1559928315000);
const distribution1 = new Distribution(
"my-dist",
[{ timestamp, value: 1 }, { timestamp, value: 2 }],
[
{ timestamp, value: 1 },
{ timestamp, value: 2 },
],
"tag:a",
"tag:b",
"tag:c",
Expand All @@ -45,7 +55,10 @@ describe("Batcher", () => {
expect(metrics).toEqual([
{
metric: "my-dist",
points: [[1559928315, [1]], [1559928315, [2]]],
points: [
[1559928315, [1]],
[1559928315, [2]],
],
tags: ["tag:a", "tag:b", "tag:c"],
type: "distribution",
},
Expand Down
8 changes: 2 additions & 6 deletions src/metrics/listener.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ describe("MetricsListener", () => {
});

it("uses unencrypted api key by default", async () => {
nock("https://api.example.com")
.post("/api/v1/distribution_points?api_key=api-key")
.reply(200, {});
nock("https://api.example.com").post("/api/v1/distribution_points?api_key=api-key").reply(200, {});

const kms = new MockKMS("kms-api-key-decrypted");
const listener = new MetricsListener(kms as any, {
Expand All @@ -44,9 +42,7 @@ describe("MetricsListener", () => {
expect(nock.isDone()).toBeTruthy();
});
it("uses encrypted kms key if it's the only value available", async () => {
nock("https://api.example.com")
.post("/api/v1/distribution_points?api_key=kms-api-key-decrypted")
.reply(200, {});
nock("https://api.example.com").post("/api/v1/distribution_points?api_key=kms-api-key-decrypted").reply(200, {});

const kms = new MockKMS("kms-api-key-decrypted");
const listener = new MetricsListener(kms as any, {
Expand Down
4 changes: 3 additions & 1 deletion src/metrics/metric-log.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ describe("buildMetricLog", () => {
);
});
it("writes timestamp in Unix seconds", () => {
expect(buildMetricLog("my.test.metric", 1337, new Date(1487076708123), ["region:us", "account:dev", "team:serverless"])).toStrictEqual(
expect(
buildMetricLog("my.test.metric", 1337, new Date(1487076708123), ["region:us", "account:dev", "team:serverless"]),
).toStrictEqual(
'{"e":1487076708.123,"m":"my.test.metric","t":["region:us","account:dev","team:serverless"],"v":1337}\n',
);
});
Expand Down
23 changes: 19 additions & 4 deletions src/metrics/model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ describe("Distribution", () => {

const distribution = new Distribution(
"my-dist",
[{ timestamp, value: 1 }, { timestamp, value: 2 }, { timestamp, value: 3 }],
[
{ timestamp, value: 1 },
{ timestamp, value: 2 },
{ timestamp, value: 3 },
],
"tag:a",
"tag:b",
"tag:c",
Expand All @@ -16,7 +20,11 @@ describe("Distribution", () => {
expect(result).toEqual([
{
metric: "my-dist",
points: [[1559928315, [1]], [1559928315, [2]], [1559928315, [3]]],
points: [
[1559928315, [1]],
[1559928315, [2]],
[1559928315, [3]],
],
tags: ["tag:a", "tag:b", "tag:c"],
type: "distribution",
},
Expand All @@ -27,14 +35,21 @@ describe("Distribution", () => {

const distribution1 = new Distribution(
"my-dist",
[{ timestamp, value: 1 }, { timestamp, value: 2 }],
[
{ timestamp, value: 1 },
{ timestamp, value: 2 },
],
"tag:a",
"tag:b",
"tag:c",
);
const distribution2 = new Distribution("my-dist", [{ timestamp, value: 3 }], "tag:a", "tag:b", "tag:c");
const distribution3 = distribution1.union(distribution2);

expect(distribution3.points).toEqual([{ timestamp, value: 1 }, { timestamp, value: 2 }, { timestamp, value: 3 }]);
expect(distribution3.points).toEqual([
{ timestamp, value: 1 },
{ timestamp, value: 2 },
{ timestamp, value: 3 },
]);
});
});
21 changes: 17 additions & 4 deletions src/metrics/processor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ describe("Processor", () => {
[
{
metric: "my-metric",
points: [[1559941498, [1]], [1559941498, [2]]],
points: [
[1559941498, [1]],
[1559941498, [2]],
],
tags: ["tag:a", "tag:b"],
type: "distribution",
},
Expand Down Expand Up @@ -83,7 +86,10 @@ describe("Processor", () => {
[
{
metric: "my-metric",
points: [[1559941498, [1]], [1559941498, [2]]],
points: [
[1559941498, [1]],
[1559941498, [2]],
],
tags: ["tag:a", "tag:b"],
type: "distribution",
},
Expand All @@ -104,7 +110,10 @@ describe("Processor", () => {
[
{
metric: "my-metric",
points: [[1559941498, [1]], [1559941498, [2]]],
points: [
[1559941498, [1]],
[1559941498, [2]],
],
tags: ["tag:a", "tag:b"],
type: "distribution",
},
Expand Down Expand Up @@ -133,7 +142,11 @@ describe("Processor", () => {
[
{
metric: "my-metric",
points: [[1559941498, [1]], [1559941498, [2]], [1559941498, [3]]],
points: [
[1559941498, [1]],
[1559941498, [2]],
[1559941498, [3]],
],
tags: ["tag:a", "tag:b"],
type: "distribution",
},
Expand Down
2 changes: 1 addition & 1 deletion src/trace/listener.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ describe("TraceListener", () => {
function_arn: "arn:aws:lambda:us-east-1:123456789101:function:my-lambda",
function_version: "$LATEST",
request_id: "1234",
resource_names: "my-lambda"
resource_names: "my-lambda",
},
type: "serverless",
},
Expand Down
43 changes: 11 additions & 32 deletions src/trace/patch-http.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ import { patchHttp, unpatchHttp } from "./patch-http";
import { TraceContextService } from "./trace-context-service";

describe("patchHttp", () => {

let traceWrapper = {
isTracerAvailable: false,
extract: () => null,
wrap: (fn: any) => fn,
traceContext: () => undefined
traceContext: () => undefined,
};

let contextService: TraceContextService;
Expand Down Expand Up @@ -42,43 +41,33 @@ describe("patchHttp", () => {
});

it("injects tracing headers into requests", () => {
nock("http://www.example.com")
.get("/")
.reply(200, {});
nock("http://www.example.com").get("/").reply(200, {});

patchHttp(contextService);
const req = http.request("http://www.example.com");
expectHeaders(req);
});
it("injects tracing headers into get requests", () => {
nock("http://www.example.com")
.get("/")
.reply(200, {});
nock("http://www.example.com").get("/").reply(200, {});
patchHttp(contextService);
const req = http.get("http://www.example.com");
expectHeaders(req);
});
it("injects tracing headers into https requests", () => {
nock("https://www.example.com")
.get("/")
.reply(200, {});
nock("https://www.example.com").get("/").reply(200, {});
patchHttp(contextService);
const req = https.request("https://www.example.com");
expectHeaders(req);
});
it("injects tracing headers into https get requests", () => {
nock("https://www.example.com")
.get("/")
.reply(200, {});
nock("https://www.example.com").get("/").reply(200, {});
patchHttp(contextService);
const req = https.get("https://www.example.com");
expectHeaders(req);
});

it("injects tracing headers when using request options", () => {
nock("http://www.example.com")
.get("/")
.reply(200, {});
nock("http://www.example.com").get("/").reply(200, {});
patchHttp(contextService);
const opt: RequestOptions = {
headers: { "some-header": "some-value" },
Expand All @@ -91,9 +80,7 @@ describe("patchHttp", () => {
expect(headers["some-header"]).toEqual("some-value");
});
it("injects tracing headers when using request options and path", () => {
nock("http://www.example.com")
.get("/")
.reply(200, {});
nock("http://www.example.com").get("/").reply(200, {});
patchHttp(contextService);
const opt: RequestOptions = {
headers: { "some-header": "some-value" },
Expand All @@ -104,18 +91,14 @@ describe("patchHttp", () => {
expect(headers["some-header"]).toEqual("some-value");
});
it("injects tracing headers when using URL", () => {
nock("http://www.example.com")
.get("/")
.reply(200, {});
nock("http://www.example.com").get("/").reply(200, {});
patchHttp(contextService);
const url = parse("http://www.example.com");
const req = http.request(url);
expectHeaders(req);
});
it("passes callback through to request", (done) => {
nock("http://www.example.com")
.get("/")
.reply(200, {});
nock("http://www.example.com").get("/").reply(200, {});
patchHttp(contextService);
const req = http.request("http://www.example.com", () => {
done();
Expand All @@ -124,9 +107,7 @@ describe("patchHttp", () => {
expectHeaders(req);
});
it("passes callback through to request with request options", (done) => {
nock("http://www.example.com")
.get("/")
.reply(200, {});
nock("http://www.example.com").get("/").reply(200, {});
patchHttp(contextService);
const options = {
headers: { "some-header": "a-value" },
Expand All @@ -140,9 +121,7 @@ describe("patchHttp", () => {
expect(headers["some-header"]).toEqual("a-value");
});
it("doesn't inject tracing headers when context is empty", () => {
nock("http://www.example.com")
.get("/")
.reply(200, {});
nock("http://www.example.com").get("/").reply(200, {});

contextService.rootTraceContext = undefined;
patchHttp(contextService);
Expand Down
Loading

0 comments on commit 4360286

Please sign in to comment.