Skip to content

Commit

Permalink
Add bindings for the pinned metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
aumetra committed Mar 18, 2024
1 parent e074d03 commit e0ce9af
Show file tree
Hide file tree
Showing 10 changed files with 199 additions and 146 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
2 changes: 2 additions & 0 deletions internal/api/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ struct AnalysisReport analyze_code(struct cache_t *cache,

struct Metrics get_metrics(struct cache_t *cache, struct UnmanagedVector *error_msg);

struct UnmanagedVector get_pinned_metrics(struct cache_t *cache, struct UnmanagedVector *error_msg);

/**
* frees a cache reference
*
Expand Down
16 changes: 16 additions & 0 deletions internal/api/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"golang.org/x/sys/unix"

"github.com/CosmWasm/wasmvm/v2/types"

Check failure on line 16 in internal/api/lib.go

View workflow job for this annotation

GitHub Actions / lint

File is not `goimports`-ed with -local github.com/CosmWasm/wasmvm (goimports)
"github.com/vmihailenco/msgpack/v5"
)

// Value types
Expand Down Expand Up @@ -188,6 +189,21 @@ func GetMetrics(cache Cache) (*types.Metrics, error) {
}, nil
}

func GetPinnedMetrics(cache Cache) (*types.PinnedMetrics, error) {
errmsg := uninitializedUnmanagedVector()
metrics, err := C.get_pinned_metrics(cache.ptr, &errmsg)
if err != nil {
return nil, errorWithMessage(err, errmsg)
}

var pinnedMetrics types.PinnedMetrics
if err := msgpack.Unmarshal(copyAndDestroyUnmanagedVector(metrics), &pinnedMetrics); err != nil {
return nil, err
}

return &pinnedMetrics, nil
}

func Instantiate(
cache Cache,
checksum []byte,
Expand Down
Loading

0 comments on commit e0ce9af

Please sign in to comment.