@gravitee/gamma-lib-observability 1.29.0 → 1.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/INTEGRATION.md +45 -55
  2. package/QUERYING.md +5 -5
  3. package/USAGE_GUIDE.md +178 -231
  4. package/dist/build-observability-base-url.d.ts +12 -12
  5. package/dist/build-observability-base-url.d.ts.map +1 -1
  6. package/dist/build-traces-base-url.d.ts +9 -18
  7. package/dist/build-traces-base-url.d.ts.map +1 -1
  8. package/dist/data-sources/http-data-source.d.ts.map +1 -1
  9. package/dist/data-sources/http-filter-source.d.ts.map +1 -1
  10. package/dist/data-sources/http-logs-source.d.ts +1 -13
  11. package/dist/data-sources/http-logs-source.d.ts.map +1 -1
  12. package/dist/data-sources/logs-data-source.d.ts +1 -1
  13. package/dist/data-sources/logs-data-source.d.ts.map +1 -1
  14. package/dist/filters/filter-provider.d.ts +6 -0
  15. package/dist/filters/filter-provider.d.ts.map +1 -1
  16. package/dist/hooks/query-keys.d.ts +1 -1
  17. package/dist/hooks/query-keys.d.ts.map +1 -1
  18. package/dist/hooks/use-log-detail-query.d.ts +1 -0
  19. package/dist/hooks/use-log-detail-query.d.ts.map +1 -1
  20. package/dist/hooks/use-logs-histogram-query.d.ts +0 -7
  21. package/dist/hooks/use-logs-histogram-query.d.ts.map +1 -1
  22. package/dist/index.d.ts +2 -2
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +1460 -1498
  25. package/dist/logs/LogsExplorerPage.d.ts +1 -7
  26. package/dist/logs/LogsExplorerPage.d.ts.map +1 -1
  27. package/dist/logs/detail/components/LogDetailContent.d.ts.map +1 -1
  28. package/dist/logs/detail/components/LogDetailContextChart.d.ts +1 -3
  29. package/dist/logs/detail/components/LogDetailContextChart.d.ts.map +1 -1
  30. package/dist/logs/detail/components/LogDetailDrawer.d.ts +2 -1
  31. package/dist/logs/detail/components/LogDetailDrawer.d.ts.map +1 -1
  32. package/dist/logs/detail/components/LogDetailPage.d.ts.map +1 -1
  33. package/dist/logs/detail/types.d.ts +0 -7
  34. package/dist/logs/detail/types.d.ts.map +1 -1
  35. package/dist/logs/index.d.ts +0 -2
  36. package/dist/logs/index.d.ts.map +1 -1
  37. package/dist/routing/LogsRouteElement.d.ts +3 -3
  38. package/dist/routing/LogsRouteElement.d.ts.map +1 -1
  39. package/dist/routing/ObservabilityRoutes.d.ts +2 -1
  40. package/dist/routing/ObservabilityRoutes.d.ts.map +1 -1
  41. package/dist/routing/types.d.ts +47 -16
  42. package/dist/routing/types.d.ts.map +1 -1
  43. package/dist/styles/observability.css +1 -1
  44. package/package.json +5 -5
  45. package/dist/logs/analytics-filter-mapping.d.ts +0 -35
  46. package/dist/logs/analytics-filter-mapping.d.ts.map +0 -1
package/INTEGRATION.md CHANGED
@@ -35,8 +35,8 @@ Your module must provide these packages. They are **not** bundled by the library
35
35
  | `react-dom` | ^19.0.0 | |
36
36
  | `react-router-dom` | ^7.0.0 | |
37
37
  | `@tanstack/react-query` | ^5.0.0 | Must be a **shared singleton** if using Module Federation |
38
- | `@gravitee/graphene-core` | ^2.33.0 | Design system primitives (buttons, popovers, tables, icons) |
39
- | `@gravitee/graphene-charts` | ^2.33.0 | Chart components (dashboard widgets, trace waterfall & lineage). Sub-paths `/dashboard-grid` and `/lineage` are used. |
38
+ | `@gravitee/graphene-core` | ^2.49.0 | Design system primitives (buttons, popovers, tables, icons) |
39
+ | `@gravitee/graphene-charts` | ^2.49.0 | Chart components (dashboard widgets, trace waterfall & lineage). Sub-paths `/dashboard-grid` and `/lineage` are used. |
40
40
  | `react-grid-layout` | ^2.0.0 | Required by `@gravitee/graphene-charts/dashboard-grid`. The lib does **not** bundle it. |
41
41
  | `@xyflow/react` | ^12.0.0 | **Optional.** Only required to render the trace **Lineage** view; lazy-loaded, so apps that never open it can omit it. See [Tracing — Lineage view](#tracing--lineage-view). |
42
42
  | `tailwindcss` | ^4.0.0 | Optional — only if you compile Tailwind yourself |
@@ -115,8 +115,8 @@ shared: {
115
115
  'react-dom': { singleton: true, requiredVersion: '^19.0.0' },
116
116
  'react-router-dom': { singleton: true, requiredVersion: '^7.0.0' },
117
117
  '@tanstack/react-query': { singleton: true, requiredVersion: '^5.0.0' },
118
- '@gravitee/graphene-core': { singleton: true, requiredVersion: '^2.16.0' },
119
- '@gravitee/graphene-charts': { singleton: true, requiredVersion: '^2.25.0' },
118
+ '@gravitee/graphene-core': { singleton: true, requiredVersion: '^2.49.0' },
119
+ '@gravitee/graphene-charts': { singleton: true, requiredVersion: '^2.49.0' },
120
120
  'react-grid-layout': { singleton: true, requiredVersion: '^2.0.0' },
121
121
  }
122
122
  ```
@@ -320,7 +320,7 @@ time bucket.
320
320
  }
321
321
  ```
322
322
 
323
- - `axisId`: `'left'` (default) or `'right'` — requires `@gravitee/graphene-charts` ≥ 2.38 with dual-axis support.
323
+ - `axisId`: `'left'` (default) or `'right'` — requires `@gravitee/graphene-charts` ≥ 2.49 with dual-axis support.
324
324
  - `unit`: optional suffix for tooltips (`1,234 req`, `250 ms`).
325
325
  - Omit `axisId` on every series to keep the previous single-axis behaviour.
326
326
 
@@ -347,15 +347,11 @@ Context filters are always-on filters silently merged into every data query. Use
347
347
  dashboards: {
348
348
  enabled: true,
349
349
  templates: [apiOverviewTemplate],
350
- contextFilters: [
351
- { field: 'API_TYPE', label: 'API Type', operator: 'in', value: ['MCP', 'LLM'] },
352
- ],
353
- scopeFilterField: 'API_TYPE',
350
+ scopeApiTypes: ['MCP', 'LLM'],
354
351
  }
355
352
  ```
356
353
 
357
- - `contextFilters` merged into every `fetchTimeSeries`, `fetchFacets`, `fetchMeasures` call
358
- - `scopeFilterField` — restricts which filter providers appear in the FilterBar (only those whose `scopes` include the active values)
354
+ `scopeApiTypes` generates `API_TYPE` context filters (merged into every analytics query) and sets `scopeFilterField` to restrict which filter providers appear in the FilterBar. For non-API_TYPE scoping, use `contextFilters` + `scopeFilterField` directly.
359
355
 
360
356
  ### Cross-section links (Dashboards → Logs)
361
357
 
@@ -425,8 +421,7 @@ export const observability = defineObservabilityFeatures({
425
421
  dashboards: { enabled: true, templates: myTemplates },
426
422
  logs: {
427
423
  enabled: true,
428
- contextFilters: [{ field: 'ENTRYPOINT', label: 'Entrypoint', operator: 'in', value: ['http-proxy'] }],
429
- scopeFilterField: 'ENTRYPOINT',
424
+ scopeApiTypes: ['HTTP_PROXY'],
430
425
  pageSize: 25,
431
426
  columnVisibilityStorageKey: 'apim-logs-columns',
432
427
  },
@@ -521,15 +516,15 @@ const columns: LogColumnDefinition<ConnectionLog>[] = [
521
516
 
522
517
  Column variants: `text` (default), `badge`, `status-code`, `duration`, `datetime`, `http-method`.
523
518
 
524
- ### Scope filtering via ENTRYPOINT
519
+ ### Scope filtering via API_TYPE
525
520
 
526
- The Gravitee v2 logs search API supports filtering by `ENTRYPOINT`. Common entrypoint values by API type:
521
+ Logs scope by `API_TYPE`, the same unified vocabulary used by dashboards:
527
522
 
528
- | API type | Entrypoint values |
529
- | -------- | ----------------------------------------- |
530
- | MCP | `['mcp-proxy', 'mcp']` |
531
- | LLM | `['llm-proxy']` |
532
- | HTTP | `['http-proxy', 'http-get', 'http-post']` |
523
+ | API type | Filter values |
524
+ | -------- | ---------------- |
525
+ | MCP | `['MCP']` |
526
+ | LLM | `['LLM']` |
527
+ | HTTP | `['HTTP_PROXY']` |
533
528
 
534
529
  ### Custom logs page (escape hatch)
535
530
 
@@ -622,7 +617,7 @@ For full data type reference, see [`USAGE_GUIDE.md` — Widget Integration Level
622
617
 
623
618
  ## Feature: Traces
624
619
 
625
- Trace support ships a full UI route (`observe/tracing`) with search, filters, and detail views. Tracing endpoints live under the **Gamma API** (not management-v2), so the lib needs a separate base URL:
620
+ Trace support ships a full UI route (`observe/tracing`) with search, filters, and detail views. Tracing endpoints live under the same Gamma API surface as all other observability endpoints:
626
621
 
627
622
  ```ts
628
623
  import type {
@@ -664,18 +659,19 @@ The capability key `observability.traces.read` is already wired.
664
659
 
665
660
  ### tracesBaseUrl
666
661
 
667
- Tracing endpoints use the Gamma API prefix (`/gamma/organizations/{orgId}/environments/{envId}`) instead of management-v2. Pass `tracesBaseUrl` to `<observability.Routes>`:
662
+ Since `baseUrl` is now Gamma-scoped, `tracesBaseUrl` is redundant it falls back to `baseUrl` when omitted. It is kept for backward compatibility:
668
663
 
669
664
  ```tsx
670
- import { buildObservabilityBaseUrl, buildTracesBaseUrl } from '@gravitee/gamma-lib-observability';
665
+ import { buildObservabilityBaseUrl } from '@gravitee/gamma-lib-observability';
671
666
 
672
- const baseUrl = buildObservabilityBaseUrl(managementBaseURL, environmentId);
673
- const tracesBaseUrl = buildTracesBaseUrl(gammaBaseURL, organizationId, environmentId);
667
+ const baseUrl = buildObservabilityBaseUrl(gammaBaseURL, organizationId, environmentId);
674
668
 
675
- <observability.Routes baseUrl={baseUrl} tracesBaseUrl={tracesBaseUrl} http={httpConfig} />;
669
+ <observability.Routes baseUrl={baseUrl} http={httpConfig} />;
676
670
  ```
677
671
 
678
- `buildTracesBaseUrl` follows the same pattern as `buildObservabilityBaseUrl`:
672
+ Both `buildObservabilityBaseUrl` and `buildTracesBaseUrl` now produce identical Gamma-scoped URLs. `tracesBaseUrl` is optional and falls back to `baseUrl`.
673
+
674
+ `buildTracesBaseUrl` is kept as a backward-compatible alias:
679
675
 
680
676
  ```ts
681
677
  import { buildTracesBaseUrl } from '@gravitee/gamma-lib-observability';
@@ -698,7 +694,7 @@ const tracesBaseUrl = buildTracesBaseUrl(bootstrapConfig.gammaBaseURL, organizat
698
694
  // → '/gamma/organizations/DEFAULT/environments/DEFAULT'
699
695
  ```
700
696
 
701
- When `tracesBaseUrl` is omitted, the lib falls back to `baseUrl` (management-v2 prefix) for backward compatibility during migration.
697
+ When `tracesBaseUrl` is omitted, the lib falls back to `baseUrl`. Both now produce identical Gamma-scoped URLs, so the prop is only needed for backward compatibility.
702
698
 
703
699
  ---
704
700
 
@@ -861,10 +857,10 @@ Guard the mount on the SDK environment being ready, with a fallback for standalo
861
857
 
862
858
  ```tsx
863
859
  import { useModuleEnvironment } from '@gravitee/gamma-modules-sdk';
864
- import { buildObservabilityBaseUrl, buildTracesBaseUrl } from '@gravitee/gamma-lib-observability';
860
+ import { buildObservabilityBaseUrl } from '@gravitee/gamma-lib-observability';
865
861
 
866
862
  function ObservabilitySection() {
867
- const { environmentId, organizationId, managementBaseURL, gammaBaseURL, isReady } = useModuleEnvironment();
863
+ const { environmentId, organizationId, gammaBaseURL, isReady } = useModuleEnvironment();
868
864
 
869
865
  // Standalone dev has no host env to wait for — mount immediately.
870
866
  const awaitingHostEnv = import.meta.env.PROD && !isReady;
@@ -872,9 +868,8 @@ function ObservabilitySection() {
872
868
  return null; // or a lightweight skeleton
873
869
  }
874
870
 
875
- const baseUrl = buildObservabilityBaseUrl(managementBaseURL, environmentId);
876
- const tracesBaseUrl = buildTracesBaseUrl(gammaBaseURL, organizationId, environmentId);
877
- return <observability.Routes baseUrl={baseUrl} tracesBaseUrl={tracesBaseUrl} http={httpConfig} /* … */ />;
871
+ const baseUrl = buildObservabilityBaseUrl(gammaBaseURL, organizationId, environmentId);
872
+ return <observability.Routes baseUrl={baseUrl} http={httpConfig} /* … */ />;
878
873
  }
879
874
  ```
880
875
 
@@ -891,28 +886,31 @@ Build the observability `baseUrl` from your module's bootstrap config using the
891
886
  ```ts
892
887
  import { buildObservabilityBaseUrl } from '@gravitee/gamma-lib-observability';
893
888
 
894
- // Production — managementBaseURL is an absolute URL from bootstrap
889
+ // Production — gammaBaseURL is an absolute URL from bootstrap
895
890
  const baseUrl = buildObservabilityBaseUrl(
896
- bootstrapConfig.managementBaseURL, // e.g. 'https://apim-master-api.cloud.gravitee.io/management'
891
+ bootstrapConfig.gammaBaseURL, // e.g. 'https://apim-master-api.cloud.gravitee.io/gamma'
892
+ organizationId, // e.g. 'DEFAULT'
897
893
  environmentId, // e.g. 'DEFAULT'
898
894
  );
899
- // → 'https://apim-master-api.cloud.gravitee.io/management/v2/environments/DEFAULT'
895
+ // → 'https://apim-master-api.cloud.gravitee.io/gamma/organizations/DEFAULT/environments/DEFAULT'
900
896
  ```
901
897
 
902
- When a local dev proxy forwards `/management/*` requests to the real API, pass `{ useDevProxy: true }` to strip the origin:
898
+ When a local dev proxy forwards `/gamma/*` requests to the real API, pass `{ useDevProxy: true }` to strip the origin:
903
899
 
904
900
  ```ts
905
- const baseUrl = buildObservabilityBaseUrl(bootstrapConfig.managementBaseURL, environmentId, { useDevProxy: true });
906
- // → '/management/v2/environments/DEFAULT' (origin stripped, browser hits the proxy)
901
+ const baseUrl = buildObservabilityBaseUrl(bootstrapConfig.gammaBaseURL, organizationId, environmentId, {
902
+ useDevProxy: true,
903
+ });
904
+ // → '/gamma/organizations/DEFAULT/environments/DEFAULT' (origin stripped, browser hits the proxy)
907
905
  ```
908
906
 
909
- The `useDevProxy` option extracts the pathname from an absolute `managementBaseURL` so the browser fetches through the local dev proxy instead of directly hitting the remote API origin. When `managementBaseURL` is already a relative path (e.g. `/management`), the option is a no-op.
907
+ The `useDevProxy` option extracts the pathname from an absolute `gammaBaseURL` so the browser fetches through the local dev proxy instead of directly hitting the remote API origin. When `gammaBaseURL` is already a relative path (e.g. `/gamma`), the option is a no-op.
910
908
 
911
- The library uses `baseUrl` to construct its built-in HTTP adapters: `createHttpDataSource(baseUrl)` for metrics, `createHttpFilterSource(baseUrl)` for filters, and `createHttpLogsSource(baseUrl)` for logs. Tracing adapters (`createHttpTracesSource`, `createHttpTracesFilterSource`) use `tracesBaseUrl` when provided, falling back to `baseUrl`. If you pass custom overrides (`dataSource`, `filterProviders`, `logsDataSource`, `tracesDataSource`), these URLs are still required for any remaining internal HTTP calls.
909
+ The library uses `baseUrl` to construct its built-in HTTP adapters: `createHttpDataSource(baseUrl)` for metrics, `createHttpFilterSource(baseUrl)` for filters, and `createHttpLogsSource(baseUrl)` for logs. All adapters target the unified `/observability/*` surface. If you pass custom overrides (`dataSource`, `filterProviders`, `logsDataSource`, `tracesDataSource`), these URLs are still required for any remaining internal HTTP calls.
912
910
 
913
911
  ### Authenticated backends (`createHttpDataSource` options)
914
912
 
915
- The built-in `createHttpDataSource(baseUrl, options?)` adapter speaks the Gravitee Management v2 analytics contract (`/analytics/measures`, `/analytics/facets`, `/analytics/time-series`). It accepts an `options` argument for hosts that need to plug their auth flow:
913
+ The built-in `createHttpDataSource(baseUrl, options?)` adapter speaks the Gravitee unified observability analytics contract (`/observability/analytics/measures`, `/observability/analytics/facets`, `/observability/analytics/time-series`). It accepts an `options` argument for hosts that need to plug their auth flow:
916
914
 
917
915
  ```ts
918
916
  import { createHttpDataSource } from '@gravitee/gamma-lib-observability';
@@ -943,7 +941,7 @@ const dataSource = createHttpDataSource(baseUrl, {
943
941
 
944
942
  ### Built-in logs adapter (`createHttpLogsSource`)
945
943
 
946
- The built-in `createHttpLogsSource(baseUrl, options?)` adapter speaks the Gravitee Management v2 logs contract (`POST /logs/search`). It is automatically used by `ObservabilityRoutes` when `config.features.logs.enabled` is true and no explicit `logsDataSource` prop is provided.
944
+ The built-in `createHttpLogsSource(baseUrl, options?)` adapter speaks the unified Gamma logs contract (`POST /observability/logs/search`). It is automatically used by `ObservabilityRoutes` when `config.features.logs.enabled` is true and no explicit `logsDataSource` prop is provided.
947
945
 
948
946
  ```ts
949
947
  import { createHttpLogsSource } from '@gravitee/gamma-lib-observability';
@@ -951,8 +949,6 @@ import { createHttpLogsSource } from '@gravitee/gamma-lib-observability';
951
949
  const logsSource = createHttpLogsSource(baseUrl, {
952
950
  credentials: 'include',
953
951
  headers: () => ({ 'X-Xsrf-Token': readXsrfTokenFromCookie() }),
954
- // Override the search endpoint path (default: '/logs/search')
955
- searchPath: '/observability/logs',
956
952
  });
957
953
  ```
958
954
 
@@ -961,11 +957,11 @@ const logsSource = createHttpLogsSource(baseUrl, {
961
957
  | `fetch` | Custom fetch implementation — useful when the host already has an authenticated client |
962
958
  | `headers` | Static `HeadersInit` or a factory called per-request (re-evaluated for every call) |
963
959
  | `credentials` | Forwarded to `fetch` — `'include'` when the host relies on cookies |
964
- | `searchPath` | Path appended to `baseUrl` for log search. Defaults to `'/logs/search'` |
960
+ | `searchPath` | Path appended to `baseUrl` for log search. Defaults to `'/observability/logs/search'` |
965
961
 
966
962
  **Wire format**: pagination (`page`, `perPage`) is sent as query params. The POST body contains `{ timeRange: { from, to }, filters: [...] }` where filters use the same wire format as the metrics adapter.
967
963
 
968
- **`getById`**: fetches a single log via the same search endpoint with a `REQUEST_ID` EQ filter. Uses the time range from the last `fetchLogs` call (falls back to a 10-year window if no prior call). This strategy is isolated internally and will be updated if a dedicated `GET /logs/:id` endpoint becomes available.
964
+ **`getById`**: fetches a single log via `GET /observability/logs/{requestId}?apiId={apiId}`. The `apiId` is extracted from the log row at click time via the `logsGetApiId` prop. Returns `null` on 404.
969
965
 
970
966
  ### Custom data source
971
967
 
@@ -1165,17 +1161,11 @@ const trafficTemplate = defineDashboardTemplate({
1165
1161
 
1166
1162
  export const observability = defineObservabilityFeatures({
1167
1163
  basePath: 'observe',
1164
+ scopeApiTypes: ['HTTP_PROXY'],
1168
1165
  features: {
1169
- dashboards: {
1170
- enabled: true,
1171
- templates: [trafficTemplate],
1172
- contextFilters: [{ field: 'API_TYPE', label: 'API Type', operator: 'in', value: ['HTTP'] }],
1173
- scopeFilterField: 'API_TYPE',
1174
- },
1166
+ dashboards: { enabled: true, templates: [trafficTemplate] },
1175
1167
  logs: {
1176
1168
  enabled: true,
1177
- contextFilters: [{ field: 'ENTRYPOINT', label: 'Entrypoint', operator: 'in', value: ['http-proxy'] }],
1178
- scopeFilterField: 'ENTRYPOINT',
1179
1169
  pageSize: 25,
1180
1170
  columnVisibilityStorageKey: 'my-module-logs-columns',
1181
1171
  },
package/QUERYING.md CHANGED
@@ -11,11 +11,11 @@ request field they expose, the defaults the library injects, and copy-pasteable
11
11
 
12
12
  ## 1. Endpoints
13
13
 
14
- | Endpoint | Used by widgets | Returns |
15
- | ----------------------------- | ------------------------ | ------------------------------------------- |
16
- | `POST /analytics/measures` | `metric`, `metric-group` | aggregated metric values (`MetricResult[]`) |
17
- | `POST /analytics/facets` | `doughnut`, `bar` | grouped buckets (`FacetBucket[]`) |
18
- | `POST /analytics/time-series` | `cartesian` | data points over time (`TimeSeriesGroup[]`) |
14
+ | Endpoint | Used by widgets | Returns |
15
+ | ------------------------------------------- | ------------------------ | ------------------------------------------- |
16
+ | `POST /observability/analytics/measures` | `metric`, `metric-group` | aggregated metric values (`MetricResult[]`) |
17
+ | `POST /observability/analytics/facets` | `doughnut`, `bar` | grouped buckets (`FacetBucket[]`) |
18
+ | `POST /observability/analytics/time-series` | `cartesian` | data points over time (`TimeSeriesGroup[]`) |
19
19
 
20
20
  ### Capability matrix
21
21