-
Notifications
You must be signed in to change notification settings - Fork 202
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: configurable mock destination for pipeline testing #2012
Conversation
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.
Very cool
|
||
func NewMockDestinationExporter(config *Config, | ||
params exporter.Settings) (*MockDestinationExporter, 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.
nit: maybe worth to add small config validation ?
ResponseDuration > 0
1 > RejectFraction > 0
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.
added in config.go under Validate
function
|
||
func (e *MockDestinationExporter) mockExport(context.Context) error { | ||
// not taking care of ctx cancel and shutdown as this is a dummy exporter and not used in production | ||
<-time.After(e.config.ResponseDuration) |
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.
nit: I think time.Sleep is better as time.After create goroutine every time it is called so this has the potential to blow up CPU according to the number of parallel invocation to this function
This new exporter mocks a destination, and allows one to simulate various back-pressure scenarios, like long time to get a response for the export, and simulating some export requests being rejected.
It is useful for pipeline development and testing