This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// general http handler | |
func httpHandler(w http.ResponseWriter, r *http.Request) { | |
// get tracer provider from otel package and inject ctx to tracer | |
tracer := otel.GetTracerProvider().Tracer("httpHandler") | |
ctx, span := tracer.Start(r.Context(), "httpHandler") | |
defer span.End() | |
// create http client with transport for inject trace signal to http header automatically | |
client := &http.Client{ | |
Transport: otelhttp.NewTransport(nil), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
// create server | |
mux := http.NewServeMux() | |
// wrapped handler for use propagation to extract trace signal from http header to request context | |
// it like a middleware | |
wrappedHandler := otelhttp.NewHandler(http.HandlerFunc(httpHandler), "http-server") | |
mux.Handle("/", wrappedHandler) | |
// start server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func init() { | |
var exporter sdktrace.SpanExporter | |
var err error | |
// use zipkin exporter | |
exporter, err = zipkin.New("http://zipkin:9411/api/v2/spans") | |
if err != nil { | |
panic(err) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.9" | |
services: | |
zookeeper: | |
image: 'bitnami/zookeeper:latest' | |
ports: | |
- '2181:2181' | |
environment: | |
- ALLOW_ANONYMOUS_LOGIN=yes | |
kafka: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "golang.org/x/tour/pic" | |
func Pic(dx, dy int) [][]uint8 { | |
slice := make([][]uint8, dx, dx) | |
// loop dx | |
for x := 0; x < dx; x++ { | |
slice[x] = make([]uint8, dy, dy) | |
// loop dy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
css: { extract: false }, | |
outputDir: 'lib' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
outDir: 'public', | |
babel: { | |
babelrc: false | |
}, | |
banner: true, | |
format: ['umd-min'], | |
css: true, | |
plugins: ['vue'] | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"strings" | |
) | |
func main() { | |
wc := NewWordCount() | |
wc = wc.AddWord("I am") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"strings" | |
) | |
func main() { | |
wc := NewWordCount() | |
wc = wc.AddWord("I am") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"strings" | |
"golang.org/x/tour/wc" | |
) | |
func WordCount(s string) map[string]int { | |
var strs = make(map[string]int) |