Merge branch 'mpetrun5/lotus-extended-tracer' of github.com:ChainSafe/lotus into mpetrun5/lotus-extended-tracer

This commit is contained in:
Mak Muftic
2021-09-24 14:16:31 +02:00
7 changed files with 51 additions and 5 deletions
+5
View File
@@ -0,0 +1,5 @@
package dtypes
type JsonTracerFile string
type ElasticSearchTracer string
type TracerSourceAuth string
+1
View File
@@ -377,6 +377,7 @@ func GossipSub(in GossipIn) (service *pubsub.PubSub, err error) {
if in.Cfg.ElasticSearchTracer != "" {
elasticSearchTransport, err := tracer.NewElasticSearchTransport(
in.Cfg.ElasticSearchTracer,
in.Cfg.ElasticSearchIndex,
)
if err != nil {
return nil, err
+18 -5
View File
@@ -12,17 +12,21 @@ import (
)
const (
ElasticSearch_INDEX = "lotus-pubsub"
ElasticSearch_INDEX_DEFAULT = "lotus-pubsub"
)
func NewElasticSearchTransport(connectionString string) (TracerTransport, error) {
func NewElasticSearchTransport(connectionString string, elasticsearchIndex string) (TracerTransport, error) {
conUrl, err := url.Parse(connectionString)
if err != nil {
return nil, err
}
username := conUrl.User.Username()
password, _ := conUrl.User.Password()
cfg := elasticsearch.Config{
Addresses: []string{
"https://" + conUrl.Host,
conUrl.Scheme + "://" + conUrl.Host,
},
Username: username,
Password: password,
@@ -34,13 +38,22 @@ func NewElasticSearchTransport(connectionString string) (TracerTransport, error)
return nil, err
}
var esIndex string
if elasticsearchIndex != "" {
esIndex = elasticsearchIndex
} else {
esIndex = ElasticSearch_INDEX_DEFAULT
}
return &elasticSearchTransport{
cl: es,
cl: es,
esIndex: esIndex,
}, nil
}
type elasticSearchTransport struct {
cl *elasticsearch.Client
cl *elasticsearch.Client
esIndex string
}
func (est *elasticSearchTransport) Transport(evt TracerTransportEvent) error {