Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9,673 changes: 4,847 additions & 4,826 deletions connect-go/gen/proto/wg/cosmo/platform/v1/platform.pb.go

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions connect/src/wg/cosmo/platform/v1/platform_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4511,6 +4511,16 @@ export class GetOperationContentRequest extends Message<GetOperationContentReque
*/
hash = "";

/**
* @generated from field: string federated_graph_name = 2;
*/
federatedGraphName = "";

/**
* @generated from field: string namespace = 3;
*/
namespace = "";

constructor(data?: PartialMessage<GetOperationContentRequest>) {
super();
proto3.util.initPartial(data, this);
Expand All @@ -4520,6 +4530,8 @@ export class GetOperationContentRequest extends Message<GetOperationContentReque
static readonly typeName = "wg.cosmo.platform.v1.GetOperationContentRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "hash", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "federated_graph_name", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 3, name: "namespace", kind: "scalar", T: 9 /* ScalarType.STRING */ },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GetOperationContentRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '@wundergraph/cosmo-connect/dist/platform/v1/platform_pb';
import type { RouterOptions } from '../../routes.js';
import { enrichLogger, getLogger, handleError } from '../../util.js';
import { FederatedGraphRepository } from '../../repositories/FederatedGraphRepository.js';

// Get operation content by hash
// TODO: Specify daterange to improve clickhouse performance
Expand All @@ -30,12 +31,26 @@ export function getOperationContent(
};
}

const fedGraphRepo = new FederatedGraphRepository(logger, opts.db, authContext.organizationId);
const graph = await fedGraphRepo.byName(req.federatedGraphName, req.namespace);
if (!graph) {
return {
response: {
code: EnumStatusCode.ERR_NOT_FOUND,
details: `Federated graph '${req.federatedGraphName}' not found`,
},
operationContent: '',
};
}

const query = `
SELECT OperationContent as operationContent
FROM ${opts.chClient?.database}.gql_metrics_operations
WHERE OperationHash = '${req.hash}'
LIMIT 1 SETTINGS use_query_cache = true, query_cache_ttl = 2629800
`;
SELECT OperationContent as operationContent
FROM ${opts.chClient?.database}.gql_metrics_operations
WHERE OrganizationID = '${authContext.organizationId}'
AND FederatedGraphID = '${graph.id}'
AND OperationHash = '${req.hash}'
LIMIT 1 SETTINGS use_query_cache = true, query_cache_ttl = 2629800
`;

const result = await opts.chClient.queryPromise(query);

Expand Down
8 changes: 5 additions & 3 deletions controlplane/src/core/repositories/CacheWarmerRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ export class CacheWarmerRepository {
rangeInHours,
dateRange,
operationHashes,
federatedGraphID, // TODO; Update view to get operations scoped to the federated graph
organizationID, // TODO; Update view to get operations scoped to the organization
federatedGraphID,
organizationID,
}: {
rangeInHours?: number;
dateRange?: DateRange;
Expand All @@ -116,7 +116,9 @@ export class CacheWarmerRepository {
OperationContent as operationContent,
OperationHash as operationHash
FROM ${this.client.database}.gql_metrics_operations
WHERE Timestamp >= startDate AND Timestamp <= endDate AND OperationHash IN (${operationHashes.map((hash) => `'${hash}'`).join(',')})
WHERE OrganizationID = '${organizationID}'
AND FederatedGraphID = '${federatedGraphID}'
AND Timestamp >= startDate AND Timestamp <= endDate AND OperationHash IN (${operationHashes.map((hash) => `'${hash}'`).join(',')})
GROUP BY
OperationContent,
OperationHash
Expand Down
2 changes: 2 additions & 0 deletions proto/wg/cosmo/platform/v1/platform.proto
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,8 @@ message GetCheckOperationsResponse {

message GetOperationContentRequest {
string hash = 1;
string federated_graph_name = 2;
string namespace = 3;
}

message GetOperationContentResponse {
Expand Down
30 changes: 28 additions & 2 deletions studio/src/components/checks/operation-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,25 @@ import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip";
const OperationContent = ({
hash,
enabled,
federatedGraphName,
namespace,
}: {
hash: string;
enabled: boolean;
federatedGraphName: string;
namespace: string;
}) => {
const [content, setContent] = useState("");

const { data, error, isLoading, refetch } = useQuery(
getOperationContent,
{
hash,
federatedGraphName,
namespace,
},
{
enabled,
enabled: enabled && !!federatedGraphName && !!namespace,
},
);

Expand All @@ -50,6 +56,17 @@ const OperationContent = ({
set(data.operationContent);
}, [data]);

if (!federatedGraphName || !namespace) {
return (
<EmptyState
icon={<ExclamationTriangleIcon />}
title="Could not retrieve content"
description="Please try again"
actions={<Button onClick={() => refetch()}>Retry</Button>}
/>
);
}

if (isLoading) {
return (
<div className="h-96">
Expand Down Expand Up @@ -80,9 +97,13 @@ const OperationContent = ({
export const OperationContentDialog = ({
hash,
trigger,
federatedGraphName,
namespace,
}: {
hash: string;
trigger?: React.ReactNode;
federatedGraphName: string;
namespace: string;
}) => {
const [open, setOpen] = useState(false);

Expand All @@ -104,7 +125,12 @@ export const OperationContentDialog = ({
<DialogHeader>
<DialogTitle>Operation Content</DialogTitle>
</DialogHeader>
<OperationContent hash={hash} enabled={open} />
<OperationContent
hash={hash}
enabled={open}
federatedGraphName={federatedGraphName}
namespace={namespace}
/>
</DialogContent>
</Dialog>
);
Expand Down
6 changes: 5 additions & 1 deletion studio/src/components/checks/operations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,11 @@ export const CheckOperations = () => {
: `First seen at ${firstSeenFormatted} and last seen at ${lastSeenAtFormatted}`}
</p>
<div className="flex items-center gap-x-2">
<OperationContentDialog hash={hash} />
<OperationContentDialog
hash={hash}
federatedGraphName={graphContext?.graph?.name ?? ""}
namespace={graphContext?.graph?.namespace ?? ""}
/>
Comment thread
JivusAyrus marked this conversation as resolved.
<Tooltip delayDuration={100}>
<TooltipTrigger asChild>
<Button
Expand Down
2 changes: 2 additions & 0 deletions studio/src/components/checks/override.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ export const ConfigureOverride = () => {
View Operation Content
</Button>
}
federatedGraphName={graphContext?.graph?.name ?? ""}
namespace={graphContext?.graph?.namespace ?? ""}
/>
Comment thread
JivusAyrus marked this conversation as resolved.
</div>
</SheetDescription>
Expand Down
Loading