Skip to content
This repository was archived by the owner on Nov 7, 2022. It is now read-only.

plugins hooked into cmd/ocagent #70

Closed
wants to merge 1 commit into from
Closed

Conversation

odeke-em
Copy link
Member

@odeke-em odeke-em commented Oct 7, 2018

Also added a canonical example as well as
regression test to ensure that plugins
work as expected.

This change finishes up the work started in #46.

Fixes #47

@odeke-em odeke-em force-pushed the ocagent-with-plugins branch 2 times, most recently from 6d5ea4b to c87ea79 Compare October 7, 2018 03:05
@odeke-em
Copy link
Member Author

odeke-em commented Oct 7, 2018

Travis doesn't seem to be returning the proper path of the Go binary that it used to run the current binary.

@songy23
Copy link
Contributor

songy23 commented Oct 8, 2018

Please fix the build.

EDIT: looks like ./cmd/ocagent/plugins/plugins_test.go is not formatted correctly?

@odeke-em odeke-em force-pushed the ocagent-with-plugins branch 2 times, most recently from 4335a1b to 952d9d3 Compare October 8, 2018 20:57
@odeke-em
Copy link
Member Author

odeke-em commented Oct 8, 2018

EDIT: looks like ./cmd/ocagent/plugins/plugins_test.go is not formatted correctly?

Thanks! But the change I made it to didn't affect the functionality, so the Travis Go binary still doesn't seem to be found.

@odeke-em
Copy link
Member Author

odeke-em commented Oct 8, 2018

The test when run locally passes but on Travis

	plugins_test.go:82: Unexpected output: 2018/10/08 21:00:19 Failed to load the plugin from
/tmp/plugin_end_to_end889768309/sample.so Error: plugin.Open("/tmp/plugin_end_to_end889768309/sample"): plugin was built with a different version of package sync/atomic

It is just an integration/example test that can be run on a proper setup so am going to skip it for now, as it is a nice to have.

@odeke-em odeke-em force-pushed the ocagent-with-plugins branch from 4163390 to 8481faf Compare October 8, 2018 21:08
@odeke-em
Copy link
Member Author

odeke-em commented Oct 8, 2018

@songy23 PTAL.

* Also added a canonical example as well as
regression test to ensure that plugins
work as expected.

This change finishes up the work started in #46.

* plugins_test: skip TestCreatePlugin

On Travis CI, trying to retrieve the same version of Go
as is being used at runtime is quite the hassle. Since
this test is a nice-to-have and more of an integration
test that runs properly locally, skip it for now until
we have enough time to expend investigating Travis CI e.g.
    https://travis-ci.org/census-instrumentation/opencensus-service/builds/438157975

Fixes #47
@odeke-em odeke-em force-pushed the ocagent-with-plugins branch from 8481faf to 466203d Compare October 8, 2018 21:15
Copy link
Contributor

@songy23 songy23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic makes sense to me, though I'm not very familiar with the syntax/usage of Go plugins. /cc @rakyll on this change.

@rakyll
Copy link
Contributor

rakyll commented Oct 8, 2018

Please don't use Go plugins yet. They are not production ready and are not supported on Windows.

@odeke-em
Copy link
Member Author

odeke-em commented Oct 8, 2018

Please don't use Go plugins yet. They are not production ready and are not supported on Windows.

@rakyll yes, we considered that as per https://github.com/census-instrumentation/opencensus-service/blob/master/exporter/plugins.md#limitations
and in the proposal issue #47

They are not production ready

What do you mean?

@rakyll
Copy link
Contributor

rakyll commented Oct 8, 2018

What do you mean?

There are many missing pieces. For example, if a plugin is built by a different version of Go, it cannot be loaded to a binary built with a different version. There are problems with sharing data and using types from third party packages. Plugins are not currently ready to be used for the purposes we want them be used for. Even if we use plugins, we need to own and build the vendor-specific shared libraries each time we make a new binary release.

@odeke-em
Copy link
Member Author

odeke-em commented Oct 8, 2018

There are many missing pieces. For example, if a plugin is built by a different version of Go, it cannot be loaded to a binary built with a different version.

Also considered and in the limitations section of https://github.com/census-instrumentation/opencensus-service/blob/master/exporter/plugins.md#limitations

Even if we use plugins, we need to own and build the vendor-specific shared libraries each time we make a new binary release.

Not really, we plan on distributing say binaries or a Docker image built using a specific version of Go that will be returned by #60 and vendors can hook into.

Plugins are not currently ready to be used for the purposes we want them be used for.

Our purpose here is very specific and we cut through the limitations mentioned, please correct me if am missing something else but I believe we examined all those points raised.

@rakyll
Copy link
Contributor

rakyll commented Oct 8, 2018

Our purpose here is very specific and we cut through the limitations mentioned, please correct me if am missing something else but I believe we examined all those points raised.

We can achieve agent features without having to rely on plugins. For example, we can look in the PATH if a vendor-specific agent extension binary exists.

If config file contains "apmvendor", we can look whether ocagent-apmvendor is in the PATH and fork it. Then communicate from ocagent to ocagent-apmvendor for exports. I am sure there are more other alternatives but this is one of the possibilities.

@rakyll
Copy link
Contributor

rakyll commented Oct 8, 2018

The other alternative is to make ocagent server a library, so vendors can build their own ocagent-compatible binaries with their features and exporters and distribute them without having to rely on us.

@derekperkins
Copy link

+1 to not using native Go plugins. This is a more production ready option if you keep going down the plugin path https://github.com/hashicorp/go-plugin

@bogdandrutu
Copy link

As we discussed I think it is important to achieve the flexibility and configurability for the agent but I think plugins are not good here because they are not very mature and they don't work on windows based on my understanding.

@odeke-em
Copy link
Member Author

odeke-em commented Oct 9, 2018

+1 to not using native Go plugins. This is a more production ready option if you keep going down the plugin path https://github.com/hashicorp/go-plugin

@derekperkins nice suggestion! However, please take a look (if you haven't already) at https://github.com/hashicorp/go-plugin#what-about-shared-libraries for the reason why they wrote that library in 2012 and then compare to today :)

As we discussed I think it is important to achieve the flexibility and configurability for the agent but I think plugins are not good here because they are not very mature and they don't work on windows based on my understanding.

@bogdandrutu sort of: they've been around since 2012 and not working on Windows is something we discussed and documented, plus I answered all the points raised in #70 (comment)

I think this proposal can simmer for a while as we find other ideas, as suggested. It is great that we've gotten discourse from this implementation and for now we can develop the other features of the agent until someone actually needs this feature or prioritize it. Thanks y'all!

@derekperkins
Copy link

nice suggestion! However, please take a look (if you haven't already) at https://github.com/hashicorp/go-plugin#what-about-shared-libraries for the reason why they wrote that library in 2012 and then compare to today :)

Honestly I don't think the situation has changed much since 2012. Not only do Go versions have to match, but there are serious issues with shared libraries, vendoring and versioning like @rakyll mentioned. golang/go#20481

If the question is about performance, another route is something akin to the plugin system for Caddy. https://caddyserver.com/download That actually natively compiles supported plugins into a binary.

I think this proposal can simmer for a while as we find other ideas, as suggested

sounds like a plan :)

@odeke-em
Copy link
Member Author

I'll close this PR and if we need it back, we can get it back from history.

@yurishkuro
Copy link

A better link to Caddy plugins approach: https://github.com/mholt/caddy/wiki. As I understand, it's just adding the plugins to the source code and building a custom binary, i.e. does not involve distributing pre-built binaries for core server + plugins.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants