Skip to content

Commit

Permalink
fix: tagObject to avoid ignoring booleans (#388)
Browse files Browse the repository at this point in the history
* fix `tagObject` to not ignore booleans

* lint
  • Loading branch information
duncanista authored May 3, 2023
1 parent 14f4be7 commit 22627ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/utils/tag-object.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,22 @@ describe("tagObject", () => {
keyOne: "foobar",
myObject: {
anotherKey: ["array", "of", "values"],
nestedBoolean: false,
},
val: null,
number: 1,
aBoolean: true,
},
});
expect(setTag.mock.calls).toEqual([
["lambda_payload.request.keyOne", "foobar"],
["lambda_payload.request.myObject.anotherKey.0", "array"],
["lambda_payload.request.myObject.anotherKey.1", "of"],
["lambda_payload.request.myObject.anotherKey.2", "values"],
["lambda_payload.request.myObject.nestedBoolean", false],
["lambda_payload.request.val", null],
["lambda_payload.request.number", 1],
["lambda_payload.request.aBoolean", true],
]);
});
it("tags arrays of objects", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/tag-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function tagObject(currentSpan: any, key: string, obj: any, depth = 0): a
}
return tagObject(currentSpan, key, parsed, depth);
}
if (typeof obj === "number") {
if (typeof obj === "number" || typeof obj === "boolean") {
return currentSpan.setTag(key, obj);
}
if (typeof obj === "object") {
Expand Down

0 comments on commit 22627ab

Please sign in to comment.