@@ -156,11 +156,11 @@ func (t *TraceCtx) init(ctx context.Context, r wazero.Runtime) error {
156
156
t .pushFunction (fn )
157
157
}
158
158
159
- metricFunc := func (ctx context.Context , m api.Module , f uint32 , ptr uint32 , len uint32 ) {
159
+ metricFunc := func (ctx context.Context , m api.Module , f uint32 , ptr uint32 , l uint32 ) {
160
160
format := MetricFormat (f )
161
- buffer , ok := m .Memory ().Read (ptr , len )
161
+ buffer , ok := m .Memory ().Read (ptr , l )
162
162
if ! ok {
163
- log .Printf ("metric: failed to read memory at offset %v with length %v\n " , ptr , len )
163
+ log .Printf ("metric: failed to read memory at offset %v with length %v\n " , ptr , l )
164
164
}
165
165
166
166
event := MetricEvent {
@@ -169,7 +169,13 @@ func (t *TraceCtx) init(ctx context.Context, r wazero.Runtime) error {
169
169
Message : string (buffer ),
170
170
}
171
171
172
- t .events = append (t .events , event )
172
+ fn , ok := t .popFunction ()
173
+ if ! ok {
174
+ t .events = append (t .events , event )
175
+ return
176
+ }
177
+ fn .within = append (fn .within , event )
178
+ t .pushFunction (fn )
173
179
}
174
180
175
181
oldMetricFunc := func (ctx context.Context , m api.Module , f uint32 , ptr uint64 , len uint32 ) {
@@ -201,7 +207,6 @@ func (t *TraceCtx) init(ctx context.Context, r wazero.Runtime) error {
201
207
}
202
208
fn .within = append (fn .within , event )
203
209
t .pushFunction (fn )
204
-
205
210
}
206
211
207
212
oldSpanTagsFunc := func (ctx context.Context , m api.Module , ptr uint64 , len uint32 ) {
@@ -226,7 +231,13 @@ func (t *TraceCtx) init(ctx context.Context, r wazero.Runtime) error {
226
231
Message : string (buffer ),
227
232
}
228
233
229
- t .events = append (t .events , event )
234
+ fn , ok := t .popFunction ()
235
+ if ! ok {
236
+ t .events = append (t .events , event )
237
+ return
238
+ }
239
+ fn .within = append (fn .within , event )
240
+ t .pushFunction (fn )
230
241
}
231
242
232
243
oldLogFunc := func (ctx context.Context , m api.Module , l uint32 , ptr uint64 , len uint32 ) {
0 commit comments