@@ -32,6 +32,7 @@ const (
32
32
CustomLogKey = "custom_log"
33
33
AILogKey = "ai_log"
34
34
TraceSpanTagPrefix = "trace_span_tag."
35
+ PluginIDKey = "_plugin_id_"
35
36
)
36
37
37
38
type HttpContext interface {
@@ -255,7 +256,7 @@ func parseEmptyPluginConfig[PluginConfig any](gjson.Result, *PluginConfig, Log)
255
256
}
256
257
257
258
func NewCommonVmCtx [PluginConfig any ](pluginName string , options ... CtxOption [PluginConfig ]) * CommonVmCtx [PluginConfig ] {
258
- logger := & DefaultLog {pluginName }
259
+ logger := & DefaultLog {pluginName , "nil" }
259
260
opts := append ([]CtxOption [PluginConfig ]{WithLogger [PluginConfig ](logger )}, options ... )
260
261
return NewCommonVmCtxWithOptions (pluginName , opts ... )
261
262
}
@@ -314,7 +315,10 @@ func (ctx *CommonPluginCtx[PluginConfig]) OnPluginStart(int) types.OnPluginStart
314
315
}
315
316
jsonData = gjson .ParseBytes (data )
316
317
}
317
-
318
+ pluginID := jsonData .Get (PluginIDKey ).String ()
319
+ if pluginID != "" {
320
+ ctx .vm .log .resetID (pluginID )
321
+ }
318
322
var parseOverrideConfig func (gjson.Result , PluginConfig , * PluginConfig ) error
319
323
if ctx .vm .parseRuleConfig != nil {
320
324
parseOverrideConfig = func (js gjson.Result , global PluginConfig , cfg * PluginConfig ) error {
@@ -329,15 +333,18 @@ func (ctx *CommonPluginCtx[PluginConfig]) OnPluginStart(int) types.OnPluginStart
329
333
)
330
334
if err != nil {
331
335
ctx .vm .log .Warnf ("parse rule config failed: %v" , err )
336
+ ctx .vm .log .Error ("plugin start failed" )
332
337
return types .OnPluginStartStatusFailed
333
338
}
334
339
if globalOnTickFuncs != nil {
335
340
ctx .onTickFuncs = globalOnTickFuncs
336
341
if err := proxywasm .SetTickPeriodMilliSeconds (100 ); err != nil {
337
342
ctx .vm .log .Error ("SetTickPeriodMilliSeconds failed, onTick functions will not take effect." )
343
+ ctx .vm .log .Error ("plugin start failed" )
338
344
return types .OnPluginStartStatusFailed
339
345
}
340
346
}
347
+ ctx .vm .log .Error ("plugin start successfully" )
341
348
return types .OnPluginStartStatusOK
342
349
}
343
350
0 commit comments