Skip to content

Commit

Permalink
fix: go sdk and api updates to latest (#161)
Browse files Browse the repository at this point in the history
* fix: add small default to channel buffer

* fix: update go observe-api names for compat

* chore: remove old print statements
  • Loading branch information
nilslice authored Feb 28, 2024
1 parent d78bf87 commit 6b4627e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
4 changes: 4 additions & 0 deletions go/trace_ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ func newTraceCtx(ctx context.Context, eventsChan chan TraceEvent, r wazero.Runti
return nil, err
}

if opts.ChannelBufferSize == 0 {
opts.ChannelBufferSize = 64 // set a reasonable minimum here so unset option doesn't block execution on an unbuffered channel
}

traceCtx := &TraceCtx{
adapter: eventsChan,
raw: make(chan RawEvent, opts.ChannelBufferSize),
Expand Down
32 changes: 15 additions & 17 deletions observe-api/go/observe_api.go
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
package observe_api

package main

import (
"fmt"
"reflect"
"strings"
"unsafe"
)

//go:wasmimport dylibso_observe metric
func metric(uint32, uint64, uint32)
//go:wasmimport dylibso:observe/api metric
func metric(uint32, uint32, uint32)

//go:wasmimport dylibso_observe log
func log(uint32, uint64, uint32)
//go:wasmimport dylibso:observe/api log
func log(uint32, uint32, uint32)

//go:wasmimport dylibso_observe span_tags
func span_tags(uint64, uint32)
//go:wasmimport dylibso:observe/api span-tags
func span_tags(uint32, uint32)

//go:wasmimport dylibso_observe span_enter
func span_enter(uint64, uint32)
//go:wasmimport dylibso:observe/api span-enter
func span_enter(uint32, uint32)

//go:wasmimport dylibso_observe span_exit
//go:wasmimport dylibso:observe/api span-exit
func span_exit()

func stringPointer(s *string) uint64 {
func stringPointer(s *string) uint32 {
header := (*reflect.StringHeader)(unsafe.Pointer(s))
return uint64(header.Data)
return uint32(header.Data)
}

type MetricFormat int
Expand Down Expand Up @@ -69,13 +66,14 @@ type span struct {
func NewSpan(name string) span {
ptr := stringPointer(&name)
span_enter(ptr, uint32(len(name)))
return span { name }
tags := []string{}
return span{name, tags}
}

func (s span) End() {
span_exit()
}

func (s span) AddTags(tags ...string) {
SpanTags(tags...)
}
SpanTags(tags)
}

0 comments on commit 6b4627e

Please sign in to comment.