Skip to content

Commit

Permalink
chore: variable naming
Browse files Browse the repository at this point in the history
  • Loading branch information
wikiwong committed Sep 26, 2023
1 parent 1154d26 commit d252948
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 28 deletions.
4 changes: 3 additions & 1 deletion demo-iota/js/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ app.post('/run', bodyParser.raw({ limit: '256mb', type: () => true }), async (re
const stdinPath = `${os.tmpdir}/stdin_${Math.ceil(Math.random() * 10000)}.txt`
fs.writeFileSync(stdinPath, req.body)
const stdin = fs.openSync(stdinPath)

const wasi = new WASI({
version: 'preview1',
args: [req.query['name']],
Expand All @@ -62,6 +62,8 @@ app.post('/run', bodyParser.raw({ limit: '256mb', type: () => true }), async (re
const bytes = fs.readFileSync(`${os.tmpdir()}/${req.query['name']}.wasm`)
const traceContext = await adapter.start(bytes)
const module = new WebAssembly.Module(bytes)
console.log(bytes)
// console.log(module)
const instance = await WebAssembly.instantiate(module, {
...wasi.getImportObject(),
...traceContext.getImportObject(),
Expand Down
18 changes: 9 additions & 9 deletions go/adapter/lightstep/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ func NewLightstepAdapter(config *LightstepConfig) *LightstepAdapter {
return adapter
}

func (h *LightstepAdapter) Start(ctx context.Context) {
h.AdapterBase.Start(ctx, h)
func (l *LightstepAdapter) Start(ctx context.Context) {
l.AdapterBase.Start(ctx, l)
}

func (h *LightstepAdapter) HandleTraceEvent(te observe.TraceEvent) {
h.AdapterBase.HandleTraceEvent(te)
func (l *LightstepAdapter) HandleTraceEvent(te observe.TraceEvent) {
l.AdapterBase.HandleTraceEvent(te)
}

func (h *LightstepAdapter) Flush(evts []observe.TraceEvent) error {
func (l *LightstepAdapter) Flush(evts []observe.TraceEvent) error {
for _, te := range evts {
traceId := te.TelemetryId.ToHex16()

var allSpans []*trace.Span
for _, e := range te.Events {
switch event := e.(type) {
case observe.CallEvent: // TODO: consider renaming to FunctionCall for consistency across Rust & JS
spans := h.MakeOtelCallSpans(event, nil, traceId)
spans := l.MakeOtelCallSpans(event, nil, traceId)
if len(spans) > 0 {
allSpans = append(allSpans, spans...)
}
Expand All @@ -69,7 +69,7 @@ func (h *LightstepAdapter) Flush(evts []observe.TraceEvent) error {
return nil
}

t := observe.NewOtelTrace(traceId, h.Config.ServiceName, allSpans)
t := observe.NewOtelTrace(traceId, l.Config.ServiceName, allSpans)
if te.AdapterMeta != nil {
meta, ok := te.AdapterMeta.(map[string]string)
if ok {
Expand All @@ -84,7 +84,7 @@ func (h *LightstepAdapter) Flush(evts []observe.TraceEvent) error {
return nil
}

url, err := url.JoinPath(h.Config.Host, "traces", "otlp", "v0.9")
url, err := url.JoinPath(l.Config.Host, "traces", "otlp", "v0.9")
if err != nil {
log.Println("failed to create lightstep endpoint url:", err)
return nil
Expand All @@ -100,7 +100,7 @@ func (h *LightstepAdapter) Flush(evts []observe.TraceEvent) error {

req.Header = http.Header{
"content-type": {"application/x-protobuf"},
"lightstep-access-token": {h.Config.ApiKey},
"lightstep-access-token": {l.Config.ApiKey},
}

resp, err := client.Do(req)
Expand Down
30 changes: 15 additions & 15 deletions go/adapter/opentelemetry/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,37 +83,37 @@ func NewOTelAdapter(config *OTelConfig) *OTelAdapter {
return adapter
}

func (h *OTelAdapter) Start(ctx context.Context) {
h.AdapterBase.Start(ctx, h)
h.Config.client.Start(ctx)
func (o *OTelAdapter) Start(ctx context.Context) {
o.AdapterBase.Start(ctx, o)
o.Config.client.Start(ctx)
}

func (h *OTelAdapter) StopWithContext(ctx context.Context, wait bool) error {
h.AdapterBase.Stop(wait)
return h.Config.client.Stop(ctx)
func (o *OTelAdapter) StopWithContext(ctx context.Context, wait bool) error {
o.AdapterBase.Stop(wait)
return o.Config.client.Stop(ctx)
}

func (h *OTelAdapter) Stop(wait bool) {
h.AdapterBase.Stop(wait)
err := h.Config.client.Stop(context.Background())
func (o *OTelAdapter) Stop(wait bool) {
o.AdapterBase.Stop(wait)
err := o.Config.client.Stop(context.Background())
if err != nil {
log.Println("failed to stop otlptrace.Client from wasm sdk")
}
}

func (h *OTelAdapter) HandleTraceEvent(te observe.TraceEvent) {
h.AdapterBase.HandleTraceEvent(te)
func (o *OTelAdapter) HandleTraceEvent(te observe.TraceEvent) {
o.AdapterBase.HandleTraceEvent(te)
}

func (h *OTelAdapter) Flush(evts []observe.TraceEvent) error {
func (o *OTelAdapter) Flush(evts []observe.TraceEvent) error {
for _, te := range evts {
traceId := te.TelemetryId.ToHex16()

var allSpans []*trace.Span
for _, e := range te.Events {
switch event := e.(type) {
case observe.CallEvent: // TODO: consider renaming to FunctionCall for consistency across Rust & JS
spans := h.MakeOtelCallSpans(event, nil, traceId)
spans := o.MakeOtelCallSpans(event, nil, traceId)
if len(spans) > 0 {
allSpans = append(allSpans, spans...)
}
Expand All @@ -128,7 +128,7 @@ func (h *OTelAdapter) Flush(evts []observe.TraceEvent) error {
return nil
}

t := observe.NewOtelTrace(traceId, h.Config.ServiceName, allSpans)
t := observe.NewOtelTrace(traceId, o.Config.ServiceName, allSpans)

if te.AdapterMeta != nil {
meta, ok := te.AdapterMeta.(map[string]string)
Expand All @@ -139,7 +139,7 @@ func (h *OTelAdapter) Flush(evts []observe.TraceEvent) error {
}
}

err := h.Config.client.UploadTraces(context.Background(), t.TracesData.ResourceSpans)
err := o.Config.client.UploadTraces(context.Background(), t.TracesData.ResourceSpans)
if err != nil {
log.Println("failed to upload wasm traces to otel endpoint", err)
}
Expand Down
4 changes: 2 additions & 2 deletions js/packages/observe-sdk-honeycomb/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion js/packages/observe-sdk-honeycomb/test/deno/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { HoneycombAdapter, HoneycombConfig } from "../../dist/esm/index.js";
import honeycomb from "npm:@dylibso/observe-sdk-honeycomb";
const {
HoneycombAdapter,
HoneycombConfig,
} = honeycomb;
import Context from "https://deno.land/std@0.192.0/wasi/snapshot_preview1.ts";
import { load } from "https://deno.land/std/dotenv/mod.ts";

Expand Down
6 changes: 6 additions & 0 deletions js/packages/observe-sdk-honeycomb/test/node/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions js/packages/observe-sdk-honeycomb/test/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@dylibso/observe-sdk-honeycomb": "^0.1.3",
"dotenv": "^16.3.1"
}
}

0 comments on commit d252948

Please sign in to comment.