api7 / wasm-nginx-module

Run Wasm in OpenResty/Nginx
Apache License 2.0
183 stars 22 forks source link

bugfix: proxy_get_metric #152

Open Sn0rt opened 1 year ago

Sn0rt commented 1 year ago

error log

2023/08/15 23:29:17 [error] 10266#10266: failed to new instance: incompatible import type for `env::proxy_get_metric`

Caused by:
    function types incompatible: expected func of type `(i32, i32) -> (i32)`, found func of type `(i32, i64) -> (i32)`
2023/08/15 23:29:17 [error] 10266#10266: *1 lua entry thread aborted: runtime error: content_by_lua(nginx.conf:96):3: failed to load wasm plugin
stack traceback:
coroutine 0:
    [C]: in function 'assert'
    content_by_lua(nginx.conf:96):3: in main chunk, client: 127.0.0.1, server: localhost, request: "GET /t HTTP/1.1", host: "localhost"

the CI should pass

diff --git a/t/testdata/metric/main.go b/t/testdata/metric/main.go
index 9424169..55b6575 100644
--- a/t/testdata/metric/main.go
+++ b/t/testdata/metric/main.go
@@ -60,6 +60,7 @@ func (ctx *httpContext) OnHttpRequestHeaders(numHeaders int, endOfStream bool) t

        ctx.metrics.incrementCounter("test")
        ctx.metrics.recordMetricHistogram("test")
+       ctx.metrics.getMetric("test")

        return types.ActionContinue
 }