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

[receiver/receivertest]: accept a user defined function to lookup the unique identifier in CheckConsumeContract #12003

Open
mauri870 opened this issue Jan 2, 2025 · 0 comments

Comments

@mauri870
Copy link

mauri870 commented Jan 2, 2025

Is your feature request related to a problem? Please describe.

I'm experimenting with receivertest.CheckConsumeContract to test a receiver and it seems to have some limitations. The receiver looks for a test_id attribute in the pdata message and uses that identifier to check if the data was delivered properly. This field is currently hardcoded.

For the receiver I'm trying to test, we don't use attributes and everything is in the log message body. I would like to be able to specify exactly how this identifier should be fetched, this gives more flexibility when testing.

Describe the solution you'd like

The first solution I thought of is to use a user defined function to fetch the identifier, for example:

	receivertest.CheckConsumeContract(receivertest.CheckConsumeContractParams{
		T:        t,
		Factory:  NewFactory(),
		Signal: pipeline.SignalLogs,
		GetLogRecordID: func(record plog.LogRecord) (pcommon.Value, bool) {
			return record.Attributes().Get("my custom attribute")
		},
		Config:        cfg,
		Generator:     gen,
		GenerateCount: logsPerTest,
	})

With this we would need a callback function for metrics and traces as well. If this callback is not defined then it defaults to the current behavior—looking up the receivertest.UniqueIDAttrName attribute.

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

No branches or pull requests

1 participant