Skip to content

Commit

Permalink
Log empty values to OTEL (#1326)
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztofzuraw committed Apr 26, 2024
1 parent 3039e7b commit eec2552
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-roses-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@saleor/apps-logger": patch
---

Send empty keys to OTEL. Thanks to that change our queries that consume OTEL will have access to falsy values.
11 changes: 2 additions & 9 deletions packages/logger/src/logger-otel-transport.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ILogObj, Logger } from "tslog";
import { LogAttributeValue, logs } from "@opentelemetry/api-logs";
import { context } from "@opentelemetry/api";
import { LogAttributeValue, logs } from "@opentelemetry/api-logs";
import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions";
import { ILogObj, Logger } from "tslog";
import { LoggerContext } from "./logger-context";

export const attachLoggerOtelTransport = (
Expand Down Expand Up @@ -29,13 +29,6 @@ export const attachLoggerOtelTransport = (
...attributes,
}).reduce(
(acc, [key, value]) => {
/**
* Prune empty keys, to save bandwidth
*/
if (!value) {
return acc;
}

if (Array.isArray(value)) {
acc[key] = JSON.stringify(value);
} else {
Expand Down

0 comments on commit eec2552

Please sign in to comment.