-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Opentracing plugin support #4506
Conversation
Points worth noting:
|
Not sure what's going wrong with Jenkins here, the plugin isn't enabled in the PR, and it looks like all tests pass (not sure on the exit code though):
|
plugin/loader/initializer.go
Outdated
@@ -41,3 +52,15 @@ func runIPLDPlugin(pl plugin.Plugin) error { | |||
|
|||
return ipldpl.RegisterInputEncParsers(coredag.DefaultInputEncParsers) | |||
} | |||
|
|||
func runTracerPlugin(pl plugin.Plugin) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we're doing a type cast above, we can make this function just accept a PluginTracer
and skip the cast here. Should do the same for the ipld one too
plugin/plugins/jaeger/jaeger.go
Outdated
} | ||
|
||
//Initalize a Jaeger tracer and set it as the global tracer in opentracing api | ||
func (*jaegerPlugin) InitGlobalTracer(cfg map[string]interface{}) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably use values from the cfg input in the configuration we do here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I think instead of using a cfg
we should define tracer specific options in the plugins themselves, since config values can differ across different tracer implementations.
933eccf
to
9e55c95
Compare
38cdfd3
to
8e2dcf8
Compare
plugin/loader/initializer.go
Outdated
return err | ||
switch pl.(type) { | ||
case plugin.PluginIPLD: | ||
err := runIPLDPlugin(pl.(plugin.PluginIPLD)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to do the cast here, the type switch does some magic for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure about this? building with err := runIPLDPlugin(pl)
instead of err := runIPLDPlugin(pl.(plugin.PluginIPLD))
fails
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plugin/loader/initializer.go:26:24: cannot use pl (type "github.com/ipfs/go-ipfs/plugin".Plugin) as type "github.com/ipfs/go-ipfs/plugin".PluginIPLD in argument to runIPLDPlugin:
"github.com/ipfs/go-ipfs/plugin".Plugin does not implement "github.com/ipfs/go-ipfs/plugin".PluginIPLD (missing RegisterBlockDecoders method)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, i forgot one bit, it needs to be:
switch pl := pl.(type) {
plugin/loader/initializer.go
Outdated
} | ||
|
||
func runTracerPlugin(pl plugin.PluginTracer) error { | ||
err := pl.InitGlobalTracer() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make type checks easier, I would do:
tr, err := pl.GetTracer()
if err != nil {
return err
}
opentrace.SetGlobalTracer(tr)
That way if the types in your plugin are wrong, this won't fail silently, it will hit type assertion issues and throw an error.
ce55e7f
to
47e4b4a
Compare
47e4b4a
to
4b5fd5f
Compare
cmd/ipfs/main.go
Outdated
|
||
// check if repo is accessible before loading plugins | ||
ok, err := checkPermissions(cctx.ConfigRoot) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if ok { | ||
if _, err := loader.LoadPlugins(pluginpath); err != nil { | ||
if _, err := loader.LoadPlugins(cctx.ConfigRoot); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm... making that code open up and parse the config on its own breaks some abstractions. The fact that the config is a file on disk is an implementation detail, We might need to rethink some things here.
cc @Stebalien @magik6k We need to get some configuration, and the peer ID to the tracing plugin. I'm not entirely sure yet how that should get fed through, ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some context, here is how it may be used with the tracing plugin
https://github.com/ipfs/go-jaeger-plugin/pull/1/files#diff-e92ca16875e3c00b8a36338613029bf9R35
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will also break changes in https://github.com/ipfs/go-ipfs/pull/4244/files#diff-153cb71153ee178fe2869148600ce8d5R197.
The problem is that at this stage we may not even have a peerID/config (i.e. user calling ipfs init
), we may add some sort of late init for plugins that want it and call that above in buildEnv
, either before or after calling core.NewNode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now setting the tracer name could be a manual process - maybe we don't want it to be the nodeID, I was doing this for convenience.
This would still be done via a configuration file (where the tracer name is a field), but that file would reside in the plugin path - possibly under a directory based on the plugin name (e.g. pluginPath/pluginName/config.cfg
).
I imagine we will want the ability to pass plugins config files in the future?
1003957
to
179e64a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. This interface may need to change while implementing/reviewing the plugin itself but this looks like a good baseline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 nitpick, rest LGTM
@@ -3,6 +3,7 @@ package loader | |||
import ( | |||
"github.com/ipfs/go-ipfs/core/coredag" | |||
"github.com/ipfs/go-ipfs/plugin" | |||
"gx/ipfs/QmWLWmRVSiagqP15jczsGME1qpob6HDbtbHAY2he9W5iUo/opentracing-go" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import grouping
I've rebased it on top of the master to allow #4806 to base off it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say: let's merge it and allow #4806 to improve it in future.
define interface for creating tracers for use with opentracing-api License: MIT Signed-off-by: ForrestWeston <forrest@protocol.ai>
define an interface for creating and configuring tracers
add the Jaeger tracer as a plugin
License: MIT
Signed-off-by: ForrestWeston forrest@protocol.ai