Skip to content

Instantly share code, notes, and snippets.

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 / 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 / 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",
@codefromthecrypt
codefromthecrypt / obess-duration.md
Created August 19, 2019 03:45
Why I obsess about POST duration on Zipkin over other things

I've been very obsessed with the duration of Zipkin's POST endpoint, more than how many bytes of memory are used while processing a POST (I also obsess about that, but it doesn't keep me up at night). The duration of an endpoint that receives telemetry data, is the part that you can control of the response time.

Callers of Zipkin's POST endpoint are usually little http loops inside an application. Even when these are done neatly, with bounds etc, blocking those loops causes damage (lost spans), and also causes more overhead as these queues fill to capacity. Crazy, but true.. sometimes people literally POST to zipkin inline (ad-hoc or sometimes in php)! While we shouldn't optimize for this, it is crazy the amount of impact you can do.

For this reason, we need to succeed fast, and we also need to fail fast. We want these things to clear or fail quickly (ex in case of failure, the client can try another node, right?). This "fast" must apply at reasonable percentage of requests, because you don't want half your

@codefromthecrypt
codefromthecrypt / duped.md
Last active July 28, 2019 04:09
you've been had! a short list of ways people trick you into using their stuff

In the last 4 years I've noticed an increase in marketing things vs making them better. Here are some tricks I've learned about and am now more wary about. Purely my own opionions as an open source person.

My company made X (but they didn't)

We know it is often the case that ideas are not executed, or poorly executed. When people quit google to make a startup competing with their employer, it is tempting to claim they invented something invented at google. You can tell this when people clarify that they "really made" X. This hints they didn't make it. Regardless of who invented something, there is value in popularizing it (provided the "it" was a good idea). There's possibly most value in enduring it through support.

It can be strange that a big company would allow a small company to literally compete with them and misattribute simultaneously. First, check to see if it is california, if so, that's probably the answer :) Also, a big company maybe doesn't want the publicity of picking on a smaller one, or

@codefromthecrypt
codefromthecrypt / add-accesslog.sh
Last active September 11, 2019 09:08
Add custom armeria configuration to zipkin
#!/bin/sh
#
# NOTE: if you are reading this, probably you should upvote https://github.com/line/armeria/issues/1909
#
# get normal zipkin server
curl -sSL https://zipkin.io/quickstart.sh | bash -s
# Write pom.xml thats responsible for generating armeria-configurator.jar
cat << 'EOF' > pom.xml
@codefromthecrypt
codefromthecrypt / curl-tls1.3.md
Created June 17, 2019 07:55
Mystery of TLS 1.3 and curl on osx

I forget all the things I needed to install first. Some of these may be irrelevant.

brew install libtool pkg-config shtool grep gcc [email protected]
# from your checkout of curl
glibtoolize
aclocal
autoconf
autoheader
automake --force-missing --add-missing
@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

import brave.propagation.Propagation;
import brave.propagation.TraceContext;
import brave.propagation.TraceContextOrSamplingFlags;
import brave.propagation.TraceIdContext;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
/**
* <p>Tries to extract a trace ID and span ID using the supplied default implementation, such as