-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
define an interface for creating and configuring tracers add the Jaeger tracer as a plugin License: MIT Signed-off-by: ForrestWeston <forrest@protocol.ai>
- Loading branch information
Showing
4 changed files
with
84 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package jaeger | ||
|
||
import ( | ||
"github.com/ipfs/go-ipfs/plugin" | ||
opentrace "github.com/opentracing/opentracing-go" | ||
config "github.com/uber/jaeger-client-go/config" | ||
) | ||
|
||
// Plugins is exported list of plugins that will be loaded | ||
var Plugins = []plugin.Plugin{ | ||
&jaegerPlugin{}, | ||
} | ||
|
||
type jaegerPlugin struct{} | ||
|
||
var _ plugin.PluginTracer = (*jaegerPlugin)(nil) | ||
|
||
func (*jaegerPlugin) Name() string { | ||
return "jaeger" | ||
} | ||
|
||
func (*jaegerPlugin) Version() string { | ||
return "0.0.1" | ||
} | ||
|
||
func (*jaegerPlugin) Init() error { | ||
return nil | ||
} | ||
|
||
//Initalize a Jaeger tracer and set it as the global tracer in opentracing api | ||
func (*jaegerPlugin) InitGlobalTracer(cfg map[string]interface{}) error { | ||
tracerCfg := &config.Configuration{ | ||
Sampler: &config.SamplerConfig{ | ||
Type: "const", | ||
Param: 1, | ||
}, | ||
Reporter: &config.ReporterConfig{ | ||
LogSpans: false, | ||
}, | ||
} | ||
//service should be the ipfs node id | ||
//we are ignoring the closer for now | ||
tracer, _, err := tracerCfg.New("IPFS-NODE-ID") | ||
if err != nil { | ||
//probably failed to init the tracer | ||
return err | ||
} | ||
opentrace.SetGlobalTracer(tracer) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package plugin | ||
|
||
// PluginTracer is an interface that can be implemented to add a tracer | ||
type PluginTracer interface { | ||
Plugin | ||
InitGlobalTracer(cfg map[string]interface{}) error | ||
} |