• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / storage / 24848158243

23 Apr 2026 05:03PM UTC coverage: 71.255% (+1.3%) from 69.952%
24848158243

push

github

web-flow
feat: add sb-request-id logging (#1041)

* feat: add sb-request-id logging

Also propagate the existing `reqId` where missed.

Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>

* chore: system tenant

Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>

---------

Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>

3480 of 5443 branches covered (63.94%)

Branch coverage included in aggregate %.

81 of 89 new or added lines in 25 files covered. (91.01%)

6 existing lines in 4 files now uncovered.

7333 of 9732 relevant lines covered (75.35%)

377.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

16.13
/src/http/plugins/tracing.ts
1
import { getTenantConfig } from '@internal/database'
2
import { logSchema } from '@internal/monitoring'
3
import fastifyPlugin from 'fastify-plugin'
4
import { getConfig } from '../../config'
5

6
declare module 'fastify' {
7
  interface FastifyRequest {
8
    tracingMode?: string
9
    serverTimings?: { spanName: string; duration: number }[]
10
  }
11
}
12

13
const { isMultitenant, tracingEnabled, tracingMode: defaultTracingMode } = getConfig()
26✔
14

15
export const tracing = fastifyPlugin(
26✔
16
  async function tracingMode(fastify) {
17
    if (!tracingEnabled) {
264!
18
      return
264✔
19
    }
20

21
    fastify.addHook('onRequest', async (request) => {
×
22
      try {
×
23
        if (isMultitenant && request.tenantId) {
×
24
          const tenantConfig = await getTenantConfig(request.tenantId)
×
25
          request.tracingMode = tenantConfig.tracingMode
×
26
        } else {
27
          request.tracingMode = defaultTracingMode
×
28
        }
29

30
        // Use request.opentelemetry().span to get the root request span,
31
        // not trace.getActiveSpan() which returns a child hook span.
32
        const span =
33
          typeof request.opentelemetry === 'function' ? request.opentelemetry()?.span : undefined
×
34
        if (span) {
×
35
          if (request.tenantId) {
×
36
            span.setAttribute('tenant.ref', request.tenantId)
×
37
          }
38
          if (request.tracingMode) {
×
39
            span.setAttribute('trace.mode', request.tracingMode)
×
40
          }
41
        }
42
      } catch (e) {
NEW
43
        logSchema.error(request.log, 'failed setting tracing mode', {
×
44
          error: e,
45
          type: 'tracing',
46
          sbReqId: request.sbReqId,
47
        })
48
      }
49
    })
50
  },
51
  { name: 'tracing-mode' }
52
)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc