Skip to content

Instantly share code, notes, and snippets.

View codefromthecrypt's full-sized avatar

Adrian Cole codefromthecrypt

View GitHub Profile
@codefromthecrypt
codefromthecrypt / re-export.wat
Created June 2, 2023 00:05
work around for weird ABI that expect the host to export memory
(module $env
;; import and re-export logstr. the exported function has the same signature
;; and passes the parameters via local.get 0..n
(import "host" "logstr" (func $logstr (param i32)))
(func (export "logstr") (param i32)
(call $logstr (local.get 0)))
(memory (export "memory") 1)
)
karmem api;
struct ManagedFieldData table {
ApiVersion []char;
FieldsType []char;
Manager []char;
Operation []char;
@codefromthecrypt
codefromthecrypt / main.go
Last active February 5, 2023 12:57
wazero devops win
package main
import (
"context"
_ "embed"
"fmt"
"log"
"github.com/tetratelabs/wazero"
"github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1"
@codefromthecrypt
codefromthecrypt / table.cc
Last active November 27, 2022 06:25
emscripten code which uses a wasm function table
#include <stdlib.h>
/* define a dynamic function */
int (*dynamicInt)();
/* import a function from the host */
extern int hostInt();
/* assign it to the next table offset (0) */
int (*hostIntPtr)() = &hostInt;
From https://github.com/tetratelabs/wazero/runs/6473296164?check_suite_focus=true
BenchmarkAllocation/Call-16
wazero-compiler 14039.84 ns/op
wasmedge 264615.55 ns/op
BenchmarkFactorial/Call-16
wazero-compiler 1600.76 ns/op
wasmedge 14359.72 ns/op
BenchmarkAllocation/Compile-2 3293992 358.9 ns/op
BenchmarkAllocation/Instantiate-2 391 3081906 ns/op
@codefromthecrypt
codefromthecrypt / opentracing-zipkin.md
Last active October 27, 2021 01:44
My ramble on OpenTracing (with a side of Zipkin)

I've had many people ask me questions about OpenTracing, often in relation to OpenZipkin. I've seen assertions about how it is vendor neutral and is the lock-in cure. This post is not a sanctioned, polished or otherwise muted view, rather what I personally think about what it is and is not, and what it helps and does not help with. Scroll to the very end if this is too long. Feel free to add a comment if I made any factual mistakes or you just want to add a comment.

So, what is OpenTracing?

OpenTracing is documentation and library interfaces for distributed tracing instrumentation. To be "OpenTracing" requires bundling its interfaces in your work, so that others can use it to time distributed operations with the same library.

So, who is it for?

OpenTracing interfaces are targeted to authors of instrumentation libraries, and those who want to collaborate with traces created by them. Ex something started a trace somewhere and I add a notable event to that trace. Structure logging was recently added to O

@codefromthecrypt
codefromthecrypt / elasticsearch-secondary.md
Last active December 24, 2020 23:55
secondary zipkin template for elasticsearch 7

Zipkin by default does special indexing to deal with limitations around names with dots and to reduce storage costs. Normal elasticsearch queries for tags won't work because of this. However, you can always add a second indexing template with the tags you feel you need to work with other tools like kibana. This shows you how to do that.

Before asking any questions please run exactly as mentioned here. These instructions are Elasticsearch v7 specific. If you do something different like use Elasticsearch 6, or do things out of order, it might not work. In other words, use our docker-compose stuff so to eliminate variance and understand how things work before changing variables.

$ git clone https://github.com/openzipkin/zipkin
$ cd zipkin/docker/examples/

Edit docker-compose-elasticsearch.yml and uncomment out po

@codefromthecrypt
codefromthecrypt / my-misunderstandings.md
Last active October 31, 2020 12:39
My take on: Misunderstanding "Open Tracing" for the Enterprise

This is a reaction post to Misunderstanding "Open Tracing" for the Enterprise by @jkowall

This is opinions with citations (imagine that!). This is not wikipedia. sorry. I didn't run this by anyone, Jonah or otherwise. I do not represent OpenTracing or OpenCensus (or my employer or whatever you might think) in this view. I will give critical thoughts on both from a technical view as people complained to me mostly about lack of details. I do have "a dog in the race" but it isn't what you might think. Yes, I'm the primary maintainer of Zipkin, but my goal is not to disparage anything rather to keep the community healthy with options that exist and free from the suffering caused in my opinion by complete lack of technical view on what things do. Particularly, this is dangerous in interop, and I'll get to that.

I have experience with both tools. Though I left within months, I was implicated in the beginning of OpenTracing. I still mainta

@codefromthecrypt
codefromthecrypt / Snark.java
Created July 9, 2020 02:12
snarking on otel's tracer v0.6
import io.opentelemetry.common.AttributeValue;
import io.opentelemetry.exporters.logging.LoggingSpanExporter;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
import io.opentelemetry.trace.Span;
import io.opentelemetry.trace.Tracer;
// This shows how you can add attributes to a span and print it to console using Java's logger.
//
// $ java -cp snark.jar Snark
2020-03-25 09:14:06.293 INFO 22055 --- [-worker-nio-2-1] c.l.a.c.l.LoggingClient : Request: {startTime=2020-03-25T01:14:06.287Z(1585098846287794), length=0B, duration=483µs(483304ns), scheme=none+h1c, headers=[:method=GET, :path=/, :authority=localhost:9200, :scheme=http, accept-encoding=gzip,deflate, user-agent=armeria/0.97.0]}
2020-03-25 09:14:06.344 INFO 22055 --- [-worker-nio-2-1] c.l.a.c.l.LoggingClient : Response: {startTime=2020-03-25T01:14:06.315Z(1585098846315931), length=333B, duration=28087µs(28087280ns), headers=[:status=200, content-type=application/json; charset=UTF-8, content-encoding=gzip, content-length=333], content={
"name" : "MacBook-Pro-8.local",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "t12hyJk4RwCyYK7Av7oz3Q",
"version" : {
"number" : "7.6.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "aa751e09be0a5072e8570670309b1f12348f023b",