Comments (9)
@Saicasm I found that gorm
has hooks and maybe we can implement a plugin based on them.
from go2sky.
Hi @arugal thanks for the response ,so go2sky doesn't support any database related metrics ?
For now, yes. Here is the list of plugins https://github.com/SkyAPM/go2sky-plugins#go2sky-plugins
Okay, thank you @arugal
from go2sky.
I don't know what do you mean. Is database showing up on the UI? If so, it must have included in a span.
And about auto instrumentation, yes, I don't think there is a way, according to Google golang team.
from go2sky.
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"strconv"
"github.com/SkyAPM/go2sky"
httpPlugin "github.com/SkyAPM/go2sky/plugins/http"
"github.com/SkyAPM/go2sky/reporter"
"github.com/gorilla/mux"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mysql"
_ "github.com/jinzhu/gorm/dialects/postgres"
)
var db *gorm.DB
var err error
type Booking struct {
Id int `json:"id"`
User string `json:"user"`
Members int `json:"members"`
}
func homePage(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Welcome to HomePage!")
fmt.Println("Endpoint Hit: HomePage")
}
func main() {
database, err := gorm.Open("mysql", "user:password@/test?charset=utf8&parseTime=True&loc=Local")
if err != nil {
panic("Failed to connect to database!")
}
database.AutoMigrate(&Booking{})
db = database
re, err := reporter.NewGRPCReporter("localhost:11800")
if err != nil {
log.Fatalf("new reporter error %v \n", err)
}
defer re.Close()
// re, err := reporter.NewLogReporter()
// if err != nil {
// log.Fatalf("new reporter error %v \n", err)
// }
// defer re.Close()
tracer, err := go2sky.NewTracer("go-http-client", go2sky.WithReporter(re))
if err != nil {
log.Fatalf("create tracer error %v \n", err)
}
sm, err := httpPlugin.NewServerMiddleware(tracer)
if err != nil {
log.Fatalf("create server middleware error %v \n", err)
}
// span, ctx, err := tracer.CreateLocalSpan(context.Background())
// go2sky.TraceID(ctx)
// subSpan, newCtx, err := tracer.CreateLocalSpan(ctx)
// fmt.Println(newCtx)
// subSpan.End()
// span.End()
log.Println("Starting development server at http://127.0.0.1:10000/")
log.Println("Quit the server with CONTROL-C.")
// creates a new instance of a mux router
myRouter := mux.NewRouter().StrictSlash(true)
myRouter.HandleFunc("/", homePage)
myRouter.HandleFunc("/new-booking", createNewBooking).Methods("POST")
myRouter.HandleFunc("/all-bookings", returnAllBookings)
myRouter.HandleFunc("/booking/{id}", returnSingleBooking)
log.Fatal(http.ListenAndServe(":10000", sm(myRouter)))
}
func createNewBooking(w http.ResponseWriter, r *http.Request) {
// get the body of our POST request
// return the string response containing the request body
reqBody, _ := ioutil.ReadAll(r.Body)
var booking Booking
json.Unmarshal(reqBody, &booking)
db.Create(&booking)
fmt.Println("Endpoint Hit: Creating New Booking")
json.NewEncoder(w).Encode(booking)
}
func returnAllBookings(w http.ResponseWriter, r *http.Request) {
bookings := []Booking{}
db.Find(&bookings)
fmt.Println("Endpoint Hit: returnAllBookings")
json.NewEncoder(w).Encode(bookings)
}
func returnSingleBooking(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
key := vars["id"]
bookings := []Booking{}
db.Find(&bookings)
for _, booking := range bookings {
// string to int
s, err := strconv.Atoi(key)
if err == nil {
if booking.Id == s {
fmt.Println(booking)
fmt.Println("Endpoint Hit: Booking No:", key)
json.NewEncoder(w).Encode(booking)
}
}
}
}
Hi @Saicasm, currently go2sky does not have gorm
plugin.
from go2sky.
Hi @arugal thanks for the response ,so go2sky doesn't support any database related metrics ?
from go2sky.
Hi @arugal thanks for the response ,so go2sky doesn't support any database related metrics ?
For now, yes. Here is the list of plugins https://github.com/SkyAPM/go2sky-plugins#go2sky-plugins
from go2sky.
@Saicasm I think the point is you need to have the exit span, with spanLayer=DATABASE
and several specific tag keys.
from go2sky.
@Saicasm I think the point is you need to have the exit span, with
spanLayer=DATABASE
and several specific tag keys.
@wu-sheng thanks for the info ,i'm able to register database but the traces and other db metrics are not shown and i believe we have it coming up in the go2sky roadmap !?
Also for distributed tracing does it have to be manually instrumented ? Go doesn't support auto instrumentation ?
from go2sky.
Discuss in new issue #78
from go2sky.
Related Issues (20)
- close gRPCReporter error HOT 2
- go get error HOT 5
- Tracing event source and sink in knative eventing HOT 6
- How to send log to the log page? HOT 1
- Grpc Reporter's logger cannot use custom logger.
- To create a exit span with one statement, not two statement HOT 3
- It has small probability will be panic HOT 5
- [Broken] CROSS_PROCESS HOT 1
- Can go2sky support output to kafka/pulsar HOT 4
- go2sky.SetGlobalTracer is undefined in v1.3.0 HOT 1
- fetch dynamic configuration error rpc error: code = PermissionDenied desc = HOT 6
- send keep alive signal error rpc error HOT 3
- unexpected EOF HOT 2
- panic on google.golang.org/protobuf/encoding/protowire.AppendString
- Unexcepted parentSpanID when parent span is ended HOT 1
- fetch dynamic configuration error rpc error: code = Unimplemented desc = Method not found: skywalking.v3.ConfigurationDiscoveryService/fetchConfigurations HOT 6
- gRPCReporter can use nanosecond instead of millisecond HOT 1
- Make sampling decision with span tags. HOT 5
- reach max send buffer
- memory leak
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 go2sky.