Skip to content

Sentry Supabase Integration #2913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open

Sentry Supabase Integration #2913

wants to merge 45 commits into from

Conversation

denrase
Copy link
Collaborator

@denrase denrase commented May 6, 2025

📜 Description

Supabase instrumentation for database operations (no auth instrumentation)

  • Breadcrumbs
  • Body Redaction
  • Tracing
  • Errors
  • PII (Body, Query)

💡 Motivation and Context

Closes #2727

💚 How did you test it?

Unit tests.

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPii is enabled
  • I updated the docs if needed
  • All tests passing
  • No breaking changes

Copy link
Contributor

github-actions bot commented May 6, 2025

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 522db05

Copy link

codecov bot commented May 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.70%. Comparing base (33f99c9) to head (522db05).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2913      +/-   ##
==========================================
- Coverage   87.74%   87.70%   -0.04%     
==========================================
  Files         286      286              
  Lines        9335     9340       +5     
==========================================
+ Hits         8191     8192       +1     
- Misses       1144     1148       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

github-actions bot commented May 6, 2025

Android Performance metrics 🚀

  Plain With Sentry Diff
Startup time 453.31 ms 507.02 ms 53.71 ms
Size 6.54 MiB 7.53 MiB 1017.45 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
8ced2dc 295.58 ms 336.49 ms 40.91 ms
4b29d6e 386.80 ms 430.86 ms 44.06 ms
5f443de 412.30 ms 491.67 ms 79.37 ms
04db237 330.16 ms 428.38 ms 98.22 ms
689d2fd 378.62 ms 430.48 ms 51.86 ms
6572f8d 302.35 ms 348.10 ms 45.75 ms
ccc09e4 308.21 ms 357.74 ms 49.54 ms
7954fb3 459.38 ms 500.72 ms 41.34 ms
33f99c9 668.33 ms 735.08 ms 66.76 ms
dd5521e 454.51 ms 538.29 ms 83.78 ms

App size

Revision Plain With Sentry Diff
8ced2dc 6.06 MiB 7.03 MiB 990.29 KiB
4b29d6e 6.33 MiB 7.26 MiB 946.14 KiB
5f443de 6.35 MiB 7.34 MiB 1008.00 KiB
04db237 5.94 MiB 6.95 MiB 1.01 MiB
689d2fd 6.06 MiB 7.10 MiB 1.04 MiB
6572f8d 6.15 MiB 7.13 MiB 999.97 KiB
ccc09e4 5.94 MiB 6.95 MiB 1.01 MiB
7954fb3 6.49 MiB 7.57 MiB 1.08 MiB
33f99c9 6.54 MiB 7.53 MiB 1017.45 KiB
dd5521e 6.44 MiB 7.50 MiB 1.06 MiB

Previous results on branch: feat/supabase

Startup times

Revision Plain With Sentry Diff
6a8651f 476.65 ms 532.62 ms 55.96 ms
5e3ca91 451.24 ms 496.74 ms 45.50 ms
8bd9497 470.21 ms 524.26 ms 54.05 ms
34b0923 509.55 ms 590.18 ms 80.62 ms
30c089b 471.71 ms 522.65 ms 50.94 ms
0ab2edd 459.85 ms 506.63 ms 46.77 ms
0a08454 515.10 ms 634.67 ms 119.57 ms
e4d1bf6 499.64 ms 528.47 ms 28.82 ms

App size

Revision Plain With Sentry Diff
6a8651f 6.54 MiB 7.53 MiB 1015.94 KiB
5e3ca91 6.44 MiB 7.44 MiB 1017.53 KiB
8bd9497 6.44 MiB 7.43 MiB 1013.21 KiB
34b0923 6.44 MiB 7.43 MiB 1013.10 KiB
30c089b 6.44 MiB 7.43 MiB 1010.46 KiB
0ab2edd 6.54 MiB 7.53 MiB 1016.33 KiB
0a08454 6.44 MiB 7.43 MiB 1013.22 KiB
e4d1bf6 6.44 MiB 7.44 MiB 1017.53 KiB

Copy link
Contributor

github-actions bot commented May 6, 2025

iOS Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1252.60 ms 1271.13 ms 18.52 ms
Size 7.86 MiB 9.45 MiB 1.59 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
c1bb00f 1265.14 ms 1290.85 ms 25.71 ms
f172c4d 1350.66 ms 1408.49 ms 57.83 ms
0be962b 1264.10 ms 1281.16 ms 17.06 ms
6325c3b 1266.52 ms 1291.06 ms 24.54 ms
e1897c5 1252.61 ms 1276.48 ms 23.87 ms
aa950e9 1275.17 ms 1295.33 ms 20.16 ms
a49594a 1284.83 ms 1313.29 ms 28.45 ms
1131914 1277.20 ms 1300.20 ms 23.00 ms
7659cbe 1246.70 ms 1265.88 ms 19.17 ms
3f23617 1261.93 ms 1286.10 ms 24.17 ms

App size

Revision Plain With Sentry Diff
c1bb00f 8.09 MiB 9.07 MiB 1001.06 KiB
f172c4d 8.33 MiB 9.62 MiB 1.29 MiB
0be962b 8.10 MiB 9.16 MiB 1.07 MiB
6325c3b 8.16 MiB 9.17 MiB 1.01 MiB
e1897c5 8.42 MiB 9.91 MiB 1.49 MiB
aa950e9 8.16 MiB 9.17 MiB 1.01 MiB
a49594a 8.16 MiB 9.16 MiB 1.00 MiB
1131914 8.16 MiB 9.17 MiB 1.01 MiB
7659cbe 8.42 MiB 9.89 MiB 1.47 MiB
3f23617 8.16 MiB 9.17 MiB 1.01 MiB

Previous results on branch: feat/supabase

Startup times

Revision Plain With Sentry Diff
6a8651f 1254.15 ms 1266.88 ms 12.73 ms
30c089b 1257.23 ms 1269.16 ms 11.93 ms
5e3ca91 1263.90 ms 1277.43 ms 13.53 ms
8bd9497 1265.35 ms 1273.98 ms 8.63 ms
0ab2edd 1254.71 ms 1264.28 ms 9.56 ms
34b0923 1269.29 ms 1275.88 ms 6.59 ms
0a08454 1265.15 ms 1283.18 ms 18.04 ms
e4d1bf6 1249.16 ms 1267.12 ms 17.96 ms

App size

Revision Plain With Sentry Diff
6a8651f 7.85 MiB 9.42 MiB 1.57 MiB
30c089b 8.43 MiB 10.01 MiB 1.58 MiB
5e3ca91 8.43 MiB 10.00 MiB 1.56 MiB
8bd9497 8.43 MiB 10.01 MiB 1.58 MiB
0ab2edd 7.85 MiB 9.45 MiB 1.59 MiB
34b0923 8.43 MiB 10.01 MiB 1.58 MiB
0a08454 8.43 MiB 10.01 MiB 1.58 MiB
e4d1bf6 8.43 MiB 10.00 MiB 1.56 MiB

@denrase denrase changed the title Supabase Support Sentry Supabase Integration May 21, 2025
@denrase denrase marked this pull request as ready for review May 21, 2025 13:58
Copy link
Contributor

@buenaflor buenaflor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick pass, I'll have a closer look later

static Map<String, dynamic>? _readBody(String table, BaseRequest request) {
final bodyString =
request is Request && request.body.isNotEmpty ? request.body : null;
final body = bodyString != null ? jsonDecode(bodyString) : null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we introduce some limit? or does the supabase SDK already handle big request bodies?

Comment on lines 48 to 49
description,
'db.${supabaseRequest.operation.value}',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can do span op: db.sql.query and description to be the full supabase query

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure i understand. Could you give me an example for this case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like:

description: 'SELECT * FROM TABLE'
op: 'db.sql.query'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added support for this, including most common operations/clauses.

Comment on lines 6 to 35
class SentrySupabaseTracingClient extends BaseClient {
final Client _innerClient;
final Hub _hub;

SentrySupabaseTracingClient(this._innerClient, this._hub);

@override
Future<StreamedResponse> send(BaseRequest request) async {
final supabaseRequest = SentrySupabaseRequest.fromRequest(request);

final span = _createSpan(supabaseRequest);

StreamedResponse? response;

try {
response = await _innerClient.send(request);

span?.setData('http.response.status_code', response.statusCode);
span?.setData('http.response_content_length', response.contentLength);
span?.status = SpanStatus.fromHttpStatusCode(response.statusCode);
} catch (e) {
span?.throwable = e;
span?.status = SpanStatus.internalError();
rethrow;
} finally {
await span?.finish();
}

return response;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is also triggered for auth requests? we gotta make sure this only handles database operations

auth tracing should be separate

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now only handling the restful requests, ignoring everything else (including auth).

@denrase denrase requested a review from buenaflor June 30, 2025 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Supabase Support
2 participants