-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathtraceStoreUtils.ts
More file actions
44 lines (36 loc) · 1.46 KB
/
traceStoreUtils.ts
File metadata and controls
44 lines (36 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { StoreConfig } from '../korrel8r-client';
export interface TraceContext {
namespace: string;
name: string;
tenant: string;
}
/**
* Extracts trace context (namespace, name, tenant) from the current URL.
* These parameters are set when the user navigates to the traces console.
*/
export const extractTraceContext = (): TraceContext | null => {
const searchParams = new URLSearchParams(window.location.search);
// Check if we're on a traces page with tenant information
const namespace = searchParams.get('namespace');
const name = searchParams.get('name');
const tenant = searchParams.get('tenant');
// If any of these are missing, return null (not on traces page or no tenant selected)
if (!namespace || !name || !tenant) {
return null;
}
return { namespace, name, tenant };
};
/**
* Builds a store configuration for the trace domain based on trace context.
*/
export const buildTraceStoreConfig = (context: TraceContext): StoreConfig => {
const { namespace, name, tenant } = context;
// Build the tempoStack URL with the tenant path
// Format: https://tempo-{name}-gateway.{namespace}.svc.cluster.local:8080/api/traces/v1/{tenant}/tempo/api/search
const tempoStackURL = `https://tempo-${name}-gateway.${namespace}.svc.cluster.local:8080/api/traces/v1/${tenant}/tempo/api/search`;
return {
domain: 'trace',
tempoStack: tempoStackURL,
certificateAuthority: '/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt',
};
};