A high-performance timeline tracing library for Golang, used by TiDB

Minitrace-Go

Actions Status LICENSE

A high-performance, ergonomic timeline tracing library for Golang.

Basic Usage

package main

import (
    "context"
    "fmt"
    "strconv"

    "github.com/tikv/minitrace-go"
)

func tracedFunc(ctx context.Context, event string) {
    span := minitrace.StartSpan(ctx, event)
    // code snippet...
    span.Finish()
}

func iterTracedFunc(ctx context.Context) {
    // extend tracing context from parent context
    ctx, span := minitrace.StartSpanWithContext(ctx, "1")

    span.AddProperty("k2", "v2")

    for i := 2; i < 10; i++ {
        tracedFunc(ctx, strconv.Itoa(i))
    }
    
    span.Finish()
}

func main() {
    ctx := context.Background()

    // enable tracing
    ctx, root := minitrace.StartRootSpan(ctx, "root", 0, nil)

    root.AddProperty("k1", "v1")

    // pass the context to traced functions
    iterTracedFunc(ctx)

    // collect tracing results into `spans`
    spans, _ := root.Collect()

    // do something with `spans`
    fmt.Printf("%+v", spans)
}
Similar Resources

A neural network library built in Go

go-mind A neural network library built in Go. Usage import "github.com/stevenmiller888/go-mind" m := mind.New(0.7, 10000, 3, "sigmoid") m.Learn([][]

Aug 27, 2022

Gorgonia is a library that helps facilitate machine learning in Go.

Gorgonia is a library that helps facilitate machine learning in Go.

Gorgonia is a library that helps facilitate machine learning in Go. Write and evaluate mathematical equations involving multidimensional arrays easily

Dec 27, 2022

A Go library implementing an FST (finite state transducer)

A Go library implementing an FST (finite state transducer)

vellum A Go library implementing an FST (finite state transducer) capable of: mapping between keys ([]byte) and a value (uint64) enumerating keys in l

Jan 8, 2023

Library for multi-armed bandit selection strategies, including efficient deterministic implementations of Thompson sampling and epsilon-greedy.

Library for multi-armed bandit selection strategies, including efficient deterministic implementations of Thompson sampling and epsilon-greedy.

Mab Multi-Armed Bandits Go Library Description Installation Usage Creating a bandit and selecting arms Numerical integration with numint Documentation

Jan 2, 2023

Bigmachine is a library for self-managing serverless computing in Go

Bigmachine Bigmachine is a toolkit for building self-managing serverless applications in Go. Bigmachine provides an API that lets a driver process for

Nov 15, 2022

go-paddle is a Go client library for accessing the Paddle API.

go-paddle go-paddle is a Go client library for accessing the Paddle API. Installation go get github.com/Fakerr/go-paddle Alternatively the same can be

Aug 22, 2022

Self-contained Machine Learning and Natural Language Processing library in Go

Self-contained Machine Learning and Natural Language Processing library in Go

Self-contained Machine Learning and Natural Language Processing library in Go

Jan 8, 2023

Go-hubspot - An auto-generated go client library of all of Hubspot's API

go-hubspot This is an auto-generated go client library of all of Hubspot's API (

Jan 22, 2022

Bcfm-study-case - A simple http server using the Echo library in Go language

Bcfm-study-case - A simple http server using the Echo library in Go language

Task 1 Hakkında Burada Go dilinde Echo kütüphanesini kullanarak basit bir http s

Feb 2, 2022
Comments
  • Fixed document issue and add more detail of span result for preview

    Fixed document issue and add more detail of span result for preview

    1. Remove uesless dependency github.com/silentred/gid
    2. Fixed error of lost traceID in document
    3. Add span content in JSON format for preview result before use
  • 关于时间精度

    关于时间精度

    Hello,

    我有一个关于时间精度的问题想请教。

    看了这篇文章 https://www.jianshu.com/p/d57b12d18c98

    Coarse Time 若仅从高性能的角度出发来寻找计时方案,可使用 Coarse Time,它牺牲了一定的精度换取高性能。在 Linux 环境下,以 CLOCK_MONOTONIC_COARSE 作为时间源参数,通过 clock_gettime 系统调用可获取 Coarse Time。Rust 社区也提供了库 coarsetime 获取 Coarse Time: coarsetime::Instant::now() Coarse Time 性能很高,在测试环境下完成两次调用仅需要 10ns。它的精度取决于 Linux 的 jiffies 配置,默认精度为 4ms。

    代码中

    // Standard library's `time.Now()` will invoke two syscalls in Linux. One is `CLOCK_REALTIME` and
    // another is `CLOCK_MONOTONIC`. In our case, we'd like to separate these two calls to measure
    // time for performance purpose.
    // `nanotime()` is identical to Linux's `clock_gettime(CLOCK_MONOTONIC, &ts)`
    func monotimeNs() uint64 {
    	return uint64(nanotime())
    }
    

    monotimeNs方法就是根据CLOCK_MONOTONIC_COARSE时间源吗? 那么是否有默认精度4ms的问题?

    第二个问题是: 本库的实现原理好像和 https://github.com/tikv/minitrace-rust 不是一样的, 对吗?

A High-level Machine Learning Library for Go
A High-level Machine Learning Library for Go

Overview Goro is a high-level machine learning library for Go built on Gorgonia. It aims to have the same feel as Keras. Usage import ( . "github.

Nov 20, 2022
A curated list of Awesome Go performance libraries and tools

Awesome Go performance Collection of the Awesome™ Go libraries, tools, project around performance. Contents Algorithm Assembly Benchmarks Compiling Co

Jan 3, 2023
A quick tour (or reminder) of Go performance tools

Basics of benchmarking, profiling and tracing with Go Introduction This documentation gives an overview of possibilities offered by go tooling to meas

Dec 29, 2022
A highly flexible blockchain architecture with great transaction performance.
A highly flexible blockchain architecture with great transaction performance.

XuperChain 中文说明 What is XuperChain XuperChain, the first open source project of XuperChain Lab, introduces a underlying solution to build the super al

Jan 2, 2023
An iterative algorithm to generate high-quality triangulated images.
An iterative algorithm to generate high-quality triangulated images.

An iterative algorithm to generate high quality triangulated images. Introduction Triangula uses a modified genetic algorithm to triangulate images. I

Dec 29, 2022
Genetic Algorithms library written in Go / golang

Description Genetic Algorithms for Go/Golang Install $ go install git://github.com/thoj/go-galib.git Compiling examples: $ git clone git://github.com

Sep 27, 2022
Go (Golang) encrypted deep learning library; Fully homomorphic encryption over neural network graphs

DC DarkLantern A lantern is a portable case that protects light, A dark lantern is one who's light can be hidden at will. DC DarkLantern is a golang i

Oct 31, 2022
Gorgonia is a library that helps facilitate machine learning in Go.
Gorgonia is a library that helps facilitate machine learning in Go.

Gorgonia is a library that helps facilitate machine learning in Go. Write and evaluate mathematical equations involving multidimensional arrays easily

Dec 30, 2022
Go package for OCR (Optical Character Recognition), by using Tesseract C++ library

gosseract OCR Golang OCR package, by using Tesseract C++ library. OCR Server Do you just want OCR server, or see the working example of this package?

Jan 3, 2023
onnx-go gives the ability to import a pre-trained neural network within Go without being linked to a framework or library.
onnx-go gives the ability to import a pre-trained neural network within Go without being linked to a framework or library.

This is a Go Interface to Open Neural Network Exchange (ONNX). Overview onnx-go contains primitives to decode a onnx binary model into a computation b

Dec 24, 2022