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

Export traces for eventshub in failed tests #368

Merged
merged 1 commit into from
Aug 3, 2022

Conversation

mgencur
Copy link
Contributor

@mgencur mgencur commented Aug 3, 2022

Changes

  • Introduce a new implementation of Emitter that will gather traces for all events in the given namespace when the test fails
  • Provide tracing.WithGatherer(t) that can be registered with the Environment when traces are supposed to be gathered
  • Export Spans from eventshub on the "sender" side automatically (no need to enable it by flags), similar to the "receiver" side. We export all the relevant information for the event: its Context and also the data.
  • Collect traces for the whole namespace when a test fails. This is done during env.Finish() phase of the Environment.
  • Instruction in readme on how to inspect/visualize traces

Example log from a failed test that shows gathering the traces:

logger.go:130: 2022-08-01T14:21:43.919+0200	DEBUG	milestone/emitter_log.go:73	ReceiverReadiness Test Finished	{"test": "TestEventsHubReceiverReadiness", "namespace": "test-remowtqp"}
    logger.go:130: 2022-08-01T14:21:43.919+0200	DEBUG	feature/feature.go:78	Feature state: {"name":"ReceiverReadiness","steps":[{"name":"Pre cache sender image","states":"Any","levels":"All","timing":"Setup"},{"name":"Deploy sink","states":"Any","levels":"All","timing":"Setup"},{"name":"Send event","states":"Any","levels":"All","timing":"Requirement"},{"name":"Event received","states":"Stable","levels":"MUST","timing":"Assert"}],"state":null,"refs":null}	{"test": "TestEventsHubReceiverReadiness"}
    logger.go:130: 2022-08-01T14:21:43.919+0200	INFO	milestone/emitter_tracing.go:104	Fetching traces for namespace test-remowtqp	{"test": "TestEventsHubReceiverReadiness"}
2022/08/01 14:21:44 Env variable ARTIFACTS not set. Using artifacts instead.
    logger.go:130: 2022-08-01T14:21:44.348+0200	INFO	milestone/emitter_tracing.go:119	Exporting trace into artifacts/traces/test-remowtqp.json	{"test": "TestEventsHubReceiverReadiness"}
    logger.go:130: 2022-08-01T14:21:44.355+0200	DEBUG	milestone/emitter_log.go:116	Finished: Failed	{"test": "TestEventsHubReceiverReadiness", "namespace": "test-remowtqp"}

This feature requires knative/pkg#2475 to be implemented because the eventshub sender Pod is shutdown immediately after the last event is sent. It means some traces might not be exported to Zipkin in time. The workaround for now is to send at least 2 events with a couple of seconds delay and adjust the test to count with extra events. I have a solution for this issue locally and will be sending a PR to knative/pkg shortly.

/kind enhancement

Fixes #367

Release Note


Docs


@knative-prow
Copy link

knative-prow bot commented Aug 3, 2022

@mgencur: The label(s) kind/<kind> cannot be applied, because the repository doesn't have them.

In response to this:

Fixes #367

Changes

  • Introduce a new implementation of Emitter that will gather traces for all events in the given namespace when the test fails
  • Provide tracing.WithGatherer(t) that can be registered with the Environment when traces are supposed to be gathered
  • Export Spans from eventshub on the "sender" side automatically (no need to enable it by flags), similar to the "receiver" side. We export all the relevant information for the event: its Context and also the data.
  • Collect traces for the whole namespace when a test fails. This is done during env.Finish() phase of the Environment.
  • Instruction in readme on how to inspect/visualize traces

This feature requires knative/pkg#2475 to be implemented because the eventshub sender Pod is shutdown immediately after the last event is sent. It means some traces might not be exported to Zipkin in time. The workaround for now is to send at least 2 events with a couple of seconds delay and adjust the test to count with extra events. I have a solution for this issue locally and will be sending a PR to knative/pkg shortly.

/kind

Fixes #

Release Note


Docs


Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@knative-prow knative-prow bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Aug 3, 2022
@mgencur mgencur force-pushed the eventshub_tracing branch from 0ac74d3 to b4d723b Compare August 3, 2022 09:03
@mgencur mgencur force-pushed the eventshub_tracing branch from b4d723b to 1a6d3cd Compare August 3, 2022 09:22
Copy link
Member

@pierDipi pierDipi left a comment

Choose a reason for hiding this comment

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

Thanks!

/lgtm
/approve

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Aug 3, 2022
@knative-prow
Copy link

knative-prow bot commented Aug 3, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mgencur, pierDipi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 3, 2022
@pierDipi
Copy link
Member

pierDipi commented Aug 3, 2022

It is stuck at

Pending — Not mergeable. Job Unit Test (discovery, knative-sandbox) has not succeeded.

we need something like this for this repository as well: knative/test-infra#3463

pierDipi added a commit to pierDipi/test-infra that referenced this pull request Aug 3, 2022
knative-prow bot pushed a commit to knative/test-infra that referenced this pull request Aug 3, 2022
@knative-prow knative-prow bot merged commit da2ce0e into knative-extensions:main Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gather traces for events sent by the framework
2 participants