0

When using a WasmPlugin with Istio 1.12 and proxy-wasm-go-sdk, it seems that stdlib-functions like time.Now() are not available, and I have not found an alternative. However, there is GetProperty() function, which allows to access some request properties like request.time.

So I ended up with something like

requestStart, err := proxywasm.GetProperty([]string{"request", "time"})

proxywasm.LogInfof("len %v", len(requestStart))
requestStartTs := binary.LittleEndian.Uint64(requestStart)
proxywasm.LogInfof("request.start %v", requestStartTs)

It prints

2022-02-15T17:48:18.806485Z info    envoy wasm  wasm log redacted: len 8
2022-02-15T17:48:18.806516Z info    envoy wasm  wasm log redacted: request.start 1644947298806002000

Now this seems to be a Unix timestamp with that given time, but I am not at all sure if I have got this right.

Is there maybe a less low-level method to get a current timestamp?

user140547
  • 7,750
  • 3
  • 28
  • 80

1 Answers1

1

Time library should be available. Did you import it in your go file ? Example : https://github.com/tetratelabs/proxy-wasm-go-sdk/blob/main/examples/helloworld/main.go

Peter Claes
  • 285
  • 3
  • 9
  • Ok so it seems that using exactly `time.Now().UnixNano()` does work, but only `time.Now()` does not. got some error like in https://github.com/proxy-wasm/proxy-wasm-cpp-host/issues/199 it seems to cause timezone stuff to be required.. – user140547 Feb 16 '22 at 18:29