@@ -39,19 +39,27 @@ func NewStandardDirectQueryExecutor(generator *wasp.Generator) (*DirectQueryExec
3939// NewDirectQueryExecutor creates a new DirectQueryExecutor with the specified generator and query functions.
4040// It initializes the executor with a kind name and prepares a map for query results, enabling efficient query execution.
4141func NewDirectQueryExecutor (generator * wasp.Generator , queries map [string ]DirectQueryFn ) (* DirectQueryExecutor , error ) {
42- g := & DirectQueryExecutor {
42+ ex := & DirectQueryExecutor {
4343 KindName : string (StandardQueryExecutor_Direct ),
4444 Generator : generator ,
4545 Queries : queries ,
4646 QueryResults : make (map [string ]interface {}),
4747 }
4848
49- return g , nil
49+ L .Debug ().
50+ Str ("Generator" , ex .GeneratorName ()).
51+ Int ("Queries" , len (queries )).
52+ Msg ("Creating new Direct query executor" )
53+
54+ return ex , nil
5055}
5156
5257// GeneratorName returns the name of the generator associated with the query executor.
5358// It is useful for identifying and categorizing results based on their generator type.
5459func (g * DirectQueryExecutor ) GeneratorName () string {
60+ if g .Generator == nil {
61+ return ""
62+ }
5563 return g .Generator .Cfg .GenName
5664}
5765
@@ -70,6 +78,10 @@ func (l *DirectQueryExecutor) Kind() string {
7078// IsComparable checks if the given QueryExecutor is of the same type and has comparable configurations.
7179// It returns an error if the types do not match or if the configurations are not comparable.
7280func (g * DirectQueryExecutor ) IsComparable (otherQueryExecutor QueryExecutor ) error {
81+ L .Debug ().
82+ Str ("Expected kind" , g .KindName ).
83+ Msg ("Checking if query executors are comparable" )
84+
7385 otherType := reflect .TypeOf (otherQueryExecutor )
7486
7587 if otherType != reflect .TypeOf (g ) {
@@ -82,7 +94,16 @@ func (g *DirectQueryExecutor) IsComparable(otherQueryExecutor QueryExecutor) err
8294 return errors .New ("generators are not comparable" )
8395 }
8496
85- return g .compareQueries (otherGeneratorQueryExecutor .Queries )
97+ queryErr := g .compareQueries (otherGeneratorQueryExecutor .Queries )
98+ if queryErr != nil {
99+ return queryErr
100+ }
101+
102+ L .Debug ().
103+ Str ("Kind" , g .KindName ).
104+ Msg ("Query executors are comparable" )
105+
106+ return nil
86107}
87108
88109func (l * DirectQueryExecutor ) compareQueries (other map [string ]DirectQueryFn ) error {
@@ -104,6 +125,9 @@ func (l *DirectQueryExecutor) compareQueries(other map[string]DirectQueryFn) err
104125// It ensures that a generator is set and at least one query is provided.
105126// Returns an error if validation fails, helping to prevent execution issues.
106127func (g * DirectQueryExecutor ) Validate () error {
128+ L .Debug ().
129+ Msg ("Validating Direct query executor" )
130+
107131 if g .Generator == nil {
108132 return errors .New ("generator is not set" )
109133 }
@@ -112,18 +136,31 @@ func (g *DirectQueryExecutor) Validate() error {
112136 return errors .New ("at least one query is needed" )
113137 }
114138
139+ L .Debug ().
140+ Msg ("Direct query executor is valid" )
141+
115142 return nil
116143}
117144
118145// Execute runs the defined queries using the data from the generator.
119146// It validates the generator's data and aggregates responses before executing each query.
120147// This function is essential for processing and retrieving results from multiple queries concurrently.
121148func (g * DirectQueryExecutor ) Execute (_ context.Context ) error {
149+ L .Info ().
150+ Str ("Generator" , g .Generator .Cfg .GenName ).
151+ Int ("Queries" , len (g .Queries )).
152+ Msg ("Executing Direct queries" )
153+
122154 if g .Generator == nil {
123155 return errors .New ("generator is not set" )
124156 }
125157
126158 for queryName , queryFunction := range g .Queries {
159+ L .Debug ().
160+ Str ("Generator" , g .Generator .Cfg .GenName ).
161+ Str ("Query" , queryName ).
162+ Msg ("Executing Direct query" )
163+
127164 if g .Generator .GetData () == nil {
128165 return fmt .Errorf ("generator %s has no data" , g .Generator .Cfg .GenName )
129166 }
@@ -148,8 +185,18 @@ func (g *DirectQueryExecutor) Execute(_ context.Context) error {
148185 }
149186
150187 g .QueryResults [queryName ] = results
188+
189+ L .Debug ().
190+ Str ("Query" , queryName ).
191+ Float64 ("Result" , results ).
192+ Msg ("Direct query executed successfully" )
151193 }
152194
195+ L .Info ().
196+ Str ("Generator" , g .Generator .Cfg .GenName ).
197+ Int ("Queries" , len (g .Queries )).
198+ Msg ("Direct queries executed successfully" )
199+
153200 return nil
154201}
155202
@@ -160,6 +207,9 @@ func (g *DirectQueryExecutor) TimeRange(_, _ time.Time) {
160207}
161208
162209func (g * DirectQueryExecutor ) generateStandardQueries () (map [string ]DirectQueryFn , error ) {
210+ L .Debug ().
211+ Msg ("Generating standard Direct queries" )
212+
163213 standardQueries := make (map [string ]DirectQueryFn )
164214
165215 for _ , metric := range StandardLoadMetrics {
@@ -170,6 +220,10 @@ func (g *DirectQueryExecutor) generateStandardQueries() (map[string]DirectQueryF
170220 standardQueries [string (metric )] = query
171221 }
172222
223+ L .Debug ().
224+ Int ("Queries" , len (standardQueries )).
225+ Msg ("Standard queries Direct generated" )
226+
173227 return standardQueries , nil
174228}
175229
0 commit comments