Skip to content

The open-source app everyone uses to manage agents at work

1.5 KB
Raw Blame
import { webcrypto } from "node:crypto";
import { describe, expect, it } from "vitest";
import {
  HONEYCOMB_RUN_HASH_ATTRIBUTE,
  buildHoneycombRunQueryUrl,
  hashPaperclipRunId,
} from "./honeycomb-run-link";

describe("Honeycomb run links", () => {
  it("uses the same 12-character SHA-256 run hash as the tracer", async () => {
    await expect(
      hashPaperclipRunId("abc", webcrypto.subtle as unknown as SubtleCrypto),
    ).resolves.toBe("ba7816bf8f01");
  });

  it("finds native and legacy root spans for the exact run with clickable trace-id breakdowns", () => {
    const url = new URL(buildHoneycombRunQueryUrl("ba7816bf8f01"));
    const query = JSON.parse(url.searchParams.get("query") ?? "null") as {
      calculations: Array<{ op: string }>;
      breakdowns: string[];
      filters: Array<{ column: string; op: string; value: string | string[] }>;
      filter_combination: string;
    };

    expect(url.origin).toBe("https://ui.honeycomb.io");
    expect(url.pathname).toBe(
      "/paperclip/environments/test/datasets/paperclip/",
    );
    expect(query.calculations).toEqual([{ op: "COUNT" }]);
    expect(query.breakdowns).toEqual(["trace.trace_id"]);
    expect(query.filter_combination).toBe("AND");
    expect(query.filters).toEqual([
      { column: "service.name", op: "=", value: "paperclip" },
      { column: "name", op: "in", value: ["task.run", "task.provider_session", "task.execution_attempt"] },
      {
        column: HONEYCOMB_RUN_HASH_ATTRIBUTE,
        op: "=",
        value: "ba7816bf8f01",
      },
    ]);
  });
});