File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed
packages/instrumentation-mongoose/test Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -26,11 +26,14 @@ import {
2626import { SpanStatusCode } from '@opentelemetry/api' ;
2727import { SerializerPayload } from '../src' ;
2828import { DB_NAME , MONGO_HOST , MONGO_PORT } from './config' ;
29+ import User from './user' ;
2930
3031export const assertSpan = ( span : ReadableSpan ) => {
3132 expect ( span . status . code ) . toBe ( SpanStatusCode . UNSET ) ;
3233 expect ( span . attributes [ SEMATTRS_DB_SYSTEM ] ) . toEqual ( 'mongoose' ) ;
33- expect ( span . attributes [ SEMATTRS_DB_MONGODB_COLLECTION ] ) . toEqual ( 'users' ) ;
34+ expect ( span . attributes [ SEMATTRS_DB_MONGODB_COLLECTION ] ) . toEqual (
35+ User . collection . name
36+ ) ;
3437 expect ( span . attributes [ SEMATTRS_DB_NAME ] ) . toEqual ( DB_NAME ) ;
3538 expect ( span . attributes [ SEMATTRS_NET_PEER_NAME ] ) . toEqual ( MONGO_HOST ) ;
3639 expect ( span . attributes [ SEMATTRS_NET_PEER_PORT ] ) . toEqual ( MONGO_PORT ) ;
Original file line number Diff line number Diff line change 1515 */
1616import { Schema , Document } from 'mongoose' ;
1717import * as mongoose from 'mongoose' ;
18+ import * as crypto from 'node:crypto' ;
1819
1920export interface IUser extends Document {
2021 email : string ;
@@ -31,7 +32,7 @@ const UserSchema: Schema = new Schema({
3132} ) ;
3233
3334// Export the model and return your IUser interface
34- const User = mongoose . model < IUser > ( 'User' , UserSchema ) ;
35+ const User = mongoose . model < IUser > ( crypto . randomUUID ( ) + 'User' , UserSchema ) ;
3536export default User ;
3637
3738export const loadUsers = async ( ) => {
You can’t perform that action at this time.
0 commit comments