Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(tracing): add has_spans check and onboarding empty state (#61202)

posthog[bot]7abec5ab2ff1
diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts
index 33a18de72890..8d9c0e163a8f 100644
--- a/frontend/src/lib/api.ts
+++ b/frontend/src/lib/api.ts
@@ -2840,6 +2840,13 @@ const api = {
},
tracing: {
+ async hasSpans(): Promise<boolean> {
+ return new ApiRequest()
+ .tracingSpans()
+ .withAction('has_spans')
+ .get()
+ .then((response) => Boolean(response.hasSpans))
+ },
async listSpans(
query: {
dateRange?: { date_from?: string | null; date_to?: string | null }
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index dea42707cbbe..27f6aab1fad7 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -3463,6 +3463,10 @@ importers:
react-window:
specifier: '*'
+ devDependencies:
+ kea-test-utils:
+ specifier: 'catalog:'
products/user_interviews:
dependencies:
diff --git a/products/tracing/backend/has_spans_query_runner.py b/products/tracing/backend/has_spans_query_runner.py
new file mode 100644
index 000000000000..868a05b0e713
--- /dev/null
+++ b/products/tracing/backend/has_spans_query_runner.py
@@ -0,0 +1,41 @@
+import datetime as dt
+
+from django.core.cache import cache
+
+from posthog.hogql import ast
+from posthog.hogql.parser import parse_select
+from posthog.hogql.query import execute_hogql_query
+
+from posthog.clickhouse.client.connection import Workload
+from posthog.models import Team
+
+HAS_SPANS_CACHE_TTL = int(dt.timedelta(days=7).total_seconds())
+
+
+class HasSpansQueryRunner:
+ def __init__(self, team: Team) -> None:
+ self.team = team
+
+ def run(self) -> bool:
+ query = parse_select("SELECT 1 FROM posthog.trace_spans LIMIT 1")
+ assert isinstance(query, ast.SelectQuery)
+
+ response = execute_hogql_query(
+ query_type="HasSpansQuery",
+ query=query,
+ team=self.team,
+ workload=Workload.LOGS,
+ )
+
+ return len(response.results) > 0
+
+
+def team_has_spans(team: Team) -> bool:
+ cache_key = f"team:{team.id}:has_spans"
+ if cache.get(cache_key) is True:
+ return True
+
+ has_spans = HasSpansQueryRunner(team).run()
+ if has_spans:
+ cache.set(cache_key, True, HAS_SPANS_CACHE_TTL)
+ return has_spans
diff --git a/products/tracing/backend/presentation/views.py b/products/tracing/backend/presentation/views.py
index d4a3f6a6d291..76fba0bb65e4 100644
--- a/products/tracing/backend/presentation/views.py
+++ b/products/tracing/backend/presentation/views.py
@@ -39,6 +39,7 @@ from posthog.clickhouse.query_tagging import Feature, tag_queries
from posthog.event_usage import report_user_action
from posthog.hogql_queries.query_runner import ExecutionMode
+from ..has_spans_query_runner import team_has_spans
from ..logic import (
TraceSpansQueryRunner,
run_aggregation_query,
@@ -269,6 +270,12 @@ class _TracingTreeRequestSerializer(serializers.Serializer):
query = _TracingTreeQueryBodySerializer(help_text="The span call-tree aggregation query to execute.")
+class _HasSpansResponseSerializer(serializers.Serializer):
+ hasSpans = serializers.BooleanField(
+ help_text="Whether the team has ingested any tracing spans yet. Used to gate the onboarding empty state."
+ )
+
+
class SpansViewSet(TeamAndOrgViewSetMixin, PydanticModelMixin, viewsets.ViewSet):
scope_object = "tracing"
serializer_class = _FallbackSerializer
@@ -297,6 +304,22 @@ class SpansViewSet(TeamAndOrgViewSetMixin, PydanticModelMixin, viewsets.ViewSet)
results = run_service_names_query(team=self.team, date_range=date_range, search=search)
return Response({"results": results}, status=status.HTTP_200_OK)
+ @extend_schema(responses={200: _HasSpansResponseSerializer})
+ @action(detail=False, methods=["GET"], url_path="has_spans", required_scopes=["tracing:read"])
+ def has_spans(self, request: Request, *args, **kwargs) -> Response:
+ tag_queries(product=ProductKey.TRACING, feature=Feature.QUERY)
+ has_spans = team_has_spans(self.team)
+
+ report_user_action(
+ request.user,
+ "tracing has_spans checked",
+ {"has_spans": has_spans},
+ team=self.team,
+ request=request,
+ )
+
+ return Response({"hasSpans": has_spans}, status=status.HTTP_200_OK)
+
@extend_schema(request=_TracingQueryRequestSerializer)
@action(detail=False, methods=["POST"], required_scopes=["tracing:read"])
def query(self, request: Request, *args, **kwargs) -> Response:
diff --git a/products/tracing/frontend/TracingScene.tsx b/products/tracing/frontend/TracingScene.tsx
index 9007769b055e..8616dffe13a4 100644
--- a/products/tracing/frontend/TracingScene.tsx
+++ b/products/tracing/frontend/TracingScene.tsx
@@ -14,6 +14,7 @@ import { SceneDivider } from '~/layout/scenes/components/SceneDivider'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'
+import { TracingSetupPrompt } from './components/SetupPrompt/SetupPrompt'
import { VirtualizedSpanList } from './components/VirtualizedSpanList/VirtualizedSpanList'
import { TraceCompareFlame } from './TraceCompareFlame'
import { TraceCompareTable } from './TraceCompareTable'
@@ -151,56 +152,58 @@ function TracingSceneContents(): JSX.Element {
>
Tracing is in alpha. Expect bugs, missing features, and breaking changes.
</LemonBanner>
- <TracingSparkline
- sparklineData={sparklineData}
- sparklineLoading={sparklineLoading}
- onDateRangeChange={setDateRange}
- displayTimezone="UTC"
- compare={compareConfig}
- visibleRowDateRange={visibleRowDateRange}
- />
- <SceneDivider />
- <TracingFilterBar />
- {!sparklineLoading && totalSpansMatchingFilters > 0 && (
- <div className="text-xs text-muted px-1">
- {totalSpansMatchingFilters.toLocaleString()} spans matching filters
- </div>
- )}
- {compareMode ? (
- <div className="flex flex-col flex-1 min-h-0 overflow-auto">
- <TraceCompareTable
- current={aggregation.current}
- previous={aggregation.previous}
- loading={aggregationLoading}
- onRowClick={(row) => openCompareFlame(row.name, row.service_name)}
- />
- </div>
- ) : (
- <VirtualizedSpanList
- dataSource={rootSpans}
- loading={spansLoading}
- hasMoreToLoad={hasMoreToLoad}
- onLoadMore={fetchNextPage}
- onVisibleRowRangeChange={setVisibleRowRange}
- expandedSpanIds={expandedSpanIds}
- onToggleExpand={toggleExpandSpan}
- emptyState={
- <div className="flex flex-col items-center gap-1">
- <span>No spans found</span>
- <Link to={TRACING_DOCS_URL} onClick={onDocsLinkClick} target="_blank">
- Learn how to send traces
- </Link>
- </div>
- }
- onRowClick={(span: Span) => {
- // Clicking a row leaves the scrollable <main tabIndex="0"> as the active
- // element; react-modal then scrolls it back into view when restoring focus
- // on close. Blur so the restore target is <body>, which doesn't scroll.
- ;(document.activeElement as HTMLElement | null)?.blur?.()
- openTraceModal(span.trace_id)
- }}
+ <TracingSetupPrompt>
+ <TracingSparkline
+ sparklineData={sparklineData}
+ sparklineLoading={sparklineLoading}
+ onDateRangeChange={setDateRange}
+ displayTimezone="UTC"
+ compare={compareConfig}
+ visibleRowDateRange={visibleRowDateRange}
/>
- )}
+ <SceneDivider />
+ <TracingFilterBar />
+ {!sparklineLoading && totalSpansMatchingFilters > 0 && (
+ <div className="text-xs text-muted px-1">
+ {totalSpansMatchingFilters.toLocaleString()} spans matching filters
+ </div>
+ )}
+ {compareMode ? (
+ <div className="flex flex-col flex-1 min-h-0 overflow-auto">
+ <TraceCompareTable
+ current={aggregation.current}
+ previous={aggregation.previous}
+ loading={aggregationLoading}
+ onRowClick={(row) => openCompareFlame(row.name, row.service_name)}
+ />
+ </div>
+ ) : (
+ <VirtualizedSpanList
+ dataSource={rootSpans}
+ loading={spansLoading}
+ hasMoreToLoad={hasMoreToLoad}
+ onLoadMore={fetchNextPage}
+ onVisibleRowRangeChange={setVisibleRowRange}
+ expandedSpanIds={expandedSpanIds}
+ onToggleExpand={toggleExpandSpan}
+ emptyState={
+ <div className="flex flex-col items-center gap-1">
+ <span>No spans found</span>
+ <Link to={TRACING_DOCS_URL} onClick={onDocsLinkClick} target="_blank">
+ Learn how to send traces
+ </Link>
+ </div>
+ }
+ onRowClick={(span: Span) => {
+ // Clicking a row leaves the scrollable <main tabIndex="0"> as the active
+ // element; react-modal then scrolls it back into view when restoring focus
+ // on close. Blur so the restore target is <body>, which doesn't scroll.
+ ;(document.activeElement as HTMLElement | null)?.blur?.()
+ openTraceModal(span.trace_id)
+ }}
+ />
+ )}
+ </TracingSetupPrompt>
<LemonModal
title={`Trace ${selectedTraceId}`}
isOpen={isTraceModalOpen}
diff --git a/products/tracing/frontend/components/SetupPrompt/SetupPrompt.tsx b/products/tracing/frontend/components/SetupPrompt/SetupPrompt.tsx
new file mode 100644
index 000000000000..2ee8dd56a28d
--- /dev/null
+++ b/products/tracing/frontend/components/SetupPrompt/SetupPrompt.tsx
@@ -0,0 +1,139 @@
+import { useActions, useValues } from 'kea'
+import posthog from 'posthog-js'
+import { useEffect } from 'react'
+
+import { LemonButton, Link, Spinner } from '@posthog/lemon-ui'
+
+import { XRayHog } from 'lib/components/hedgehogs'
+import { ProductIntroduction } from 'lib/components/ProductIntroduction/ProductIntroduction'
+import { useInterval } from 'lib/hooks/useInterval'
+import goImage from 'scenes/onboarding/sdks/logos/go.svg'
+import javaImage from 'scenes/onboarding/sdks/logos/java.svg'
+import nodejsImage from 'scenes/onboarding/sdks/logos/nodejs.svg'
+import pythonImage from 'scenes/onboarding/sdks/logos/python.svg'
+import { teamLogic } from 'scenes/teamLogic'
+
+import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'
+
+import { tracingIngestionLogic } from './tracingIngestionLogic'
+
+const FRAMEWORK_LINKS: { name: string; image?: string; docsLink: string }[] = [
+ { name: 'Node.js', image: nodejsImage, docsLink: 'https://opentelemetry.io/docs/languages/js/' },
+ { name: 'Python', image: pythonImage, docsLink: 'https://opentelemetry.io/docs/languages/python/' },
+ { name: 'Java', image: javaImage, docsLink: 'https://opentelemetry.io/docs/languages/java/' },
+ { name: 'Go', image: goImage, docsLink: 'https://opentelemetry.io/docs/languages/go/' },
+ { name: 'Other', docsLink: 'https://opentelemetry.io/docs/languages/' },
+]
+
+const POLLING_INTERVAL_MS = 5000
+
+export const TracingSetupPrompt = ({
+ children,
+ className,
+}: {
+ children: React.ReactNode
+ className?: string
+}): JSX.Element => {
+ const { hasSpans, teamHasSpansLoading, teamHasSpansCheckFailed } = useValues(tracingIngestionLogic)
+ const { currentTeam } = useValues(teamLogic)
+
+ if ((teamHasSpansLoading && hasSpans === undefined) || !currentTeam) {
+ return (
+ <div className="flex justify-center">
+ <Spinner />
+ </div>
+ )
+ }
+
+ if (teamHasSpansCheckFailed || hasSpans === undefined) {
+ return <>{children}</>
+ }
+
+ if (!hasSpans) {
+ return <NoSpansPrompt className={className} />
+ }
+
+ return <>{children}</>
+}
+
+const NoSpansPrompt = ({ className }: { className?: string }): JSX.Element | null => {
+ const { addProductIntent } = useActions(teamLogic)
+ const { hasSpans } = useValues(tracingIngestionLogic)
+ const { loadTeamHasSpans } = useActions(tracingIngestionLogic)
+
+ useEffect(() => {
+ posthog.capture('tracing setup prompt viewed')
+ }, [])
+
+ useInterval(() => {
+ if (!hasSpans) {
+ loadTeamHasSpans()
+ }
+ }, POLLING_INTERVAL_MS)
+
+ const onDocsLinkClick = (docsType: string): void => {
+ posthog.capture('tracing onboarding docs clicked', { docs_type: docsType })
+ addProductIntent({
+ product_type: ProductKey.TRACING,
+ intent_context: ProductIntentContext.TRACING_DOCS_VIEWED,
+ })
+ }
+
+ return (
+ <ProductIntroduction
+ productName="Tracing"
+ thingName="trace"
+ titleOverride="You haven't sent any traces yet"
+ description="PostHog tracing works with any OpenTelemetry-compatible client. You don't need any PostHog-specific packages – just use standard OpenTelemetry libraries to send spans via OTLP."
+ isEmpty={true}
+ productKey={ProductKey.TRACING}
+ className={className}
+ customHog={XRayHog}
+ actionElementOverride={
+ <div className="flex flex-col items-start gap-4">
+ <p className="text-sm text-secondary m-0">
+ Read our{' '}
+ <Link to="https://posthog.com/docs/tracing" onClick={() => onDocsLinkClick('Tracing')}>
+ tracing docs
+ </Link>
+ , learn more about{' '}
+ <Link
+ to="https://opentelemetry.io/docs/what-is-opentelemetry/"
+ target="_blank"
+ disableDocsPanel
+ onClick={() => onDocsLinkClick('OpenTelemetry')}
+ >
+ OpenTelemetry
+ </Link>
+ , or pick a language to get started:
+ </p>
+ <div className="flex flex-wrap gap-2">
+ {FRAMEWORK_LINKS.map(({ name, image, docsLink }) => (
+ <LemonButton
+ key={name}
+ type="secondary"
+ size="small"
+ to={docsLink}
+ onClick={() => onDocsLinkClick(name)}
+ icon={
+ image ? (
+ <img src={image} alt="" aria-hidden="true" className="w-5 h-5" />
+ ) : undefined
+ }
+ >
+ {name}
+ </LemonButton>
+ ))}
+ </div>
+ <div className="flex items-center gap-2 px-3 py-1.5 border border-accent rounded">
+ <div className="relative flex items-center justify-center">
+ <div className="absolute w-3 h-3 border-2 border-accent rounded-full animate-ping" />
+ <div className="w-2 h-2 bg-accent rounded-full" />
+ </div>
+ <span className="text-sm">Watching for traces</span>
+ </div>
+ </div>
+ }
+ />
+ )
+}
diff --git a/products/tracing/frontend/components/SetupPrompt/tracingIngestionLogic.test.ts b/products/tracing/frontend/components/SetupPrompt/tracingIngestionLogic.test.ts
new file mode 100644
index 000000000000..33b7add760e8
--- /dev/null
+++ b/products/tracing/frontend/components/SetupPrompt/tracingIngestionLogic.test.ts
@@ -0,0 +1,175 @@
+import { expectLogic } from 'kea-test-utils'
+
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+
+import { tracingIngestionLogic } from './tracingIngestionLogic'
+
+describe('tracingIngestionLogic', () => {
+ let logic: ReturnType<typeof tracingIngestionLogic.build>
+
+ beforeEach(() => {
+ localStorage.clear()
+ initKeaTests()
+ })
+
+ afterEach(() => {
+ logic?.unmount()
+ localStorage.clear()
+ })
+
+ describe('loadTeamHasSpans', () => {
+ it.each([
+ { hasSpans: true, label: 'spans exist' },
+ { hasSpans: false, label: 'no spans exist' },
+ ])('loads teamHasSpans as $hasSpans when $label', async ({ hasSpans }) => {
+ useMocks({
+ get: {
+ '/api/environments/:team_id/tracing/spans/has_spans/': () => [200, { hasSpans }],
+ },
+ })
+
+ logic = tracingIngestionLogic()
+ logic.mount()
+
+ await expectLogic(logic).toDispatchActions(['loadTeamHasSpans', 'loadTeamHasSpansSuccess']).toMatchValues({
+ teamHasSpans: hasSpans,
+ teamHasSpansLoading: false,
+ teamHasSpansCheckFailed: false,
+ })
+ })
+
+ it('handles API failure and sets teamHasSpansCheckFailed', async () => {
+ useMocks({
+ get: {
+ '/api/environments/:team_id/tracing/spans/has_spans/': () => [500, { detail: 'Server error' }],
+ },
+ })
+
+ logic = tracingIngestionLogic()
+ logic.mount()
+
+ // With retry logic (3 attempts), this will eventually fail
+ await expectLogic(logic).toDispatchActions(['loadTeamHasSpans', 'loadTeamHasSpansFailure']).toMatchValues({
+ teamHasSpans: null, // kea-loaders sets to null on failure
+ teamHasSpansLoading: false,
+ teamHasSpansCheckFailed: true,
+ })
+ })
+
+ it('starts with loading state on mount', async () => {
+ useMocks({
+ get: {
+ '/api/environments/:team_id/tracing/spans/has_spans/': () => [200, { hasSpans: true }],
+ },
+ })
+
+ logic = tracingIngestionLogic()
+ logic.mount()
+
+ // Immediately after mount, the loader should be in loading state
+ expect(logic.values.teamHasSpansLoading).toBe(true)
+
+ await expectLogic(logic).toDispatchActions(['loadTeamHasSpansSuccess'])
+ })
+
+ it('resets teamHasSpansCheckFailed on new load attempt', async () => {
+ let callCount = 0
+ useMocks({
+ get: {
+ '/api/environments/:team_id/tracing/spans/has_spans/': () => {
+ callCount++
+ if (callCount <= 3) {
+ return [500, { detail: 'Server error' }]
+ }
+ return [200, { hasSpans: true }]
+ },
+ },
+ })
+
+ logic = tracingIngestionLogic()
+ logic.mount()
+
+ // First attempt fails after retries
+ await expectLogic(logic).toDispatchActions(['loadTeamHasSpans', 'loadTeamHasSpansFailure']).toMatchValues({
+ teamHasSpansCheckFailed: true,
+ })
+
+ // Manual retry succeeds
+ logic.actions.loadTeamHasSpans()
+
+ await expectLogic(logic).toDispatchActions(['loadTeamHasSpans', 'loadTeamHasSpansSuccess']).toMatchValues({
+ teamHasSpans: true,
+ teamHasSpansCheckFailed: false,
+ })
+ })
+ })
+
+ describe('caching', () => {
+ it('skips API call when cachedTeamHasSpans is true', async () => {
+ const mockFn = jest.fn(() => [200, { hasSpans: true }])
+ useMocks({
+ get: { '/api/environments/:team_id/tracing/spans/has_spans/': mockFn },
+ })
+
+ logic = tracingIngestionLogic()
+ logic.mount()
+
+ await expectLogic(logic).toDispatchActions(['loadTeamHasSpans', 'loadTeamHasSpansSuccess'])
+ expect(mockFn).toHaveBeenCalledTimes(1)
+
+ logic.unmount()
+
+ // Mount again - should skip API call due to cache
+ logic = tracingIngestionLogic()
+ logic.mount()
+
+ await expectLogic(logic).toNotHaveDispatchedActions(['loadTeamHasSpans'])
+ expect(mockFn).toHaveBeenCalledTimes(1)
+ expect(logic.values.hasSpans).toBe(true)
+ })
+
+ it('makes API call when cachedTeamHasSpans is null', async () => {
+ const mockFn = jest.fn(() => [200, { hasSpans: false }])
+ useMocks({
+ get: { '/api/environments/:team_id/tracing/spans/has_spans/': mockFn },
+ })
+
+ logic = tracingIngestionLogic()
+ logic.mount()
+
+ await expectLogic(logic).toDispatchActions(['loadTeamHasSpans', 'loadTeamHasSpansSuccess'])
+ expect(mockFn).toHaveBeenCalledTimes(1)
+
+ logic.unmount()
+
+ // Mount again - should make API call since false is not cached
+ logic = tracingIngestionLogic()
+ logic.mount()
+
+ await expectLogic(logic).toDispatchActions(['loadTeamHasSpans', 'loadTeamHasSpansSuccess'])
+ expect(mockFn).toHaveBeenCalledTimes(2)
+ })
+
+ it('hasSpans selector falls back to cachedTeamHasSpans when teamHasSpans is undefined', async () => {
+ useMocks({
+ get: { '/api/environments/:team_id/tracing/spans/has_spans/': () => [200, { hasSpans: true }] },
+ })
+
+ logic = tracingIngestionLogic()
+ logic.mount()
+
+ await expectLogic(logic).toDispatchActions(['loadTeamHasSpansSuccess'])
+ expect(logic.values.cachedTeamHasSpans).toBe(true)
+
+ logic.unmount()
+
+ // Remount - teamHasSpans starts undefined, hasSpans should use cached
+ logic = tracingIngestionLogic()
+ logic.mount()
+
+ expect(logic.values.teamHasSpans).toBeFalsy()
+ expect(logic.values.hasSpans).toBe(true)
+ })
+ })
+})
diff --git a/products/tracing/frontend/components/SetupPrompt/tracingIngestionLogic.tsx b/products/tracing/frontend/components/SetupPrompt/tracingIngestionLogic.tsx
new file mode 100644
index 000000000000..7acd4eb5cf62
--- /dev/null
+++ b/products/tracing/frontend/components/SetupPrompt/tracingIngestionLogic.tsx
@@ -0,0 +1,53 @@
+import { afterMount, kea, path, reducers, selectors } from 'kea'
+import { loaders } from 'kea-loaders'
+
+import api from 'lib/api'
+import { retryWithBackoff } from 'lib/utils'
+
+import type { tracingIngestionLogicType } from './tracingIngestionLogicType'
+
+const teamId = window.POSTHOG_APP_CONTEXT?.current_team?.id
+
+export const tracingIngestionLogic = kea<tracingIngestionLogicType>([
+ path(['products', 'tracing', 'components', 'SetupPrompt', 'tracingIngestionLogic']),
+ loaders({
+ teamHasSpans: {
+ __default: undefined as boolean | undefined,
+ loadTeamHasSpans: async (): Promise<boolean> => {
+ return await retryWithBackoff(() => api.tracing.hasSpans(), { maxAttempts: 3 })
+ },
+ },
+ }),
+
+ reducers({
+ teamHasSpansCheckFailed: [
+ false,
+ {
+ loadTeamHasSpans: () => false,
+ loadTeamHasSpansSuccess: () => false,
+ loadTeamHasSpansFailure: () => true,
+ },
+ ],
+ cachedTeamHasSpans: [
+ null as boolean | null,
+ { persist: true, prefix: `${teamId}__` },
+ {
+ // Only cache true - spans don't disappear once ingested
+ loadTeamHasSpansSuccess: (_, { teamHasSpans }) => teamHasSpans || null,
+ },
+ ],
+ }),
+
+ selectors({
+ hasSpans: [
+ (s) => [s.teamHasSpans, s.cachedTeamHasSpans],
+ (teamHasSpans, cachedTeamHasSpans): boolean | undefined => teamHasSpans ?? cachedTeamHasSpans ?? undefined,
+ ],
+ }),
+
+ afterMount(({ actions, values }) => {
+ if (values.cachedTeamHasSpans !== true) {
+ actions.loadTeamHasSpans()
+ }
+ }),
+])
diff --git a/products/tracing/frontend/generated/api.schemas.ts b/products/tracing/frontend/generated/api.schemas.ts
index 0fd23e755d2a..218309bbb022 100644
--- a/products/tracing/frontend/generated/api.schemas.ts
+++ b/products/tracing/frontend/generated/api.schemas.ts
@@ -114,6 +114,11 @@ export interface _TracingAggregationRequestApi {
query: _TracingAggregationQueryBodyApi
}
+export interface _HasSpansResponseApi {
+ /** Whether the team has ingested any tracing spans yet. Used to gate the onboarding empty state. */
+ hasSpans: boolean
+}
+
/**
* * `latest` - latest
* `earliest` - earliest
diff --git a/products/tracing/frontend/generated/api.ts b/products/tracing/frontend/generated/api.ts
index 7ae734eac76f..552586b65871 100644
--- a/products/tracing/frontend/generated/api.ts
+++ b/products/tracing/frontend/generated/api.ts
@@ -12,6 +12,7 @@ import type {
TracingSpansAttributesRetrieveParams,
TracingSpansServiceNamesRetrieveParams,
TracingSpansValuesRetrieveParams,
+ _HasSpansResponseApi,
_TracingAggregationRequestApi,
_TracingQueryRequestApi,
_TracingTraceRequestApi,
@@ -65,6 +66,20 @@ export const tracingSpansAttributesRetrieve = async (
})
}
+export const getTracingSpansHasSpansRetrieveUrl = (projectId: string) => {
+ return `/api/projects/${projectId}/tracing/spans/has_spans/`
+}
+
+export const tracingSpansHasSpansRetrieve = async (
+ projectId: string,
+ options?: RequestInit
+): Promise<_HasSpansResponseApi> => {
+ return apiMutator<_HasSpansResponseApi>(getTracingSpansHasSpansRetrieveUrl(projectId), {
+ ...options,
+ method: 'GET',
+ })
+}
+
export const getTracingSpansQueryCreateUrl = (projectId: string) => {
return `/api/projects/${projectId}/tracing/spans/query/`
}
diff --git a/products/tracing/mcp/tools.yaml b/products/tracing/mcp/tools.yaml
index 2f1eb7dee347..184ee1e76966 100644
--- a/products/tracing/mcp/tools.yaml
+++ b/products/tracing/mcp/tools.yaml
@@ -141,3 +141,6 @@ tools:
response:
include:
- results
+ tracing-spans-has-spans-retrieve:
+ operation: tracing_spans_has_spans_retrieve
+ enabled: false
diff --git a/products/tracing/package.json b/products/tracing/package.json
index bb9e6b8cd551..f54e65c13e68 100644
--- a/products/tracing/package.json
+++ b/products/tracing/package.json
@@ -9,6 +9,9 @@
"kea-router": "catalog:",
"posthog-js": "catalog:"
},
+ "devDependencies": {
+ "kea-test-utils": "catalog:"
+ },
"peerDependencies": {
"@posthog/icons": "*",
"@types/react": "*",
diff --git a/pyproject.toml b/pyproject.toml
index ddef3a37e525..c0ca7f8ba4f0 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -507,6 +507,7 @@ ignore_imports = [
"products.notifications.backend.presentation.views -> products.notifications.backend.models",
"products.tracing.backend.presentation.views -> products.tracing.backend.logic",
"products.tracing.backend.presentation.views -> products.tracing.backend.sparkline_query_runner",
+ "products.tracing.backend.presentation.views -> products.tracing.backend.has_spans_query_runner",
"products.user_interviews.backend.presentation.views -> products.user_interviews.backend.models",
"products.user_interviews.backend.presentation.webhooks -> products.user_interviews.backend.models",
]
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index b22efe7197f2..10b7c164cd66 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -39178,6 +39178,11 @@ export namespace Schemas {
detail: string;
}
+ export interface _HasSpansResponse {
+ /** Whether the team has ingested any tracing spans yet. Used to gate the onboarding empty state. */
+ hasSpans: boolean;
+ }
+
export interface _LogAttributeEntry {
name: string;
/** Property filter type: "log_attribute" or "log_resource_attribute". Use this as the `type` field when filtering. */