modulepackage
0.0.0-20190215104628-93818c898049
Repository: https://github.com/efureev/tracefall.git
Documentation: pkg.go.dev
# README
Info
Package for sending logs to the storage, for the subsequent withdrawal of the traceViewer service and display there.
Supported storage drivers:
- Console // invalid realisation
- Postgres // invalid realisation
- Algolia
- ElasticSearch
Content
- Thread Line: Line of logs. Contains Logs. Thread ID = First root Log ID
- Log: data node. May contents other Logs as children
ScreenShort of TraceViewer based on traceFall
Union Logs
Independent Logs may union to one log thread via LogParentShadow
logChild := tracefall.NewLog(`prepare Scrapping`).SetApplication(`micro.1`)
logChild.ParentFromShadow(job.LogShadow)
Example
microservice #1
logParent := tracefall.NewLog(`Start`)
// send to RabbitMQ job with logParent.ToShadow() data
microservice #2
// get from RabbitMQ job with logParent.ToShadow() data
logChild := tracefall.NewLog(`prepare Scrapping`).SetApplication(`micro.2`)
logChild.ParentFromShadow(job.LogShadow)
Now logChild
has parent logParent
Use
Create new Log node
import "github.com/efureev/tracefall"
// ...
log := tracefall.NewLog(`test log`)
Finish log
log := tracefall.NewLog(`test log`)
// with fail result
log.Fail(err error)
// with success result
log.Success()
// without result: set finish time of the log
log.FinishTimeEnd()
Finish thred of logs
log.ThreadFinish()
Add extra data to Log
log := tracefall.NewLog(`test log`)
log.Data.Set(`url`, `http://google.com`).Set(`service`, service.Name)
Add notes to Log
log.Notes.Add(`send to redis`, `ok`).Add(`send to rabbit`, `ok`)
//or
log.Notes.AddGroup(`send to redis`, [`ping`,`processing`,`done`])
Sending logs to storage
var logStorage *tracefall.DB
func tracerLogStart(tracerHost, tracerUser, tracerPassword, tracerDbName, tracerTable string) {
var err error
logStorage, err = tracefall.Open(`postgres`, postgres.GetConnParams(tracerHost, tracerDbName, tracerTable, tracerUser, tracerPassword))
if err != nil {
log.Fatal(err)
}
}
func send(m) {
if logStorage == nil {
return
}
_, err := logStorage.Send(m *tracefall.Log)
if err != nil {
fmt.Println(`[error sent to trace logs] -> ` + err.Error())
}
}
# Functions
Drivers returns a sorted list of the names of the registered drivers.
NewExtraData create new Data struct.
NewLog create new Log.
NewNote struct.
NewNoteGroup create new NoteGroup.
NewNotesGroups creates new NoteGroups struct.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ThreadFromList make Thread from list of LogJSON structs.
# Structs
.
No description provided by the author
Log struct.
LogJSON struct.
LogParentShadow struct.
Note struct.
NoteGroup struct.
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
No description provided by the author
No description provided by the author
Logable interface.
.
# Type aliases
ExtraData is data tree.
NoteGroupList is list of NoteGroup.
NoteGroups is list of NoteGroup.
Notes list of Note.
Tags struct is list of string.
Thread is list of LogJSON struct.