Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,6 @@ jobs:
with:
go-version: 'stable'

- name: Setup Wasmtime (for Go unit tests)
uses: bytecodealliance/actions/wasmtime/setup@v1
with:
version: "40.0.1"

- name: Setup componentize-go
uses: bytecodealliance/componentize-go/.github/actions/setup-componentize-go@main
with:
version: 'v0.2.0'

- name: Setup Spin
uses: fermyon/actions/spin/setup@v1
with:
Expand Down
6 changes: 2 additions & 4 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ vet:
cargo vet --manifest-path rust/Cargo.toml

# Vet: Go SDK
cd go && GOOS=wasip1 GOARCH=wasm go vet ./logs/... ./metrics/... ./tracing/... ./types/...
cd go && go vet -unsafeptr=false -composites=false ./...

# Vet: TypeScript SDK
# This is handled in the lint step
Expand Down Expand Up @@ -54,9 +54,7 @@ test:
@npm --prefix ts test

# Test: Go SDK
@cd go \
&& GOOS=wasip1 GOARCH=wasm go test -ldflags=-checklinkname=0 -c -o logs_test.wasm ./logs \
&& wasmtime run logs_test.wasm
@cd go && go test ./...

# Test: Integration tests
# TODO: Until this issue is taken care of, these will continue to fail: https://github.com/calebschoepp/opentelemetry-wasi/issues/45
Expand Down
4 changes: 2 additions & 2 deletions go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ Whenever WIT files are changed/added to the `../wit` directory, the bindings in

### Prerequisites

- [**componentize-go**](https://github.com/bytecodealliance/componentize-go) - v0.2.0
- [**go**](https://go.dev/dl/) - v1.25+

### Run

```sh
componentize-go -w imports -d ../wit bindings -o internal --pkg-name github.com/calebschoepp/opentelemetry-wasi/internal --format
go tool componentize-go -w imports -d ../wit bindings -o internal --pkg-name github.com/calebschoepp/opentelemetry-wasi/internal --format
```
4 changes: 4 additions & 0 deletions go/componentize-go.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Use this world by default if none is specified:
worlds = [ "wasi:otel/imports@0.2.0-rc.2" ]
# Here's where to find the WIT files used by this SDK:
wit_paths = [ "../wit" ]
12 changes: 6 additions & 6 deletions go/examples/spin-basic/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.25.5

require (
github.com/calebschoepp/opentelemetry-wasi v0.0.0-00010101000000-000000000000
github.com/spinframework/spin-go-sdk/v3 v3.0.0-00010101000000-000000000000
github.com/spinframework/spin-go-sdk/v3 v3.0.0-20260407161511-f2bf8873711b
go.opentelemetry.io/otel v1.39.0
go.opentelemetry.io/otel/log v0.14.0
go.opentelemetry.io/otel/metric v1.39.0
Expand All @@ -14,19 +14,19 @@ require (
)

require (
github.com/bytecodealliance/wit-bindgen v0.0.0-00010101000000-000000000000 // indirect
github.com/apparentlymart/go-userdirs v0.0.0-20200915174352-b0c018a67c13 // indirect
github.com/bytecodealliance/componentize-go v0.3.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gofrs/flock v0.13.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/julienschmidt/httprouter v1.3.0 // indirect
go.bytecodealliance.org/pkg v0.2.1 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/otel/trace v1.39.0 // indirect
golang.org/x/sys v0.39.0 // indirect
)

replace github.com/spinframework/spin-go-sdk/v3 => github.com/asteurer/spin-go-sdk/v3 v3.0.0-20260114220401-5aec7236bb2c

replace github.com/calebschoepp/opentelemetry-wasi => ../../

replace github.com/bytecodealliance/wit-bindgen => github.com/bytecodealliance/wit-bindgen/crates/go/src/package v0.51.0
tool github.com/bytecodealliance/componentize-go
18 changes: 12 additions & 6 deletions go/examples/spin-basic/go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/asteurer/spin-go-sdk/v3 v3.0.0-20260114220401-5aec7236bb2c h1:wxLJbYhfEGH82IdZddbdN3ZU2CpleNQk+k8FsAMxnHE=
github.com/asteurer/spin-go-sdk/v3 v3.0.0-20260114220401-5aec7236bb2c/go.mod h1:omWk7AOSaQgL07B2iu5kxYe21a7xOuGX/jPQKl+C6OI=
github.com/bytecodealliance/wit-bindgen/crates/go/src/package v0.51.0 h1:fbwpkAmU6eZnDQpBHrdQwPXi5atE0KSfjU8zwFkClnw=
github.com/bytecodealliance/wit-bindgen/crates/go/src/package v0.51.0/go.mod h1:MUXxhOBN0hAtqHjc9/9XAEiXcGhcwYL6PeDXkKwVZN0=
github.com/apparentlymart/go-userdirs v0.0.0-20200915174352-b0c018a67c13 h1:JtuelWqyixKApmXm3qghhZ7O96P6NKpyrlSIe8Rwnhw=
github.com/apparentlymart/go-userdirs v0.0.0-20200915174352-b0c018a67c13/go.mod h1:7kfpUbyCdGJ9fDRCp3fopPQi5+cKNHgTE4ZuNrO71Cw=
github.com/bytecodealliance/componentize-go v0.3.1 h1:uXfSgjvIhYun74gcxnOxAO3pUKQ4SWmStxlROZLUoRA=
github.com/bytecodealliance/componentize-go v0.3.1/go.mod h1:w1QFtPLGI9o38epvMOPyCKbMc7q7GJ7yZhIvhGTpzA0=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand All @@ -11,16 +11,21 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/gofrs/flock v0.13.0 h1:95JolYOvGMqeH31+FC7D2+uULf6mG61mEZ/A8dRYMzw=
github.com/gofrs/flock v0.13.0/go.mod h1:jxeyy9R1auM5S6JYDBhDt+E2TCo7DkratH4Pgi8P+Z0=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/spinframework/spin-go-sdk/v3 v3.0.0-20260407161511-f2bf8873711b h1:ssbg3S4ereZoFknFC086rEJ+Q9fED5NLcWfku4elbM0=
github.com/spinframework/spin-go-sdk/v3 v3.0.0-20260407161511-f2bf8873711b/go.mod h1:8YZLMpWrO1iBXhfnHKA/GgDTcjcE0WdN5CUqvV2LatA=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
go.bytecodealliance.org/pkg v0.2.1 h1:TdRagooIcCW3UmlKqVO4cDR3GNDyfDnbiBzGI6TOvyg=
go.bytecodealliance.org/pkg v0.2.1/go.mod h1:OjA+V8g3uUFixeCKFfamm6sYhTJdg8fvwEdJ2GO0GSk=
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48=
Expand All @@ -39,6 +44,7 @@ go.opentelemetry.io/otel/trace v1.39.0 h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6
go.opentelemetry.io/otel/trace v1.39.0/go.mod h1:88w4/PnZSazkGzz/w84VHpQafiU4EtqqlVdxWy+rNOA=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
12 changes: 9 additions & 3 deletions go/examples/spin-basic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,26 @@ import (
metricApi "go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/sdk/log"
"go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/resource"
"go.opentelemetry.io/otel/sdk/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.37.0"
)

func init() {
spinhttp.Handle(func(w http.ResponseWriter, r *http.Request) {
ctx := context.Background()

res, _ := resource.New(ctx,
resource.WithAttributes(semconv.ServiceName("spin")),
)

/*
### METRICS ###
*/
exporter := wasiMetrics.NewWasiMetricExporter()
defer exporter.Export(ctx) // Export metrics to the host

meterProvider := metric.NewMeterProvider(metric.WithReader(exporter))
meterProvider := metric.NewMeterProvider(metric.WithReader(exporter), metric.WithResource(res))
meter := meterProvider.Meter("spin-metrics")

attrs := metricApi.WithAttributes(
Expand Down Expand Up @@ -70,7 +76,7 @@ func init() {
/*
### TRACING ###
*/
tracerProvider := trace.NewTracerProvider(trace.WithSpanProcessor(wasiTracing.NewWasiSpanProcessor()))
tracerProvider := trace.NewTracerProvider(trace.WithSpanProcessor(wasiTracing.NewWasiSpanProcessor()), trace.WithResource(res))
propagator := wasiTracing.NewTraceContextPropagator()
hostCtx := propagator.Extract(ctx)
otel.SetTracerProvider(tracerProvider)
Expand Down Expand Up @@ -105,7 +111,7 @@ func init() {
/*
### LOGS ###
*/
loggerProvider := log.NewLoggerProvider(log.WithProcessor(wasiLogs.NewWasiLogProcessor()))
loggerProvider := log.NewLoggerProvider(log.WithProcessor(wasiLogs.NewWasiLogProcessor()), log.WithResource(res))
logger := loggerProvider.Logger("spin-logs")
logRecord := logApi.Record{}
logRecord.SetBody(logApi.StringValue("Hello from Go!"))
Expand Down
2 changes: 1 addition & 1 deletion go/examples/spin-basic/spin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ component = "go-spin-basic"
source = "main.wasm"
key_value_stores = ["default"]
[component.go-spin-basic.build]
command = "componentize-go -w http-trigger componentize"
command = "go tool componentize-go build"
watch = ["**/*.go", "go.mod"]
49 changes: 0 additions & 49 deletions go/examples/spin-basic/wit/deps/spin-key-value-2.0.0/package.wit

This file was deleted.

20 changes: 0 additions & 20 deletions go/examples/spin-basic/wit/deps/wasi-cli-0.2.0/package.wit

This file was deleted.

29 changes: 0 additions & 29 deletions go/examples/spin-basic/wit/deps/wasi-clocks-0.2.0/package.wit

This file was deleted.

Loading
Loading