jtolio / gls Goto Github PK
View Code? Open in Web Editor NEWGoroutine local storage
License: MIT License
Goroutine local storage
License: MIT License
gls currently does not work at Go tip - it appears to have broken somewhere between 1.11.2 and golang/go@78c0e1f.
This means that the goconvey package doesn't work any more, since it relies on gls for context tracking.
Test code:
package main
import (
"fmt"
"runtime"
"github.com/jtolds/gls"
)
func main() {
fmt.Printf("Go version: %s\n", runtime.Version())
manager := gls.NewContextManager()
manager.SetValues(gls.Values{
"foo": 1,
}, func() {
foo, ok := manager.GetValue("foo")
fmt.Printf("foo, ok = %+v, %t\n", foo, ok)
})
}
Output on recent versions:
Go version: go1.11.1
foo, ok = 1, true
Go version: go1.11.2
foo, ok = 1, true
Go version: devel +78c0e1f Fri Nov 9 19:57:57 2018 +0000
foo, ok = <nil>, false
For passing trace context, only current gls
is not enough, is there a way to get parent goroutine id? So we can get parent trace context.
see for example smartystreets/goconvey#476
somebody said it's due to improved inlining (removing the tag frames from the call stack).
It request data from runtime stack every getValue, what about the loss in performance?
Thanks.
Hi @jtolds , glad to find these cool codes. I am the original creator and current PPMC, committer of Apache SkyWalking (incubating) project: https://github.com/apache/incubator-skywalking
I am a rookie and new for golang ecosystem, and aware of building an auto-instrument(I prefer most) is possible but hard. So the first step is providing a manual instrument sdk based on SkyWalking model, like you did in monkit-zipkin.
So I definitely look for the thread local propagation for matching our tracing context : https://github.com/apache/incubator-skywalking/blob/master/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextManager.java#L46 I assume the gls library can do that? Am I right?
And also, I found your spacemonkeygo/monkit library, but look like it is more likely based on a pure manual context propagation. Do I get the point right?
I hope you can have time to help with our Apache project.
Hey, I'm not sure if you're still interested in this library, but I was wondering if you could answer a question for me. My use case is similar to the second one mentioned in the read me. I'd like to find a way to identify an HTTP request context for metric purposes. Rather than passing around a context I'd like to consider a goroutine as the context so I can work out timing information on a per request basis.
Would your library work for this, or is it a bit of overkill since I'm really only interested in having an identifier for each goroutine (and possibly looking up the goroutine hierarchy to see if an ancestor is a known goroutine).
Hello,
Can you please tag and version this project?
I am the Debian Maintainer for gls and versioning would help Debian keep up with development.
For my Go interpreter gomacro, I had to use goroutine-local storage so I implemented https://github.com/cosmos72/gls - it uses a single line of assembler to retrieve a goroutine id.
Would you be interested in comparing the two implementations and perhaps add to each one the best features of the other?
A simple example below. GetValue
should return 0, true, but in Go 1.12, it returns 0, false.
package main
import (
"fmt"
"github.com/jtolds/gls"
)
func main() {
mgr := gls.NewContextManager()
mgr.SetValues(gls.Values{"node": 1}, func() {
fmt.Println(mgr.GetValue("node"))
})
}
jtolds/gls cause gc stw increase:
sample code
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.