Skip to content

Commit b02bfc2

Browse files
committed
only check parts of the string that are not going to get truncated
remove unnecessary taks
1 parent fc41b95 commit b02bfc2

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

apps/webapp/app/v3/otlpExporter.server.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -803,17 +803,19 @@ function truncateAndDetectUnpairedSurrogate(str: string, maximumLength: number):
803803
return truncatedString;
804804
}
805805

806-
const ASCII_ONLY_REGEX = /^[\x00-\x7F]*$/;
806+
const ASCII_ONLY_REGEX = /^[\p{ASCII}]*$/u;
807807

808808
function smartTruncateString(str: string, maximumLength: number): string {
809809
if (!str) return "";
810810
if (str.length <= maximumLength) return str;
811811

812-
if (ASCII_ONLY_REGEX.test(str)) {
812+
const checkLength = Math.min(str.length, maximumLength * 2 + 2);
813+
814+
if (ASCII_ONLY_REGEX.test(str.slice(0, checkLength))) {
813815
return str.slice(0, maximumLength);
814816
}
815817

816-
return [...str].slice(0, maximumLength).join("");
818+
return [...str.slice(0, checkLength)].slice(0, maximumLength).join("");
817819
}
818820

819821
function hasUnpairedSurrogateAtEnd(str: string): boolean {

references/hello-world/src/trigger/telemetry.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,6 @@ export const taskWithChildTasks = task({
5151
},
5252
});
5353

54-
export const taskWithBadLogString = task({
55-
id: "otel/task-with-bad-log-string",
56-
run: async (payload: any, { ctx }) => {
57-
logger.log("Hello, world!", {
58-
myString: "👋🏽 I’m Shelby, of Defense.\n\n𝐋𝐞𝐭'𝐬 𝐛𝐮𝐢𝐥𝐝 𝐭𝐡𝐞 \ud835",
59-
});
60-
61-
logger.log("Hello, world!", {
62-
myString:
63-
"👋🏽 I’m Shelby, an award-winning people leader, an award-winning people leader, an award-winning people leader, an award-winning people leader, an award-winning people leader, an award-winning people leader, an award-winning people leader, an award-winning people leader, an award-winning people leader, an award-winning people leader, an award-winning people leader, MIT-trained mathematician, and AI researcher, engineer, and speaker.\n\nI drive clarity, vision, and execution at the frontier of AI, empowering teams to build breakthrough technologies with real-world, enterprise impact. 💥\n\n🔹 35+ influential AI research publications across AI agents, LLMs, SLMs, and ML (see 𝘗𝘶𝘣𝘭𝘪𝘤𝘢𝘵𝘪𝘰𝘯𝘴 below)\n🔹 8+ years developing applied AI for Fortune 500 use cases\n🔹 10+ years hands-on engineering • 16+ years teaching & speaking with clarity\n🔹 Featured in VentureBeat, ZDNET, and more (see 𝘔𝘦𝘥𝘪𝘢 𝘊𝘰𝘷𝘦𝘳𝘢𝘨𝘦 below)\n🔹 30+ AI keynotes, talks, podcasts, and panels (see 𝘒𝘦𝘺𝘯𝘰𝘵𝘦𝘴 below)\n\nCurrently, I lead and manage a growing team of AI researchers and engineers at Salesforce. We push the boundaries of agentic AI, multi-agent systems, on-device AI, and efficient models.\n\nPreviously, I spent time in research andAI, and efficient models.\n\nPreviously, I spent time in research andAI, and efficient models.\n\nPreviously, I spent time in research andAI, and efficient models.\n\nPreviously, I spent time in research andAI, and efficient models.\n\nPreviously, I spent time in research andAI, and efficient models.\n\nPreviously, I spent time in research andAI, and efficient models.\n\nPreviously, I spent time in research andAI, and efficient models.\n\nPreviously, I spent time in research andAI, and efficient models.\n\nPreviously, I spent time in research and engineering at Intel, IBM Research, MITRE, and the Department of Defense.\n\n𝐋𝐞𝐭'𝐬 𝐛𝐮𝐢𝐥𝐝 𝐭𝐡𝐞 \ud835",
64-
});
65-
},
66-
});
67-
6854
export const generateLogsParentTask = task({
6955
id: "otel/generate-logs-parent",
7056
run: async (payload: any) => {

0 commit comments

Comments
 (0)