Skip to content
This repository has been archived by the owner on Jun 14, 2023. It is now read-only.

Latest commit

 

History

History
78 lines (61 loc) · 1.37 KB

README.md

File metadata and controls

78 lines (61 loc) · 1.37 KB

Go2sky with net/http

Installation

go get -u github.com/SkyAPM/go2sky

Usage

Server

package main

import (
	"log"

	"github.com/SkyAPM/go2sky"
	"github.com/SkyAPM/go2sky/plugins/http"
	"github.com/SkyAPM/go2sky/reporter"
)

func main() {
	// Use gRPC reporter for production
	re, err := reporter.NewLogReporter()
	if err != nil {
		log.Fatalf("new reporter error %v \n", err)
	}
	defer re.Close()

	tracer, err := go2sky.NewTracer("gin-server", go2sky.WithReporter(re))
	if err != nil {
		log.Fatalf("create tracer error %v \n", err)
	}

	sm, err := http.NewServerMiddleware(tracer)
	if err != nil {
		log.Fatalf("create server middleware error %v \n", err)
	}
	// do something
}

Client

package main

import (
	"log"

	"github.com/SkyAPM/go2sky"
	"github.com/SkyAPM/go2sky/plugins/http"
	"github.com/SkyAPM/go2sky/reporter"
)

func main() {
	// Use gRPC reporter for production
	re, err := reporter.NewLogReporter()
	if err != nil {
		log.Fatalf("new reporter error %v \n", err)
	}
	defer re.Close()

	tracer, err := go2sky.NewTracer("gin-server", go2sky.WithReporter(re))
	if err != nil {
		log.Fatalf("create tracer error %v \n", err)
	}

	sm, err := http.NewClient(tracer)
	if err != nil {
		log.Fatalf("create client error %v \n", err)
	}
	// do something
}

See more