Skip to content

Commit 715e7df

Browse files
authored
Optionally log the selector in our spans, so we can track down which queries are slow. (#1874)
* Optionally log the selector in our spans, so we can track down which queries are slow. * Move the selectSchema mesage to the space.querySchema span instead of the space.instance.querySchema. * Added integration test to check the timing, though this is standalone enough that it could be a unit test. This data was captured from a real charm with a slow query. * Remove unused selection tracker for now
1 parent 23699be commit 715e7df

File tree

3 files changed

+11751
-4
lines changed

3 files changed

+11751
-4
lines changed

packages/memory/space-schema.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ export class ServerObjectManager extends BaseObjectManager<
151151
export const selectSchema = <Space extends MemorySpace>(
152152
session: Session<Space>,
153153
{ selectSchema, since, classification }: SchemaQuery["args"],
154-
selectionTracker?: MapSet<string, SchemaPathSelector>,
155154
): FactSelection => {
156155
const startTime = performance.timeOrigin + performance.now();
157156

@@ -178,9 +177,6 @@ export const selectSchema = <Space extends MemorySpace>(
178177
};
179178
const matchingFacts = getMatchingFacts(session, factSelector);
180179
for (const entry of matchingFacts) {
181-
const factKey = manager.toKey(entry.address);
182-
// TODO(@ubik2): need to remove this or schemaTracker
183-
selectionTracker?.add(factKey, selectorEntry.value);
184180
// The top level facts we accessed should be included
185181
addToSelection(includedFacts, entry, entry.cause, entry.since);
186182

packages/memory/space.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,10 @@ export const querySchema = <Space extends MemorySpace>(
887887

888888
if (command.args?.selectSchema) {
889889
span.setAttribute("querySchema.has_selector", true);
890+
span.setAttribute(
891+
"querySchema.selectSchema",
892+
JSON.stringify(command.args.selectSchema),
893+
);
890894
}
891895
if (command.args?.since !== undefined) {
892896
span.setAttribute("querySchema.since", command.args.since);

0 commit comments

Comments
 (0)