Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,20 @@ jobs:
matrix:
library:
# Exclude upstash-redis-js for now because takes ~15 min. To re-enable when someone needs it.
[fetch, firestore, grpc, http, ioredis, mysql, mysql2, nextjs, pg, postgres, prisma]
[
fetch,
firestore,
grpc,
http,
ioredis,
mysql,
mysql2,
nextjs,
pg,
postgres,
prisma,
mongodb,
]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Tusk Drift currently supports the following packages and versions:
- **Firestore**: `@google-cloud/firestore@7.x-8.x`
- **Postgres**: `postgres@3.x`
- **MySQL**: `mysql2@3.x`, `mysql@2.x`
- **MongoDB**: `mongodb@5.x-7.x`
- **IORedis**: `ioredis@4.x-5.x`
- **Upstash Redis**: `@upstash/redis@1.x`
- **GraphQL**: `graphql@15.x-16.x`
Expand Down
6 changes: 6 additions & 0 deletions src/core/TuskDrift.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
NextjsInstrumentation,
PrismaInstrumentation,
MysqlInstrumentation,
MongodbInstrumentation,
} from "../instrumentation/libraries";
import { TdSpanExporter } from "./tracing/TdSpanExporter";
import { trace, Tracer, SpanKind, SpanStatusCode } from "@opentelemetry/api";
Expand Down Expand Up @@ -325,6 +326,11 @@ export class TuskDriftCore {
enabled: true,
mode: this.mode,
});

new MongodbInstrumentation({
enabled: true,
mode: this.mode,
});
}

private initializeTracing({ baseDirectory }: { baseDirectory: string }): void {
Expand Down
8 changes: 8 additions & 0 deletions src/instrumentation/libraries/date/Instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ export class DateInstrumentation extends TdInstrumentationBase {

return self._handleDateCall(args, isConstructorCall);
}
// Preserve the original constructor name so that libraries which validate
// types by checking constructor.name (e.g. Mongoose schema type validation)
// still see "Date" instead of "_TdDate". Without this, any Mongoose schema
// using { type: Date } throws:
// TypeError: Invalid schema configuration: `_TdDate` is not a valid type
// This only changes the name metadata — all instrumentation logic is unaffected.
Object.defineProperty(_TdDate, "name", { value: "Date" });

return _TdDate;
};
}
Expand Down
1 change: 1 addition & 0 deletions src/instrumentation/libraries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ export * from "./grpc";
export * from "./firestore";
export * from "./nextjs";
export * from "./prisma";
export * from "./mongodb";
Loading