-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add configurable log processing parameters to telemetry system #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
32a4c7e
14bff79
5eea383
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,21 @@ | ||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||
| * Parse a numeric environment variable with optional minimum bound. | ||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||
| export function parseNumberEnv(value: string | undefined, minimum: number = 0): number | undefined { | ||||||||||||||||||||||||||||
| if (value === undefined) return undefined | ||||||||||||||||||||||||||||
| const parsed = Number(value) | ||||||||||||||||||||||||||||
| if (!Number.isFinite(parsed) || parsed < minimum) return undefined | ||||||||||||||||||||||||||||
| return parsed | ||||||||||||||||||||||||||||
|
Comment on lines
+4
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Find the file and examine its structure
find . -type f -name "utils.ts" | grep -i telemetryRepository: iii-hq/sdk Length of output: 103 🏁 Script executed: # Also check the overall structure of the packages/node directory
git ls-files packages/node/ | head -30Repository: iii-hq/sdk Length of output: 1209 🏁 Script executed: # Search for parseNumberEnv usage across the codebase
rg -l "parseNumberEnv" --type=tsRepository: iii-hq/sdk Length of output: 149 🏁 Script executed: # Read the utils.ts file to see the implementation
cat -n packages/node/iii/src/telemetry-system/utils.tsRepository: iii-hq/sdk Length of output: 840 🏁 Script executed: # Check the index.ts to see how parseNumberEnv is used
cat -n packages/node/iii/src/telemetry-system/index.tsRepository: iii-hq/sdk Length of output: 11461 🏁 Script executed: # Search for all usages of parseNumberEnv with context
rg -n "parseNumberEnv" -C5 --type=tsRepository: iii-hq/sdk Length of output: 3660 🏁 Script executed: # Search for test files related to this utility
find . -type f \( -name "*test*" -o -name "*spec*" \) -path "*/telemetry-system/*" | head -20Repository: iii-hq/sdk Length of output: 36 🏁 Script executed: # Search for test files in the entire packages/node/iii directory
find packages/node/iii -type f \( -name "*.test.ts" -o -name "*.spec.ts" \)Repository: iii-hq/sdk Length of output: 581 🏁 Script executed: # Search for any tests referencing parseNumberEnv or parseIntegerEnv
rg -n "(parseNumberEnv|parseIntegerEnv)" --type=ts -g "*test*" -g "*spec*"Repository: iii-hq/sdk Length of output: 36 🏁 Script executed: # Check DEFAULT_OTEL_CONFIG to understand the defaults
rg -n "DEFAULT_OTEL_CONFIG\|logsFlushIntervalMs\|logsBatchSize" --type=ts -B2 -A2Repository: iii-hq/sdk Length of output: 36 🏁 Script executed: # Check if there are any guards before the parseNumberEnv calls
rg -n "OTEL_LOGS_FLUSH_INTERVAL_MS\|OTEL_LOGS_BATCH_SIZE" --type=ts -B3 -A3Repository: iii-hq/sdk Length of output: 36 🏁 Script executed: # Look at the otel-defaults test file
cat -n packages/node/iii/tests/otel-defaults.test.tsRepository: iii-hq/sdk Length of output: 9587 🏁 Script executed: # Search for DEFAULT_OTEL_CONFIG definition
rg -n "DEFAULT_OTEL_CONFIG" --type=tsRepository: iii-hq/sdk Length of output: 1386 🏁 Script executed: # Search for logsFlushIntervalMs and logsBatchSize in types.ts
cat packages/node/iii/src/telemetry-system/types.tsRepository: iii-hq/sdk Length of output: 3960 🏁 Script executed: # Test JavaScript Number coercion behavior to confirm the claim
node -e "console.log('Number(\"\") =', Number('')); console.log('Number(\" \") =', Number(' ')); console.log('Number(\"0\") =', Number('0')); console.log('Number(\"abc\") =', Number('abc'))"Repository: iii-hq/sdk Length of output: 122 Add empty-string validation before numeric coercion in parseNumberEnv. Environment variables like Currently called on lines 172 and 176 of index.ts with no upstream guards. Proposed fix export function parseNumberEnv(value: string | undefined, minimum: number = 0): number | undefined {
if (value === undefined) return undefined
- const parsed = Number(value)
+ const normalized = value.trim()
+ if (normalized.length === 0) return undefined
+ const parsed = Number(normalized)
if (!Number.isFinite(parsed) || parsed < minimum) return undefined
return parsed
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||
| * Parse an integer environment variable with optional minimum bound. | ||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||
| export function parseIntegerEnv( | ||||||||||||||||||||||||||||
| value: string | undefined, | ||||||||||||||||||||||||||||
| minimum: number = 0, | ||||||||||||||||||||||||||||
| ): number | undefined { | ||||||||||||||||||||||||||||
| const parsed = parseNumberEnv(value, minimum) | ||||||||||||||||||||||||||||
| if (parsed === undefined || !Number.isInteger(parsed)) return undefined | ||||||||||||||||||||||||||||
| return parsed | ||||||||||||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.