mirror of
https://github.com/minio/minio.git
synced 2025-01-25 21:53:16 -05:00
Merge pull request #945 from harshavardhana/release-tag
Update new changes in probe and add setAppInfo
This commit is contained in:
commit
07839caf9b
4
main.go
4
main.go
@ -148,8 +148,8 @@ VERSION:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Set projet's root source path.
|
probe.Init() // Set project's root source path.
|
||||||
probe.SetRoot()
|
probe.SetAppInfo("Release-Tag", minioReleaseTag)
|
||||||
|
|
||||||
app := registerApp()
|
app := registerApp()
|
||||||
app.Before = func(c *cli.Context) error {
|
app.Before = func(c *cli.Context) error {
|
||||||
|
38
vendor/github.com/minio/minio-xl/pkg/probe/probe.go
generated
vendored
38
vendor/github.com/minio/minio-xl/pkg/probe/probe.go
generated
vendored
@ -29,17 +29,32 @@ import (
|
|||||||
"github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
// Root path to the project's source.
|
// Root path to the project's source.
|
||||||
var rootPath string
|
rootPath string
|
||||||
|
// App specific info to be included reporting.
|
||||||
|
appInfo map[string]string
|
||||||
|
)
|
||||||
|
|
||||||
// SetRoot sets the project's root path. Root path is automatically
|
// Init initializes probe. It is typically called once from the main()
|
||||||
// determined from the calling function's source file location. It is
|
// function or at least from any source file placed at the top level
|
||||||
// typically called from the main() function.
|
// source directory.
|
||||||
func SetRoot() {
|
func Init() {
|
||||||
|
// Root path is automatically determined from the calling function's source file location.
|
||||||
// Catch the calling function's source file path.
|
// Catch the calling function's source file path.
|
||||||
_, file, _, _ := runtime.Caller(1)
|
_, file, _, _ := runtime.Caller(1)
|
||||||
// Save the directory alone.
|
// Save the directory alone.
|
||||||
rootPath = filepath.Dir(file)
|
rootPath = filepath.Dir(file)
|
||||||
|
|
||||||
|
appInfo = make(map[string]string)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAppInfo sets app speific key:value to report additionally during call trace dump.
|
||||||
|
// Eg. SetAppInfo("ReleaseTag", "RELEASE_42_0")
|
||||||
|
// SetAppInfo("Version", "42.0")
|
||||||
|
// SetAppInfo("Commit", "00611fb")
|
||||||
|
func SetAppInfo(key, value string) {
|
||||||
|
appInfo[key] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSysInfo returns useful system statistics.
|
// GetSysInfo returns useful system statistics.
|
||||||
@ -102,7 +117,7 @@ func NewError(e error) *Error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
Err := Error{lock: sync.RWMutex{}, Cause: e, CallTrace: []TracePoint{}, SysInfo: GetSysInfo()}
|
Err := Error{lock: sync.RWMutex{}, Cause: e, CallTrace: []TracePoint{}, SysInfo: GetSysInfo()}
|
||||||
return Err.trace()
|
return Err.trace() // Skip NewError and only instead register the NewError's caller.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trace records the point at which it is invoked.
|
// Trace records the point at which it is invoked.
|
||||||
@ -118,7 +133,8 @@ func (e *Error) Trace(fields ...string) *Error {
|
|||||||
return e.trace(fields...)
|
return e.trace(fields...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Internal trace - records the point at which it is invoked.
|
// trace records caller's caller. It is intended for probe's own
|
||||||
|
// internal use. Take a look at probe.NewError for example.
|
||||||
func (e *Error) trace(fields ...string) *Error {
|
func (e *Error) trace(fields ...string) *Error {
|
||||||
if e == nil {
|
if e == nil {
|
||||||
return nil
|
return nil
|
||||||
@ -182,7 +198,13 @@ func (e *Error) String() string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
str += "\n" + " Host:" + e.SysInfo["host.name"] + " | "
|
str += "\n "
|
||||||
|
|
||||||
|
for key, value := range appInfo {
|
||||||
|
str += key + ":" + value + " | "
|
||||||
|
}
|
||||||
|
|
||||||
|
str += "Host:" + e.SysInfo["host.name"] + " | "
|
||||||
str += "OS:" + e.SysInfo["host.os"] + " | "
|
str += "OS:" + e.SysInfo["host.os"] + " | "
|
||||||
str += "Arch:" + e.SysInfo["host.arch"] + " | "
|
str += "Arch:" + e.SysInfo["host.arch"] + " | "
|
||||||
str += "Lang:" + e.SysInfo["host.lang"] + " | "
|
str += "Lang:" + e.SysInfo["host.lang"] + " | "
|
||||||
|
4
vendor/github.com/minio/minio-xl/pkg/probe/probe_test.go
generated
vendored
4
vendor/github.com/minio/minio-xl/pkg/probe/probe_test.go
generated
vendored
@ -43,8 +43,8 @@ func testDummy2() *probe.Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestProbe(c *C) {
|
func (s *MySuite) TestProbe(c *C) {
|
||||||
probe.SetRoot() // Set project's root source path.
|
probe.Init() // Set project's root source path.
|
||||||
|
probe.SetAppInfo("Release-Tag", "RELEASE.Sat-19-Sep-2015-06-15-16-GMT")
|
||||||
es := testDummy2().Trace("TopOfStack")
|
es := testDummy2().Trace("TopOfStack")
|
||||||
// Uncomment the following Println to visually test probe call trace.
|
// Uncomment the following Println to visually test probe call trace.
|
||||||
// fmt.Println("Expecting a simulated error here.", es)
|
// fmt.Println("Expecting a simulated error here.", es)
|
||||||
|
4
vendor/vendor.json
vendored
4
vendor/vendor.json
vendored
@ -64,8 +64,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "github.com/minio/minio-xl/pkg/probe",
|
"path": "github.com/minio/minio-xl/pkg/probe",
|
||||||
"revision": "0ccfa2965bc93efde3efda8b0f0779690f192d4f",
|
"revision": "a7b8623fd546965505f18172717393f5de4139a2",
|
||||||
"revisionTime": "2015-10-23T19:31:44-07:00"
|
"revisionTime": "2015-10-25T03:03:43-07:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "github.com/minio/minio-xl/pkg/quick",
|
"path": "github.com/minio/minio-xl/pkg/quick",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user