Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
rouzwelt committed Jan 26, 2025
1 parent 5e978f1 commit 2216885
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/modes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,21 @@ export async function findOpp({
if ((allResults[0] as any)?.reason?.spanAttributes) {
extendSpanAttributes(
spanAttributes,
JSON.stringify((allResults[0] as any).reason.spanAttributes),
(allResults[0] as any).reason.spanAttributes,
"routeProcessor",
);
}
if ((allResults[1] as any)?.reason?.spanAttributes) {
extendSpanAttributes(
spanAttributes,
JSON.stringify((allResults[1] as any).reason.spanAttributes),
(allResults[1] as any).reason.spanAttributes,
"intraOrderbook",
);
}
if ((allResults[2] as any)?.reason?.spanAttributes) {
extendSpanAttributes(
spanAttributes,
JSON.stringify((allResults[2] as any).reason.spanAttributes),
(allResults[2] as any).reason.spanAttributes,
"interOrderbook",
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/modes/interOrderbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ export async function findOpp({
for (let i = 0; i < e.errors.length; i++) {
extendSpanAttributes(
spanAttributes,
JSON.stringify(e.errors[i].spanAttributes),
e.errors[i].spanAttributes,
"againstOrderbooks." + opposingOrderbookOrders[i].orderbook,
);
}
Expand Down
6 changes: 1 addition & 5 deletions src/modes/intraOrderbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,7 @@ export async function findOpp({
});
} catch (e: any) {
allNoneNodeErrors.push(e?.value?.noneNodeError);
extendSpanAttributes(
spanAttributes,
JSON.stringify(e.spanAttributes),
"intraOrderbook." + i,
);
extendSpanAttributes(spanAttributes, e.spanAttributes, "intraOrderbook." + i);
}
}
const noneNodeErrors = allNoneNodeErrors.filter((v) => !!v);
Expand Down
4 changes: 2 additions & 2 deletions src/modes/routeProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ export async function findOpp({
// the fail reason can only be no route in case all hops fail reasons are no route
if (e.reason !== RouteProcessorDryrunHaltReason.NoRoute) noRoute = false;
allNoneNodeErrors.push(e?.value?.noneNodeError);
extendSpanAttributes(spanAttributes, JSON.stringify(e.spanAttributes), "full");
extendSpanAttributes(spanAttributes, e.spanAttributes, "full");
}
if (!hasPriceMatch.value) {
const maxTradeSize = findMaxInput({
Expand Down Expand Up @@ -398,7 +398,7 @@ export async function findOpp({
// the fail reason can only be no route in case all hops fail reasons are no route
if (e.reason !== RouteProcessorDryrunHaltReason.NoRoute) noRoute = false;
allNoneNodeErrors.push(e?.value?.noneNodeError);
extendSpanAttributes(spanAttributes, JSON.stringify(e.spanAttributes), "partial");
extendSpanAttributes(spanAttributes, e.spanAttributes, "partial");
}
}
}
Expand Down
10 changes: 4 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1405,17 +1405,15 @@ export function scale18To(value: BigNumberish, targetDecimals: BigNumberish): Bi
*/
export function extendSpanAttributes(
spanAttributes: Record<string, any>,
newAttributes: string,
newAttributes: Record<string, any>,
header: string,
excludeHeaderForKeys: string[] = [],
) {
const attrs = JSON.parse(newAttributes);
for (const attrKey in attrs) {
for (const attrKey in newAttributes) {
if (!excludeHeaderForKeys.includes(attrKey)) {
spanAttributes[header + "." + attrKey] = attrs[attrKey];
spanAttributes[header + "." + attrKey] = newAttributes[attrKey];
} else {
spanAttributes[attrKey] = attrs[attrKey];
spanAttributes[attrKey] = newAttributes[attrKey];
}
delete attrs[attrKey];
}
}

0 comments on commit 2216885

Please sign in to comment.