Removed dynamic imports
This commit is contained in:
@@ -66,6 +66,17 @@ containerTest("should use both", async ({ prisma, redisOptions }) => {
|
||||
});
|
||||
```
|
||||
|
||||
## Code Style
|
||||
|
||||
### Imports
|
||||
|
||||
**Prefer static imports over dynamic imports.** Only use dynamic `import()` when:
|
||||
- Circular dependencies cannot be resolved otherwise
|
||||
- Code splitting is genuinely needed for performance
|
||||
- The module must be loaded conditionally at runtime
|
||||
|
||||
Dynamic imports add unnecessary overhead in hot paths and make code harder to analyze. If you find yourself using `await import()`, ask if a regular `import` statement would work instead.
|
||||
|
||||
## Changesets and Server Changes
|
||||
|
||||
When modifying any public package (`packages/*` or `integrations/*`), add a changeset:
|
||||
|
||||
@@ -40,6 +40,7 @@ import { waitForLlmPricingReady } from "./llmPricingRegistry.server";
|
||||
import { env } from "~/env.server";
|
||||
import { detectBadJsonStrings } from "~/utils/detectBadJsonStrings";
|
||||
import { singleton } from "~/utils/singleton";
|
||||
import { getClickhouseForOrganization, getEventRepositoryForOrganization } from "~/services/clickhouse/clickhouseFactory.server";
|
||||
|
||||
class OTLPExporter {
|
||||
private _tracer: Tracer;
|
||||
@@ -149,9 +150,6 @@ class OTLPExporter {
|
||||
async #getEventRepositoryForStoreAndOrg(store: string, orgId: string): Promise<IEventRepository> {
|
||||
// For ClickHouse stores with a specific org (not "default"), use org-specific repository
|
||||
if ((store === "clickhouse" || store === "clickhouse_v2") && orgId !== "default") {
|
||||
const { getEventRepositoryForOrganization } = await import(
|
||||
"~/services/clickhouse/clickhouseFactory.server"
|
||||
);
|
||||
return await getEventRepositoryForOrganization(orgId);
|
||||
}
|
||||
|
||||
@@ -1191,11 +1189,6 @@ export const otlpExporter = singleton("otlpExporter", initializeOTLPExporter);
|
||||
|
||||
async function initializeOTLPExporter() {
|
||||
// Metrics are written globally (not per-org), use standard clickhouse
|
||||
// We use a dummy org ID since metrics table is global
|
||||
const { getClickhouseForOrganization } = await import(
|
||||
"~/services/clickhouse/clickhouseFactory.server"
|
||||
);
|
||||
|
||||
// Use a sentinel org ID for global metrics writes
|
||||
// In practice, all orgs currently share the same metrics table/instance
|
||||
const metricsClickhouse = await getClickhouseForOrganization("METRICS_GLOBAL", "standard");
|
||||
|
||||
Reference in New Issue
Block a user