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

tracing/tracingtest: deprecate Tracer and Span types #3375

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

AlexanderYastrebov
Copy link
Member

@AlexanderYastrebov AlexanderYastrebov commented Jan 14, 2025

Follow up on #684 (#684 (comment)) and
deprecate hand-rolled test tracer implementation in favour of
MockTracer added by #3322 that wraps github.com/opentracing/opentracing-go/mocktracer and waits for finished spans.

Fix MockTracer:

  • return MockSpan that has proper Tracer() implementation
  • return MockSpan wrappers from FinishedSpans
  • panic on timeout waiting for finished spans

Closes #2084
Updates #2104

Comment on lines -66 to -74
if len(tracer.RecordedSpans) == 0 {
t.Fatal("no span recorded...")
}
if tracer.RecordedSpans[0].Trace != traceContent {
t.Errorf("trace not found, got `%s` instead", tracer.RecordedSpans[0].Trace)
}
if len(tracer.RecordedSpans[0].Refs) == 0 {
t.Errorf("no references found, this is a root span")
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This tested tracer internals and not HTTP propagator or something.

@AlexanderYastrebov AlexanderYastrebov added the major moderate risk, for example new API, small filter changes that have no risk like refactoring or logs label Jan 14, 2025
@AlexanderYastrebov AlexanderYastrebov force-pushed the tracing/tracingtest/deprecate-tracer branch 5 times, most recently from f459e69 to bc966f4 Compare January 14, 2025 20:51
@AlexanderYastrebov AlexanderYastrebov added the bugfix Bug fixes and patches label Jan 14, 2025
@AlexanderYastrebov AlexanderYastrebov force-pushed the tracing/tracingtest/deprecate-tracer branch from bc966f4 to e9c9be7 Compare January 14, 2025 21:17
@AlexanderYastrebov AlexanderYastrebov added minor no risk changes, for example new filters and removed major moderate risk, for example new API, small filter changes that have no risk like refactoring or logs labels Jan 14, 2025

testCases := []struct {
name string
req *http.Request
tracer opentracing.Tracer
parentSpan opentracing.Span
parentSpan string
Copy link
Member Author

Choose a reason for hiding this comment

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

This change is because closing parent span created during test case setup after tracer.Reset() is wrong and does not work properly with MockTracer.

@AlexanderYastrebov AlexanderYastrebov force-pushed the tracing/tracingtest/deprecate-tracer branch from e9c9be7 to d86c1c8 Compare January 14, 2025 21:26
Follow up on #684 (#684 (comment)) and
deprecate hand-rolled test tracer implementation in favour of
MockTracer added by #3322 that wraps github.com/opentracing/opentracing-go/mocktracer
and waits for finished spans.

Fix MockTracer:
* return MockSpan that has proper Tracer() implementation
* return MockSpan wrappers from FinishedSpans
* panic on timeout waiting for finished spans

Closes #2084
Updates #2104

Signed-off-by: Alexander Yastrebov <[email protected]>
@AlexanderYastrebov AlexanderYastrebov force-pushed the tracing/tracingtest/deprecate-tracer branch from d86c1c8 to 331f035 Compare January 15, 2025 11:21
@AlexanderYastrebov AlexanderYastrebov marked this pull request as ready for review January 15, 2025 11:59
@MustafaSaber
Copy link
Member

👍

1 similar comment
@AlexanderYastrebov
Copy link
Member Author

👍

@AlexanderYastrebov AlexanderYastrebov merged commit 7c15e71 into master Jan 15, 2025
14 checks passed
@AlexanderYastrebov AlexanderYastrebov deleted the tracing/tracingtest/deprecate-tracer branch January 15, 2025 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Bug fixes and patches minor no risk changes, for example new filters
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor: mocktracer use
2 participants