Skip to content
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

WIP - Add firebase integration #13954

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft

WIP - Add firebase integration #13954

wants to merge 4 commits into from

Conversation

obecny
Copy link
Collaborator

@obecny obecny commented Oct 11, 2024

Before submitting a pull request, please take a look at our
Contributing guidelines and verify:

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).

@obecny obecny marked this pull request as draft October 11, 2024 10:53
Copy link
Contributor

github-actions bot commented Oct 11, 2024

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 22.73 KB - -
@sentry/browser - with treeshaking flags 21.53 KB - -
@sentry/browser (incl. Tracing) 34.97 KB - -
@sentry/browser (incl. Tracing, Replay) 71.62 KB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 62.03 KB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 75.97 KB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 88.73 KB - -
@sentry/browser (incl. Tracing, Replay, Feedback, metrics) 90.59 KB - -
@sentry/browser (incl. metrics) 27 KB - -
@sentry/browser (incl. Feedback) 39.87 KB - -
@sentry/browser (incl. sendFeedback) 27.38 KB - -
@sentry/browser (incl. FeedbackAsync) 32.17 KB - -
@sentry/react 25.49 KB - -
@sentry/react (incl. Tracing) 37.94 KB - -
@sentry/vue 26.91 KB - -
@sentry/vue (incl. Tracing) 36.86 KB - -
@sentry/svelte 22.87 KB - -
CDN Bundle 24.05 KB - -
CDN Bundle (incl. Tracing) 36.76 KB - -
CDN Bundle (incl. Tracing, Replay) 71.38 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 76.7 KB - -
CDN Bundle - uncompressed 70.53 KB - -
CDN Bundle (incl. Tracing) - uncompressed 109.04 KB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 221.4 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 234.62 KB - -
@sentry/nextjs (client) 37.91 KB - -
@sentry/sveltekit (client) 35.56 KB - -
@sentry/node 125.61 KB +0.57% +726 B 🔺
@sentry/node - without tracing 94.13 KB - -
@sentry/aws-serverless 103.7 KB - -

View base workflow run

@Lms24 Lms24 self-requested a review October 14, 2024 13:10
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Took a first look. I think this PR is going into a good direction and I think - once we addressed the open todos - we should merge it in and build new features on top of it.

A couple of things I think are worth looking into in the future (i.e. not in this PR):

  • should we patch collection? I'm not entirely sure what the function does but it returns the ref to the document collection so maybe it's interesting?
  • I'd like us to collect more information about the query. Would be great if we could somehow build a query from the individual query composition functions
  • I think it'd be worth to look into firebase auth and file storage but these could definitely come later.


const config: FirebaseInstrumentationConfig = {
firestoreSpanCreationHook: (span: Span) => {
addOriginToSpan(span, 'auto.firebase.otel.firestore');
Copy link
Member

Choose a reason for hiding this comment

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

We should also set the sentry.op attribute here. It should be db.query according to the develop spec but I'll check if this is the op for all CRUD operations.

Comment on lines +84 to +93
for (let i = 0, j = files.length; i < j; i++) {
moduleFirestoreCJS.files.push(
new InstrumentationNodeModuleFile(
files[i] as string,
firestoreSupportedVersions,
moduleExports => wrapMethods(moduleExports, wrap, unwrap, tracer, firestoreSpanCreationHook),
moduleExports => unwrapMethods(moduleExports, unwrap),
),
);
}
Copy link
Member

Choose a reason for hiding this comment

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

I think we can simplify this loop to a simple for ... of loop or .foreach, right? Should help us get rid of the two indexes we don't need.

): void {
const firestoreApp: FirebaseApp = reference.firestore.app;
const firestoreOptions: FirebaseOptions = firestoreApp.options;

Copy link
Member

Choose a reason for hiding this comment

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

We should also also add the db.* semantic attributes that apply for firestore. Feel free to tackle this in this PR or in a follow-up. I'll leave this up to you to decide! https://github.com/open-telemetry/semantic-conventions/blob/main/docs/attributes-registry/db.md#generic-database-attributes

Copy link
Member

@Lms24 Lms24 Oct 15, 2024

Choose a reason for hiding this comment

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

At least, we should set db.system because our Sentry "Queries" performance insights module needs it

Copy link
Member

Choose a reason for hiding this comment

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

Let me expand on this a bit: Our Queries module has some specific requirements which information the db spans need to contain. Moreover, the support is scoped to specific databases, identified by db.system. At the moment, Firestore is not supported but I think we should model the spans according to the specification for MongoDB (given both are NoSQL albeit Firestore being less "powerful").

Unfortunately, the MongoDB spec isn't yet merged but there's a PR open which probably only needs to be merged: getsentry/sentry-docs#11234. I'd recommend you give this a read and we make adjustments in follow-up PRs. To completely satisfy the spec we'll need to be able to access or reconstruct the query.

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.

2 participants