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

refactor: switch to hub object storage s3 client #28140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pl
Copy link
Contributor

@pl pl commented Jan 31, 2025

Problem

Session recording v2 instantiated a new S3 client, which wasn't properly set up.

Changes

Switches to the S3 client provided by the hub or by the getObjectStorage factory.

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Does this work well for both Cloud and self-hosted?

Yes

How did you test this code?

Will verify on dev.

@pl pl requested a review from a team January 31, 2025 13:28
@@ -495,17 +495,31 @@ export async function startPluginsServer(
if (capabilities.sessionRecordingBlobIngestionV2) {
const hub = await setupHub()
const postgres = hub?.postgres ?? new PostgresRouter(serverConfig)
const objectStorage = hub?.objectStorage ?? getObjectStorage(serverConfig)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmmmm does this mean that we are using the same config as the other recorder? We definitely don't want to use the same bucket etc 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We use that bucket for a few other things too, so I wanted to get something running quickly. I can take a look at creating a new bucket – creating the bucket should be easy, I'm not sure how access keys are handled in this case though.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR refactors the session recording ingestion to use a centralized S3 client from the hub's object storage instead of creating its own instance, improving configuration management and dependency injection.

  • Modified SessionRecordingIngesterV2 constructor to accept an external S3Client in /plugin-server/src/main/ingestion-queues/session-recording-v2/consumer.ts
  • Simplified S3SessionBatchWriter to use injected S3Client in /plugin-server/src/main/ingestion-queues/session-recording-v2/sessions/s3-session-batch-writer.ts
  • Updated pluginsServer.ts to pass hub's object storage S3 client to session recording ingestion
  • Removed SESSION_RECORDING_V2_S3_REGION config as region is now handled through hub's object storage
  • Updated test suite to use mocked S3Client through dependency injection instead of internal creation

5 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile


beforeEach(() => {
uploadedData = Buffer.alloc(0)
jest.mocked(S3Client).mockImplementation(() => ({} as any))
mockS3Client = {} as jest.Mocked<S3Client>
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Empty mock object might not be sufficient - consider adding minimal required S3Client interface methods

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