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

feat(factory): introduce factories #6782

Closed
wants to merge 18 commits into from
Closed

feat(factory): introduce factories #6782

wants to merge 18 commits into from

Conversation

grandwizard28
Copy link
Collaborator

@grandwizard28 grandwizard28 commented Jan 8, 2025

Summary

feat(pkg/factory)

  • Introduce factories for base initialization of all components.
  • Move service to factory.

refactor(pkg/config)

  • Introduced new configuration system using factory and provider patterns in pkg/config and pkg/factory.
  • Removed dependency on opentelemetry-collector.
  • Added NewConfigFactory and NewProviderFactory for modular configuration.

feat(pkg/sqlstore)

  • Refactored database initialization to use sqlstore and migrations.
  • Consolidate migration files for all migrations.
  • Refactor query-service to use this new package.

feat(pkg/web)

  • Introduced noop provider in web
  • Add config ENABLED to web.

refactor(pkg/instrumentation)

  • Use the upstream sdk for initialization
  • Remove unnecessary and verbose config

Important

Introduce factory-based initialization, refactor configuration and database setup, and update web and instrumentation components.

  • Factories and Initialization:
    • Introduce factory-based initialization for components in pkg/factory.
    • Refactor pkg/config to use factory and provider patterns.
    • Add NewConfigFactory and NewProviderFactory for modular configuration.
  • Database and Migrations:
    • Refactor database initialization in pkg/sqlstore to use sqlstore and migrations.
    • Consolidate migration files in pkg/sqlstoremigrator/migrations.
    • Update dao and sqlite packages to use new database initialization.
  • Web and Instrumentation:
    • Introduce noop provider in pkg/web and add ENABLED config.
    • Use upstream SDK for initialization in pkg/instrumentation.
  • Testing and Utilities:
    • Update tests in pkg/query-service/tests/integration to align with new initialization.
    • Refactor NewQueryServiceDBForTests in pkg/query-service/utils/testutils.go to use new factory system.

This description was created by Ellipsis for b10a906. It will automatically update as commits are pushed.

Copy link

github-actions bot commented Jan 8, 2025

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

1 similar comment
Copy link

github-actions bot commented Jan 8, 2025

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Reviewed everything up to ae5ba2b in 1 minute and 44 seconds

More details
  • Looked at 1775 lines of code in 34 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. pkg/config/conf.go:28
  • Draft comment:
    The comment on line 28 is misleading. It should clarify that the function merges the input configuration at a specified path within the current configuration.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The comment on line 28 incorrectly states that the function merges the current configuration with the input configuration. This is misleading as the function actually merges the input configuration at a specified path within the current configuration.
2. pkg/config/uri.go:10
  • Draft comment:
    The comment on line 10 is misleading. It should clarify that the regex matches a specific format of URI, not the entire URI definition.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The comment on line 10 in pkg/config/uri.go is misleading. It states that the regex complies with the URI definition, but it only matches a specific format of URI. This should be clarified.
3. pkg/web/config.go:10
  • Draft comment:
    The comment on line 10 is outdated. It should reflect that the Config satisfies the new config.Config interface, not confmap.Config.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The comment on line 10 in pkg/web/config.go is misleading. It states that the Config satisfies the confmap.Config interface, but it should be updated to reflect the new config.Config interface.
4. pkg/web/router/router.go:1
  • Draft comment:
    Avoid using the component/index.tsx file structure approach, as it makes it difficult to debug and find components using global search tools like VS Code.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_XloMbrlpzoO23qs6


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

pkg/web/router/router.go Fixed Show fixed Hide fixed
pkg/config/conf.go Outdated Show resolved Hide resolved
vikrantgupta25
vikrantgupta25 previously approved these changes Jan 9, 2025
Copy link

github-actions bot commented Jan 9, 2025

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 4c94386 in 1 minute and 31 seconds

More details
  • Looked at 2466 lines of code in 40 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. pkg/signoz/signoz.go:24
  • Draft comment:
    Add error handling for unrecognized cache providers to prevent potential nil pointer dereference.
  • Reason this comment was not posted:
    Comment was not on a valid diff hunk.
2. pkg/signoz/signoz.go:46
  • Draft comment:
    Add error handling for web initialization to prevent potential nil pointer dereference.
  • Reason this comment was not posted:
    Comment was not on a valid diff hunk.
3. pkg/signoz/signoz.go:57
  • Draft comment:
    Add error handling for sqlStore initialization to prevent potential nil pointer dereference.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
4. pkg/query-service/app/server.go:27
  • Draft comment:
    Avoid using the component/index.tsx file structure approach, as it makes it difficult to debug and find components using global search tools like VS Code.
  • Reason this comment was not posted:
    Comment was not on a valid diff hunk.

Workflow ID: wflow_SdvgtI8IbXj32Z5C


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

github-actions bot commented Jan 9, 2025

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 5d26d2b in 1 minute and 8 seconds

More details
  • Looked at 170 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. pkg/query-service/app/integrations/manager.go:126
  • Draft comment:
    Removing error handling for NewInstalledIntegrationsSqliteRepo can lead to runtime errors if the database is not properly initialized. Consider re-adding error handling to ensure robustness.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
  1. Without seeing NewInstalledIntegrationsSqliteRepo implementation, I can't be certain if it can fail. 2. The change suggests the function was modified to not return an error anymore. 3. If the function signature changed, then error handling would be unnecessary. 4. The code compiles, suggesting the function signature must have changed. 5. The PR author likely made this change intentionally after determining errors weren't possible.
    I don't have access to the NewInstalledIntegrationsSqliteRepo implementation or its changes. The comment could be valid if that function can still fail at runtime.
    Since the code compiles, the function signature must have changed to not return an error. The PR author likely determined error handling wasn't needed and simplified the API.
    Without seeing the NewInstalledIntegrationsSqliteRepo implementation or its changes, I cannot verify if error handling is actually needed. The comment makes assumptions without full context.
2. pkg/query-service/app/integrations/test_utils.go:18
  • Draft comment:
    Removing error handling for NewInstalledIntegrationsSqliteRepo can lead to runtime errors if the database is not properly initialized. Consider re-adding error handling to ensure robustness. This is also applicable in NewTestIntegrationsManager.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    This is a test utility function, and test utilities often simplify error handling for cleaner tests. The database is created using NewQueryServiceDBForTests which likely handles setup validation. Since this is test code, a panic on initialization failure is actually preferable to error propagation. The comment seems to be applying production code standards to test code.
    I could be wrong about the database initialization being validated in NewQueryServiceDBForTests. There could be valid reasons to handle errors even in test code.
    Even if the database initialization isn't fully validated elsewhere, having a test utility panic on setup failure is a valid and common pattern - it fails fast and makes test failures more obvious.
    The comment should be deleted as it's applying overly strict standards to test code where simplified error handling is acceptable and often preferred.
3. pkg/query-service/app/integrations/manager.go:126
  • Draft comment:
    The NewInstalledIntegrationsSqliteRepo function no longer returns an error, so the error handling in NewManager is unnecessary and should be removed.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.

Workflow ID: wflow_BOx5CKlqmlQpyfHW


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

github-actions bot commented Jan 9, 2025

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 0c3af05 in 1 minute and 5 seconds

More details
  • Looked at 106 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 drafted comments based on config settings.
1. ee/query-service/app/server.go:210
  • Draft comment:
    The removal of the 'engine' parameter from the NewLogParsingPipelinesController function call is consistent with the refactoring goal. Ensure that this parameter is not used elsewhere in the function.
  • Reason this comment was not posted:
    Confidence changes required: 20%
    The removal of the 'engine' parameter from the function signature is consistent across all instances where the function is called. This change aligns with the refactoring goal of removing unnecessary parameters.
2. pkg/query-service/agentConf/manager.go:42
  • Draft comment:
    The removal of the 'DBEngine' field from the ManagerOptions struct is consistent with the refactoring goal. Ensure that this field is not used elsewhere in the code.
  • Reason this comment was not posted:
    Confidence changes required: 20%
    The removal of the 'DBEngine' field from the ManagerOptions struct is consistent across all instances where the struct is used. This change aligns with the refactoring goal of removing unnecessary fields.
3. pkg/query-service/app/logparsingpipeline/controller.go:30
  • Draft comment:
    The removal of the 'engine' parameter from the NewLogParsingPipelinesController function call is consistent with the refactoring goal. Ensure that this parameter is not used elsewhere in the function.
  • Reason this comment was not posted:
    Confidence changes required: 20%
    The removal of the 'engine' parameter from the function signature is consistent across all instances where the function is called. This change aligns with the refactoring goal of removing unnecessary parameters.
4. pkg/query-service/tests/integration/logparsingpipeline_test.go:487
  • Draft comment:
    The removal of the 'DBEngine' field from the ManagerOptions struct is consistent with the refactoring goal. Ensure that this field is not used elsewhere in the code.
  • Reason this comment was not posted:
    Confidence changes required: 20%
    The removal of the 'DBEngine' field from the ManagerOptions struct is consistent across all instances where the struct is used. This change aligns with the refactoring goal of removing unnecessary fields.
5. pkg/query-service/app/server.go:174
  • Draft comment:
    Avoid using inline styles in React components. Use external stylesheets, CSS classes, or styled components instead. This is also applicable in other parts of the code where inline styles are used.
  • Reason this comment was not posted:
    Comment was not on a valid diff hunk.

Workflow ID: wflow_8M11gtu6Fo1lD3Vp


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

github-actions bot commented Jan 9, 2025

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on e1cb905 in 38 seconds

More details
  • Looked at 241 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. pkg/sqlstore/config.go:36
  • Draft comment:
    The increase in MaxOpenConns from 10 to 100 should be justified. Ensure the system can handle this increase without resource exhaustion.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The change in MaxOpenConns from 10 to 100 in pkg/sqlstore/config.go is significant and should be justified. Increasing the number of open connections can improve performance by allowing more concurrent database operations, but it can also lead to resource exhaustion if not managed properly. It's important to ensure that the system can handle this increase without negative side effects.
2. pkg/sqlstore/provider/sqlite/provider.go:33
  • Draft comment:
    The log message includes ?_foreign_keys=true in the path, which might be misleading as it's not part of the actual connection string. Consider aligning the log message with the actual connection string or explaining the discrepancy.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The connection string for SQLite in pkg/sqlstore/provider/sqlite/provider.go includes ?_foreign_keys=true in the log message but not in the actual connection string. This could lead to confusion as the log message suggests foreign keys are enabled by default, which is not the case unless explicitly set in the connection string or via PRAGMA command.
3. pkg/sqlstore/provider/sqlite/provider.go:5
  • Draft comment:
    Avoid using the component/index.tsx file structure approach, as it makes it difficult to debug and find components using global search tools.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_WX037G8SS8Azkp3M


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

github-actions bot commented Jan 9, 2025

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 2060905 in 36 seconds

More details
  • Looked at 75 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. pkg/sqlstore/provider/sqlite/provider.go:30
  • Draft comment:
    The refactor removed the explicit enabling of foreign key support using PRAGMA foreign_keys = ON;. Ensure that foreign key constraints are enforced as expected, as SQLite does not enable them by default.
  • Reason this comment was not posted:
    Comment did not seem useful.
2. pkg/sqlstore/provider/sqlite/provider.go:30
  • Draft comment:
    Avoid using inline styles in React components. Use external stylesheets, CSS classes, or styled components instead. This comment applies to other instances of inline styles in the code as well.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_iCItnw1uPH1tsZFP


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on e9decec in 37 seconds

More details
  • Looked at 76 lines of code in 4 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. pkg/query-service/utils/testutils.go:18
  • Draft comment:
    The function NewQueryServiceDBForTests is a good refactor as it encapsulates the setup of a test database, including migrations and DAO initialization, providing a cleaner and more reliable test setup.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The function NewQueryServiceDBForTests in pkg/query-service/utils/testutils.go is responsible for setting up a test database. It creates a temporary SQLite database file, initializes the SQL store, runs migrations, and initializes the DAO and dashboards. This function is used in the test files to provide a test database instance. The refactoring seems to replace the previous NewTestSqliteDB function with this new function, which is more comprehensive and encapsulates the setup process better.
2. ee/query-service/app/server.go:206
  • Draft comment:
    Refactored to use signoz.SqlStore.Provider().SqlxDB() for initializing cloudIntegrationsController, which centralizes database access and reduces redundancy.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The refactor in ee/query-service/app/server.go and pkg/query-service/app/server.go changes the way the cloudIntegrationsController is initialized. It now uses signoz.SqlStore.Provider().SqlxDB() instead of localDB. This change aligns with the refactor goal of removing upstream dependencies and centralizing the database access through signoz.SqlStore. This is a positive change as it reduces redundancy and potential inconsistencies in database access.
3. pkg/query-service/app/cloudintegrations/controller_test.go:15
  • Draft comment:
    Replaced NewTestSqliteDB with NewQueryServiceDBForTests for better encapsulation of test database setup, improving test reliability.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The refactor in pkg/query-service/app/cloudintegrations/controller_test.go replaces NewTestSqliteDB with NewQueryServiceDBForTests. This change is consistent with the refactor goal of centralizing test database setup. The new function encapsulates the setup process better, including migrations and DAO initialization, which improves test reliability.
4. pkg/query-service/app/server.go:177
  • Draft comment:
    Refactored to use signoz.SqlStore.Provider().SqlxDB() for initializing cloudIntegrationsController, aligning with the goal of centralizing database access.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The refactor in pkg/query-service/app/server.go changes the initialization of cloudIntegrationsController to use signoz.SqlStore.Provider().SqlxDB(). This aligns with the refactor goal of centralizing database access and removing upstream dependencies, which is a positive change for maintainability and consistency.

Workflow ID: wflow_5fjNCUa3QKXZ0UzS


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 50a06d1 in 48 seconds

More details
  • Looked at 71 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. pkg/sqlstore/migrations/007_add_integrations.go:37
  • Draft comment:
    Consider implementing the Down method to make the migration reversible. This will help in rolling back the migration if needed.
  • Reason this comment was not posted:
    Comment was not on a valid diff hunk.
2. pkg/sqlstore/migrations/007_add_integrations.go:40
  • Draft comment:
    Do not add non-ClickHouse related functions to the ClickHouseReader interface. Use the DAO in the telemetry instance to access such information instead.
  • Reason this comment was not posted:
    Comment was not on a valid diff hunk.

Workflow ID: wflow_DU2eZElvH4qeMJOr


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

1 similar comment
Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on e35d1c2 in 1 minute and 26 seconds

More details
  • Looked at 2165 lines of code in 41 files
  • Skipped 0 files when reviewing.
  • Skipped posting 6 drafted comments based on config settings.
1. ee/query-service/app/server.go:115
  • Draft comment:
    The refactoring replaces SqlStore.Provider().SqlxDB() with SQLStore.SQLxDB(). Ensure that this change is consistent across the codebase and aligns with the refactoring goal to remove upstream dependencies.
  • Reason this comment was not posted:
    Confidence changes required: 20%
    The refactoring seems to have removed the SqlStore.Provider().SqlxDB() calls and replaced them with SQLStore.SQLxDB(). This change is consistent across the files and aligns with the refactoring goal to remove upstream dependencies.
2. ee/query-service/main.go:148
  • Draft comment:
    The introduction of the instrumentation package and its usage to create an Instrumentation instance is a good practice. It modularizes the code and separates concerns.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The refactoring introduces a new instrumentation package and uses it to create an Instrumentation instance. This is a good practice as it modularizes the code and separates concerns.
3. pkg/cache/config.go:28
  • Draft comment:
    The introduction of the factory package to handle configuration and provider creation centralizes the creation logic and makes the code more maintainable.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The refactoring introduces a new factory package to handle configuration and provider creation. This is a good practice as it centralizes the creation logic and makes the code more maintainable.
4. pkg/sqlstore/config.go:30
  • Draft comment:
    The introduction of the factory package to handle configuration and provider creation centralizes the creation logic and makes the code more maintainable.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The refactoring introduces a new factory package to handle configuration and provider creation. This is a good practice as it centralizes the creation logic and makes the code more maintainable.
5. pkg/web/config.go:18
  • Draft comment:
    The introduction of the factory package to handle configuration and provider creation centralizes the creation logic and makes the code more maintainable.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The refactoring introduces a new factory package to handle configuration and provider creation. This is a good practice as it centralizes the creation logic and makes the code more maintainable.
6. pkg/signoz/config.go:22
  • Draft comment:
    The introduction of the factory package to handle configuration and provider creation centralizes the creation logic and makes the code more maintainable.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The refactoring introduces a new factory package to handle configuration and provider creation. This is a good practice as it centralizes the creation logic and makes the code more maintainable.

Workflow ID: wflow_B18PCoTALM59wbck


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 288747a in 1 minute and 41 seconds

More details
  • Looked at 2165 lines of code in 41 files
  • Skipped 0 files when reviewing.
  • Skipped posting 6 drafted comments based on config settings.
1. ee/query-service/app/server.go:115
  • Draft comment:
    Refactored to use signoz.SQLStore.SQLxDB() instead of signoz.SqlStore.Provider().SqlxDB(), which aligns with the refactoring goal to remove the dependency on opentelemetry-collector. This change is applied consistently across the files.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The refactoring of the NewServer function in ee/query-service/app/server.go and pkg/query-service/app/server.go is consistent with the intent to remove the dependency on opentelemetry-collector. The changes involve using signoz.SQLStore.SQLxDB() instead of signoz.SqlStore.Provider().SqlxDB(), which aligns with the refactoring goal. This change is applied consistently across the files.
2. pkg/query-service/main.go:91
  • Draft comment:
    Refactored to initialize instrumentation and signoz using the new factory pattern, which aligns with the refactoring goal to remove the dependency on opentelemetry-collector.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The refactoring in pkg/query-service/main.go and ee/query-service/main.go involves initializing the instrumentation and signoz instances with the new factory pattern. This change is consistent with the refactoring goal to remove the dependency on opentelemetry-collector. The initialization of instrumentation and signoz is done using the new NewProviderFactories method, which is a part of the refactoring.
3. pkg/cache/provider/memory/memory.go:18
  • Draft comment:
    Introduced a new factory pattern for creating cache providers using NewFactory, which aligns with the refactoring goal to remove the dependency on opentelemetry-collector.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The refactoring in pkg/cache/provider/memory/memory.go introduces a new factory pattern for creating cache providers. This change is consistent with the refactoring goal to remove the dependency on opentelemetry-collector. The NewFactory function is used to create a new provider factory for the memory cache, which aligns with the new factory pattern.
4. pkg/sqlstore/provider/sqlite/sqlite.go:23
  • Draft comment:
    Introduced a new factory pattern for creating SQL store providers using NewFactory, which aligns with the refactoring goal to remove the dependency on opentelemetry-collector.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The refactoring in pkg/sqlstore/provider/sqlite/sqlite.go introduces a new factory pattern for creating SQL store providers. This change is consistent with the refactoring goal to remove the dependency on opentelemetry-collector. The NewFactory function is used to create a new provider factory for the SQLite provider, which aligns with the new factory pattern.
5. pkg/sqlstore/migrations/migrations.go:19
  • Draft comment:
    Refactored to use the new factory pattern for creating migration instances using NamedMap, which aligns with the refactoring goal to remove the dependency on opentelemetry-collector.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The refactoring in pkg/sqlstore/migrations/migrations.go involves using the new factory pattern for creating migration instances. This change is consistent with the refactoring goal to remove the dependency on opentelemetry-collector. The New function now uses the NamedMap to get migration factories, which aligns with the new factory pattern.
6. pkg/query-service/app/server.go:98
  • Draft comment:
    Avoid using inline styles in React components. Use external stylesheets, CSS classes, or styled components instead. This is also applicable at line 115, 153, 170, and 233.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_Nm8s5l6BS2KSoR9s


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 6a7975a in 51 seconds

More details
  • Looked at 216 lines of code in 4 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. ee/query-service/main.go:94
  • Draft comment:
    The removal of the enableQueryServiceLogOTLPExport flag and related logic changes the functionality. Ensure this is intended and documented.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The PR refactors the logging setup by removing the custom initialization and using the logger from the instrumentation package. This is a good change as it centralizes logging configuration. However, the removal of the enableQueryServiceLogOTLPExport flag and related logic should be noted as it changes the functionality.
2. pkg/query-service/main.go:87
  • Draft comment:
    The removal of the initZapLog function changes the logging setup. Ensure this is intended and documented.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The PR refactors the logging setup by removing the custom initialization and using the logger from the instrumentation package. This is a good change as it centralizes logging configuration. However, the removal of the initZapLog function should be noted as it changes the logging setup.

Workflow ID: wflow_QCSU5FCHm6TrL9Jd


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 63a7ae5 in 1 minute and 51 seconds

More details
  • Looked at 37 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. go.sum:947
  • Draft comment:
    The go.sum file contains future-dated versions (e.g., golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842). This is likely incorrect and should be reviewed.
  • Reason this comment was not posted:
    Comment did not seem useful.

Workflow ID: wflow_LzwDg7J55QrHpI77


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@grandwizard28 grandwizard28 changed the title refactor(config): refactor config package feat(factory): introduce factories Jan 15, 2025
Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Member

@nityanandagohain nityanandagohain left a comment

Choose a reason for hiding this comment

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

I tried to review, but I am getting lost.

From what is seems,it feels like separate pr's can be created.

MaxOpenConns: 100,
},
Sqlite: SqliteConfig{
Path: "/var/lib/signoz/signoz.db",
Copy link
Member

Choose a reason for hiding this comment

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

env variables ?

return err
}

if _, err := db.ExecContext(ctx, `CREATE TABLE IF NOT EXISTS cloud_integrations_accounts(
Copy link
Member

Choose a reason for hiding this comment

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

since these are already known things, I guess we can club this all to the 001_migration_squashed, anything new can be added as a new migration.

}

var config Config
if err := conf.Unmarshal("", &config); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

what is the use of this ?

@github-actions github-actions bot added the enhancement New feature or request label Jan 16, 2025
Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on fae0581 in 3 minutes and 0 seconds

More details
  • Looked at 1071 lines of code in 30 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. ee/query-service/main.go:14
  • Draft comment:
    The import alias signozconfig is not used and can be removed to clean up the code.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The import path for envprovider has been changed in the PR, but the import alias signozconfig is no longer used. This alias should be removed to clean up the code.
2. pkg/query-service/main.go:12
  • Draft comment:
    The import alias signozconfig is not used and can be removed to clean up the code.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The import path for envprovider has been changed in the PR, but the import alias signozconfig is no longer used. This alias should be removed to clean up the code.
3. pkg/cache/memorycache/memory.go:1
  • Draft comment:
    Avoid using the component/index.tsx file structure approach, as it makes it difficult to debug and find components using global search tools like VS Code. This is applicable in other files like pkg/cache/memorycache/memory_test.go, pkg/cache/rediscache/redis.go, pkg/cache/rediscache/redis_test.go, etc.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_cSrKC9rVGdSO4JMv


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on b10a906 in 1 minute and 21 seconds

More details
  • Looked at 72 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. pkg/signoz/provider.go:10
  • Draft comment:
    The import path for migrations should be updated to "go.signoz.io/signoz/pkg/sqlstoremigrator/migrations" to maintain consistency with other files.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
2. pkg/query-service/utils/testutils.go:16
  • Draft comment:
    Avoid using the component/index.tsx file structure approach, as it makes it difficult to debug and find components using global search tools like VS Code. This is applicable to the pkg/sqlstoremigrator/migrations/003_add_dashboards.go file and other similar files.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_SaHPzgkMPBEqAJw7


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

path := filepath.Join(web.config.Directory, req.URL.Path)

// check whether a file exists or is a directory at the given path
fi, err := os.Stat(path)

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.

Copilot Autofix AI 12 days ago

To fix the problem, we need to ensure that the user-provided path is validated and sanitized before it is used to construct a file path. Specifically, we should:

  1. Resolve the user-provided path relative to a safe base directory.
  2. Ensure that the resolved path is still within the intended directory to prevent directory traversal attacks.

We will modify the ServeHTTP function to include these checks.

Suggested changeset 1
pkg/web/routerweb/router.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/pkg/web/routerweb/router.go b/pkg/web/routerweb/router.go
--- a/pkg/web/routerweb/router.go
+++ b/pkg/web/routerweb/router.go
@@ -76,7 +76,11 @@
 func (web *router) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
-	// Join internally call path.Clean to prevent directory traversal
-	path := filepath.Join(web.config.Directory, req.URL.Path)
+	// Resolve the user-provided path relative to the base directory
+	absPath, err := filepath.Abs(filepath.Join(web.config.Directory, req.URL.Path))
+	if err != nil || !strings.HasPrefix(absPath, web.config.Directory) {
+		http.Error(rw, "Invalid file path", http.StatusBadRequest)
+		return
+	}
 
 	// check whether a file exists or is a directory at the given path
-	fi, err := os.Stat(path)
+	fi, err := os.Stat(absPath)
 	if os.IsNotExist(err) || fi.IsDir() {
EOF
@@ -76,7 +76,11 @@
func (web *router) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
// Join internally call path.Clean to prevent directory traversal
path := filepath.Join(web.config.Directory, req.URL.Path)
// Resolve the user-provided path relative to the base directory
absPath, err := filepath.Abs(filepath.Join(web.config.Directory, req.URL.Path))
if err != nil || !strings.HasPrefix(absPath, web.config.Directory) {
http.Error(rw, "Invalid file path", http.StatusBadRequest)
return
}

// check whether a file exists or is a directory at the given path
fi, err := os.Stat(path)
fi, err := os.Stat(absPath)
if os.IsNotExist(err) || fi.IsDir() {
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
grandwizard28 added a commit that referenced this pull request Jan 20, 2025
### Summary

feat(.): initialize all factories

#### Related Issues / PR's

Removed all redundant commits of #6843
Closes #6782
amlannandy pushed a commit that referenced this pull request Jan 21, 2025
### Summary

feat(.): initialize all factories

#### Related Issues / PR's

Removed all redundant commits of #6843
Closes #6782
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants