Comments (7)
span will be created by the first HandlerFunc and closed by the last HandlerFunc,
What was wrong? This sentence is not clear.
from skywalking.
span will be created by the first HandlerFunc and closed by the last HandlerFunc,
What was wrong? This sentence is not clear.
I found that the Gin plugin has been changed to func (c *Context) Next()
. However, this method will be handled multiple times by multiple middleware handlerFuncs in the route.
As a result, CreateEntrySpan is called every handlerFuncs and propagated by Invocation.SetContext()
closed by the last handlerFunc, causing the segment to be incorrectly interrupted prematurely when customizing Gin middleware.
from skywalking.
Could you put a graph to explain this? You are using an instance level dynamic field, this should not be helpful is a handler instance repeatedly used in the process.
from skywalking.
when customize middleware in Gin, the trace info will lost , such as
router := gin.Default()
router.Use(func(c *gin.Context) {
logger.Info("do something before handler")
c.Next()
logger.Info("do something after handler")
})
and the log like this, after has no trace info
2024-01-31 16:56:02 | info | [email protected]/context.go:174 | do something before handler | {"SW_CTX": "[Your_ApplicationName,[email protected],8ad58d8ac01611eea4c42672e7982bed.36.39184449623780005,8ad58d8ac01611eea4c42672e7982bed.36.39184449623780006,0]"}
2024-01-31 16:56:02 | info | [email protected]/context.go:174 | handle | {"SW_CTX": "[Your_ApplicationName,[email protected],8ad58d8ac01611eea4c42672e7982bed.36.39184449623780005,8ad58d8ac01611eea4c42672e7982bed.36.39184449623780006,0]"}
2024-01-31 16:56:02 | info | [email protected]/context.go:174 | do something after handler | {"SW_CTX": "[Your_ApplicationName,[email protected],N/A,N/A,-1]"}
[GIN] 2024/01/31 - 16:56:02 | 200 | 179.3µs | ::1 | GET "/hello"
from skywalking.
I could understand your case now, then, when the context gets reset in the after? Is it caused by stop span
at the end of #Next
, or somewhere else?
from skywalking.
because every middleware handlerFuncs could call #Next
, then it will call #CreateEntrySpan
in #BeforeInvoke
and call span.End()
in #AfterInvoke
many times, but after span.End()
first be Called by the last middleware handlerFunc, the TracingContext in current goroutine will be cleared, so the other handlerfuncs cannot get the TraceContext for use.
from skywalking.
OK, then there is typically solution for this, you should put a counter in the context of the chain. This counter increases one in before and minus one in after. Then, create span when the counter created, and stop span when counter back to zero.
Note, the counter should be kept in the request context.
from skywalking.
Related Issues (20)
- [Feature] does skywalking support hot update of MAL or lal now in2024? HOT 1
- [Feature] where store the sevice name and instance name list? HOT 1
- [Bug] skywalking agent randomly occupies some ports during runtime. HOT 3
- virtual database query HOT 1
- [Bug] java.lang.UnsupportedOperationException: class redefinition failed: attempted to change superclass or interfaces HOT 7
- [Feature] support playframework v3 HOT 2
- [Feature] Expose traceId in PHP for Enhanced Observability HOT 6
- apm-spring-cloud-gateway-3.x-plugin-8.9.0 generate the same tid HOT 1
- [Bug] table exists check error with two schemas in a database HOT 1
- [Feature] skywalking-client-js supports Core Web Vitals metrics
- Discussion about clickhouse support in the OAP HOT 14
- [Feature] Add hierarchy for RabbitMQ layer HOT 4
- [Feature] Add hierarchy to Kafka monitoring HOT 3
- [Feature] Add Kafka monitoring to the showcase HOT 1
- [Bug] skywalking-go sdk panic HOT 7
- [Bug, Vulnerability] CVE-2023-48795 HOT 12
- [Feature] Add Pulsar monitoring to the showcase HOT 4
- [Feature] Add hierarchy to Pulsar monitoring
- [BanyanDB] some tests are missing in convert package in skywalking-banyandb HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from skywalking.