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

embed: add integration test for distributed tracing #14348

Merged
merged 3 commits into from
Oct 12, 2022

Conversation

VinozzZ
Copy link
Contributor

@VinozzZ VinozzZ commented Aug 15, 2022

To verify distributed tracing feature is correctly setup, this PR adds
an integration test for this feature.
In the process of writing the test, I discovered a goroutine leak due to
the TraceProvider not being closed. This PR fixs this issue as well

Closes #13814

To verify distributed tracing feature is correctly setup, this PR adds
an integration test for this feature.
In the process of writing the test, I discovered a goroutine leak due to
the TraceProvider not being closed. This PR fixs this issue as well.

Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com>
type tracingExporter struct {
exporter tracesdk.SpanExporter
opts []otelgrpc.Option
shutdown func(ctx context.Context)
Copy link
Member

Choose a reason for hiding this comment

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

The name shutdown is a little strange to me, if tracingExporter knows what it should do on close, why not to get the traceProvider added to the struct directly? Two choice:

  1. Add the traceProvider into the struct directly, and call te.traceProvider.Shutdown(ctx) directly on Close.
  2. Rename to cleanup so that the logic is agnostic to tracingExporter, instead it's just doing the cleanup task it's told.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the suggestion. I went with the first option

if err != nil {
return e, err
}
if tracingExporter == nil || len(opts) == 0 {
return e, fmt.Errorf("error setting up distributed tracing")
Copy link
Member

Choose a reason for hiding this comment

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

You intentionally removed this, does it mean that tracingExporter == nil || len(opts) == 0 will never be true if the returned err is nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's the intention. I noticed no code path would result in err == nil and either exporter nor opts would be nil

Copy link
Member

Choose a reason for hiding this comment

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

ack

Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com>
}
if te.provider != nil {
te.provider.Shutdown(ctx)
}
Copy link
Member

Choose a reason for hiding this comment

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

I am not quite confident on this. Have you considered the order of the shutdown? In other words, is there any potential issue when shutting down the exporter firstly? I just had a quick code review on the otl SDK, it seems that the provider callbacks the exporters; if we shutdown the exporter firstly, will it cause any potential temporary issue on the provider?

Have you thought about shutting down the provider firstly?

Please clarify this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From my understanding, if the exporter is shutdown first, the provider will either hit a timeout or a shutdown error. It would mean that some spans that hasn't been sent to the remote may be lost. Thank you for pointing it out. I changed it to shutdown the provider first.

@ptabor
Copy link
Contributor

ptabor commented Aug 29, 2022

Please run ./scripts/fix.sh to fix the mod tidy problems causing a Static Analysis to fail.

@ahrtr
Copy link
Member

ahrtr commented Sep 5, 2022

@VinozzZ There are lots of comment changes in this PR. Did you do it intentionally or they are just updated by IDE or any tool? If it's the former (intentionally did), please do it in a separate PR. If it's the latter, please revert the changes.

@VinozzZ
Copy link
Contributor Author

VinozzZ commented Sep 6, 2022

@VinozzZ There are lots of comment changes in this PR. Did you do it intentionally or they are just updated by IDE or any tool? If it's the former (intentionally did), please do it in a separate PR. If it's the latter, please revert the changes.

This is the change from running ./scripts/fix.sh . Just curious if the script makes changes based on some configs from the local dev machine?

Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com>
@VinozzZ VinozzZ force-pushed the add-integration-test-for-tracing branch from 64ae889 to 57206f9 Compare September 6, 2022 15:26
Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

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

LGTM

Thank you @VinozzZ

Copy link
Member

@spzala spzala left a comment

Choose a reason for hiding this comment

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

Thanks @VinozzZ lgtm. Defer to @ahrtr

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

Successfully merging this pull request may close these issues.

Add integration test for etcd tracing
4 participants