Skip to content
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

feat(outputs): Add inlong output plugin #16211

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

justinwwhuang
Copy link

@justinwwhuang justinwwhuang commented Nov 20, 2024

Summary

Add inlong output plugin
Apache InLong is a one-stop, full-scenario integration framework for massive data that supports Data Ingestion, Data Synchronization and Data Subscription, and it provides automatic, secure and reliable data transmission capabilities. InLong also supports both batch and stream data processing at the same time, which offers great power to build data analysis, modeling and other real-time applications based on streaming data.

Checklist

  • No AI generated code was used in this PR

Related issues

resolves #16210

@telegraf-tiger
Copy link
Contributor

Thanks so much for the pull request!
🤝 ✒️ Just a reminder that the CLA has not yet been signed, and we'll need it before merging. Please sign the CLA when you get a chance, then post a comment here saying !signed-cla

@telegraf-tiger telegraf-tiger bot added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Nov 20, 2024
@justinwwhuang
Copy link
Author

Thanks so much for the pull request! 🤝 ✒️ Just a reminder that the CLA has not yet been signed, and we'll need it before merging. Please sign the CLA when you get a chance, then post a comment here saying !signed-cla

!signed-cla

Copy link
Member

@mstrandboge mstrandboge left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I have some initial comments if you could take a look

@mstrandboge mstrandboge self-assigned this Nov 23, 2024
@justinwwhuang
Copy link
Author

@DStrand1 Hello, I have made corresponding modifications to your comments. Please take a look again. Thank you

@justinwwhuang
Copy link
Author

@DStrand1 Hello, I have made corresponding modifications to your comments. Please take a look again. Thank you

Copy link
Member

@mstrandboge mstrandboge left a comment

Choose a reason for hiding this comment

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

Changes look good to me, @justinwwhuang can you rebase and run go mod tidy to fix the merge issue?

@justinwwhuang justinwwhuang force-pushed the b16210 branch 3 times, most recently from 9e1915e to 30ba17d Compare December 19, 2024 10:34
@justinwwhuang
Copy link
Author

@DStrand1 Hello, I have made corresponding modifications to your comments. Please take a look again. Thank you

I have made corresponding modifications to your comments. Please take a look again. Thank you

@justinwwhuang
Copy link
Author

@DStrand1 I have made corresponding modifications to your comments. Please take a look again. Thank you

@justinwwhuang
Copy link
Author

@DStrand1 Is there anything blocking this PR? I'd appreciate feedback to improve it.

Copy link
Member

@mstrandboge mstrandboge left a comment

Choose a reason for hiding this comment

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

Sorry for the slow response! Overall this looks good, I just have a couple remaining smaller comments

@justinwwhuang
Copy link
Author

Sorry for the slow response! Overall this looks good, I just have a couple remaining smaller comments
Thank you for your comment, I have made the necessary modifications according to it. The current test-go-mac failed to run, I don't quite understand what the error is.

@justinwwhuang
Copy link
Author

@DStrand1 @srebhan Hello, can you help merge this PR? This PR has been in existence for a long time and has already resolved several code conflicts. If there are any issues, I am willing to make changes.

@justinwwhuang justinwwhuang force-pushed the b16210 branch 7 times, most recently from cc90ed1 to de82ea4 Compare March 11, 2025 02:43
Copy link
Member

@mstrandboge mstrandboge left a comment

Choose a reason for hiding this comment

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

Just one small comment left, otherwise approved! Thanks for being patient and wrapping up this PR

@mstrandboge mstrandboge assigned skartikey and srebhan and unassigned mstrandboge Mar 28, 2025
@mstrandboge mstrandboge added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Mar 28, 2025
Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Thank you very much @justinwwhuang for your contribution! Much appreciated. However, I do have some comments regarding the code. The major points are

  1. There is no form of user-specified option checking e.g. if no or a malformed URL is specified, missing group- or stream-IDs...
  2. The tests don't add any value as they will always succeed even when the plugin is set-up with invalid configuration options.
  3. I don't see any way to authenticate to the service. I can't imagine that anyone will use Inlong in an production environment without authentication...

While I'm okay with adding authentication later (point 3), the former ones need some more work.

For option checking (point 1) I suggest to introduce an Init() function to the plugin and check the values there with at least a test for

  • provided URL is not empty
  • provided URL is a valid http or https URL
  • provided group-id is not empty
  • provided stream-id is not empty

If the latter two are "optional" you can skip those or add a sensible default value (e.g. "telegraf").

For testing (point 2) I do see three options actually:

  1. Produce a mock implementation. This would require a mock of the manager "server" endpoint for getting the node IDs and a mock of the data-proxy send protocol. Information for producing the mock can be found in the inlong SDK I think together with some reverse engineering by running queries against a real instance and observe the responses. Certainly the hardest of the options but also the most rewarding one...
  2. Setup an integration test using docker containers by "manually" composing the instance mimicking e.g. this docker compose setup. This would guarantee that the plugin would actually work with a real Inlong instance...
  3. If none of the above is possible, at least add some tests for invalid user options and skip all the always-succeeding mock-producer tests.

My preference would be a mix of 1 and 2 but that might be some effort.

So long story short, I would need at least the user-setting checks and a rudimentary test being implemented to be able to merge this PR.

Comment on lines +47 to +68
func TestInlong_Write(t *testing.T) {
s := &csv.Serializer{Header: true}
require.NoError(t, s.Init())
producer := &MockProducer{}
i := &Inlong{
producer: producer,
serializer: s,
}
m := metric.New(
"cpu",
map[string]string{
"topic": "test-topic",
},
map[string]interface{}{
"value": 42.0,
},
time.Unix(0, 0),
)
var metrics []telegraf.Metric
metrics = append(metrics, m)
require.NoError(t, i.Write(metrics))
}
Copy link
Member

Choose a reason for hiding this comment

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

To be honest, I don't know if this test adds any meaningful guard at all. The mock producer will not validate any of the data sent nor any of the parameters. It would succeed even if you don't specify any URL or group or stream (as you do here) and without a connect! So you could do anything and this test would always succeed! That's not a test in my view.

ManagerURL string `toml:"manager_url"`
Log telegraf.Logger `toml:"-"`

producerFunc func(groupId string, managerUrl string) (dataproxy.Client, error)
Copy link
Member

Choose a reason for hiding this comment

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

This indirection through producerFunc seems to be introduced for testing. However, as it stands now, the tests add no real value so I would remove the indirection in favor of simplifying the code.

return nil
}

func (i *Inlong) Write(metrics []telegraf.Metric) error {
Copy link
Member

Choose a reason for hiding this comment

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

What happens if the Inlong instance goes down for whatever reason and comes up again e.g. due to network issues or service outages? Would the plugin reconnect automatically in this case?

@srebhan srebhan removed the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Mar 31, 2025
@telegraf-tiger
Copy link
Contributor

@srebhan
Copy link
Member

srebhan commented Mar 31, 2025

@justinwwhuang please re-request a review once you are done, for me to get a notification and guarantee fast update-review cycles... You are already waiting for too long... :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add inlong output plugin
5 participants