-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
exporterhelper
should reject a queue size of 0
#4584
Comments
@mx-psi I would like to work on this , as I can understand from the codebase the error occurs here opentelemetry-collector/exporter/exporterhelper/queued_retry.go Lines 98 to 104 in 3db1d11
I was thinking of adding a condition to check if queue size is set to 0 and returning the relevant error message else returning the error already present in the code |
@DiptoChakrabarty I think we should |
I agree with Bogdan's suggested approach @DiptoChakrabarty |
Hey, I'm new to contributing and noticed this issue was starting to go stale. I would like to take a stab at it if that's alright. I've setup my environment locally, and wanted to confirm that I am looking at the correct location for the start function, is this correct? Also, I noticed that in the Prometheus exporter where @mx-psi made a similar fix, we are checking for negative values, I don't believe that has been implemented for the OTLP exporter. |
Hey @FreakyNobleGas,
sure, go ahead :)
If we were to check this at startup, I think that would be the right spot. However, as Bogdan pointed above, a better approach is to add a So I believe the plan is to:
Does that make sense?
We can also check for negative values here, they are also nonsensical. |
That makes sense to me and I really appreciate the guidance here. I'll start working on this. :) |
Can this issue be closed? |
@TylerHelmuth While the |
@mx-psi yes, but I've got some other items to complete first. Once I've got those done I'll check back and if its still up for grabs I'll take it. |
@mx-psi. I think we should use reflection in the Config.Validation and look for all members that implement Validate and call it? See https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/configtest/configtest.go#L44 where we check for tags, but we can have the same logic for validate. |
This sounds like a good idea, but it's unclear to me where this should happen. Would the service recursively check all struct fields on |
@TylerHelmuth, if you're not already working on this, I would like to work on it. :) |
@FreakyNobleGas its all yours. |
Hey @mx-psi & @bogdandrutu, I've been attempting to implement the approach bogdandrutu described using reflection, but having some trouble with getting the Validate method using reflect. Just as a proof of concept, my initial approach was to go through each Exporter in config.go and find the nested structures that implement the Validate method. Here is the function I wrote to accomplish this, but the conditional to check if Validate is a method for the struct is never hit even though the struct does have a Validate function. (I confirmed this with print statements that I've removed for clarity)
|
I am not familiar enough with reflection in Go to really help with this, but I can say that I managed to reproduce it https://go.dev/play/p/o73crbqvPbE and the problem is that there are zero methods on the |
@mx-psi, this was extremely helpful! After taking a look at your code and an example from GeekforGeeks, I realized that the function should take type "reflect.Value" instead of "reflect.Type". With this change, the program now reports that Validate() exists. Here's a link to the example you sent with this modification. Another lesson learned from your example is that the receiver type for the struct method will also have an impact. If an addressable struct is passed to the MethodByName function, it will be able to detect struct methods with both pointer and value receivers, however, if the struct is not addressable, then only methods with a value receiver will be detected. The reflection package has a function called Addr() which can return a pointer to the struct, but only if it is addressable. In the Go Playground example I shared, an example of an unaddressable struct is SubConfigOne. When I tested this code in config.go, the function is now reporting that Validate does exist on structs such as exporterhelper.QueueSettings. (Woot!) My only concern is not being able to catch the Validate method on unaddressable structs, which introduces the possibility that Validate wouldn't be executed and with this implementation, we wouldn't be able to detect it. Curious on your thoughts and thank you again for the help. |
Glad to see I could help @FreakyNobleGas. Being able to run |
@mx-psi have you looked into https://github.com/go-playground/validator it may be easier to use something that already offers some kind of support. Not sure if it helps, just throwing ideas to you :)) |
Hey @mx-psi & @bogdandrutu, this took me forever, but I believe I have a proper solution to this issue using the standard reflect library that can call methods of both by value and by pointer regardless if the struct was passed as a pointer or by value. Here's the code that represents this solution: https://go.dev/play/p/1Y8d-mXR4IP |
Look here how I check that a reflect.Value implements an interface. You should not look for method, you should check if it implements an interface: https://github.com/open-telemetry/opentelemetry-collector/pull/4879/files#diff-42d3514f5e3be7f3e45e57a1a6fddedacd15835b09a044cc74107f972973d1adR227 |
Apologies if I'm misunderstanding this, but I thought the intention was to call Validate() on structs that exist within an interface such as QueueSettings. |
@FreakyNobleGas indeed, but go is duck typing, see https://medium.com/@matryer/golang-advent-calendar-day-one-duck-typing-a513aaed544d TLDR: If a struct has a "Validate() error" func it means it implements that interface. |
Hey @bogdandrutu, I was able to get a working solution for this, but I'm curious if there is still a need since config/config.go has been deprecated? Here is the link to my solution to call all validate methods based on your recommendation to use duck typing. I can move it to another location if you still think it is useful. |
There is still a need. The config package is not being removed, it's just being moved to a different place in the repository. |
I was working on this by making some modifications to @FreakyNobleGas 's solution and integrated it into the new config implementation here: 84e49f1. However, it looks like the implementation changed again in #6572 so I'll be re-targetting my changes on top of that new PR. |
It looks like this functionality is already being worked on in this draft PR: #6545 |
Describe the bug
exporterhelper
allows for aQueueSize
of0
, which results in a permanently blocked exporter that drops all data (see open-telemetry/opentelemetry-collector-contrib#6718 (comment)).Steps to reproduce
Create a pipeline with an exporter that exposes the
QueueSettings
struct and set the queue size to 0.What did you expect to see?
The Collector would fail to start and provide a descriptive error.
What did you see instead?
The Collector fails each time a payload gets to the exporter with a message similar to:
What version did you use?
Version: (e.g.,
v0.4.0
,1eb551b
, etc)Latest commit reproduces 81ab024
What config did you use?
Config: (e.g. the yaml config file)
Example config with contrib distro
Environment
not relevant
The text was updated successfully, but these errors were encountered: