go-gorm / opentelemetry Goto Github PK
View Code? Open in Web Editor NEWopentelemetry for gorm
License: MIT License
opentelemetry for gorm
License: MIT License
As other tracing methods like sqlx, it is not necessary to call a function to pass the context as a parameter. But in the examples folder, you call WithContext
and pass the context there.
I have seen in the code that the tracing plugin is called in the hooks so, do I need to call the method WithContext
when we want to trace the SQL query?
The README.md should have an example after its initialization.
Two possibilities:
WithContext
every time you want to execute any queryI'd like to add a config option to skip the tx.Dialector.Explain
step step when tracing the query (i.e. just record the result of tx.Statement.SQL.String()
). This can either be its own option or it could replace the WithoutQueryVariables()
option, which has some significant performance issues for some uses (see below). I'm not sure that there's a good use case for WithoutQueryVariables()
that wouldn't be solved with the proposed option.
I have a working version of the option in a fork I created here: master...tonalfitness:gorm-opentelemetry:master
If you're open to this request, I can open a PR for this change.
I'm using this plugin in a production environment, configured with the WithoutQueryVariables()
option. We originally configured the overall tracing with a relatively low sampling rate (10%) and there wasn't a noticeable change in performance. When we switch to 100% tracing (in order to tail sample our traces), we noticed a very large increase in latency and high CPU utilization that we traced back to the use of this plugin (by disabling it and re-testing).
We traced the actual performance issue to the use of tx.Dialector.Explain
, which substitutes the actual parameters into the query string. This results in a lot of string copies, which I think makes sense given what it's doing. We use the WithoutQueryVariables()
option, but all that does is substitute ?
for the variable values -- it still does the string interpolation.
My preliminary performance testing of the forked version mentioned above shows that the high CPU utilization and latency goes away but we still get a useful representation of the SQL query used.
I developed a http service using gin framework. The service has an interface to call gorm's framework for database queries. The telemetry of the entire service is generated through istio sidecar and reported to jaeger. Using the plugin alone, it is impossible to associate gorm's telemetry with the http service call.
How to pass the parent span and gorm association generated by istio
Support zap logger.
We are looking for gorm tool for tracing and metrics, and , can we use it for production now?
Looks like the plugin doesn't exist on gorm.io:
go get gorm.io/plugin/opentelemetry
go: unrecognized import path "gorm.io/plugin/opentelemetry": reading https://gorm.io/plugin/opentelemetry?go-get=1: 404 Not Found
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.