-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
base: master
Are you sure you want to change the base?
Conversation
@@ -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) |
There was a problem hiding this comment.
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 🤔
There was a problem hiding this comment.
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.
There was a problem hiding this 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> |
There was a problem hiding this comment.
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
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.