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

fix: mark spans representing calls to external services as exit spans #1317

Merged
merged 9 commits into from
Sep 23, 2022

Conversation

kruskall
Copy link
Member

Exit spans are spans that describe a call to an external service, such as an outgoing HTTP request or a call to a database.

Marking a span as an exit span also triggers service target fields and destination fields inference.
Update tests to reflect the new fields.

Disable compression in some tests as exit spans can be aggregated based on certain fields, leading to unexpected results.

Additionally, make sure exit spans are not being used as parents of other spans as that would cause the spans to be dropped.

Closes #1315

Exit spans are spans that describe a call to an external service,
such as an outgoing HTTP request or a call to a database.

Marking a span as an exit span also triggers service target fields
and destination fields inference.
Update tests to reflect the new fields.

Disable compression in some tests as exit spans can be aggregated
based on certain fields, leading to unexpected results.

Additionally, make sure exit spans are not being used as parents of
other spans as that would cause the spans to be dropped.
@apmmachine
Copy link
Contributor

apmmachine commented Sep 20, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-09-23T13:23:02.089+0000

  • Duration: 50 min 26 sec

Test stats 🧪

Test Results
Failed 0
Passed 8554
Skipped 201
Total 8755

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • run benchmark tests : Run the benchmark test.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@kruskall
Copy link
Member Author

/test

Copy link
Member

@axw axw left a comment

Choose a reason for hiding this comment

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

Thanks, this is great. Just a few questions.

module/apmhttp/clienttrace.go Outdated Show resolved Hide resolved
module/apmhttp/client.go Outdated Show resolved Hide resolved
}
assert.Equal(t, dsnInfo.Address, span.Context.Destination.Address)
assert.Equal(t, dsnInfo.Port, span.Context.Destination.Port)
assert.Equal(t, dsnInfo.User, span.Context.Destination.Service.Name)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assert.Equal(t, dsnInfo.User, span.Context.Destination.Service.Name)
assert.Equal(t, dsnInfo.Database, span.Context.Destination.Service.Name)

Right?

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 is actually destination service name, the old deprecated field. It should use the driver name.

kruskall and others added 3 commits September 22, 2022 02:24
this was not a service target field but the old deprecated
destination service name.
The field value is expected to be the driver name.

Update the test to reflect what the implementation is doing.
trace request are now non-exit spans while the parent span is always
an exit span.
@kruskall
Copy link
Member Author

This uncovered another bug with the agent which is not respecting the spec.

Blocked by #1320

Copy link
Member

@axw axw left a comment

Choose a reason for hiding this comment

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

Thanks for the changes! LGTM, modulo the httptrace issue you uncovered.

@kruskall kruskall removed the blocked label Sep 23, 2022
@kruskall
Copy link
Member Author

This uncovered another bug with the agent which is not respecting the spec.

Blocked by #1320

PR merged. Unblocking

Copy link
Member

@axw axw left a comment

Choose a reason for hiding this comment

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

The driver name is changing during integration tests so we can't hardcode
sqlite3.
Update the test to pass the driver name from the testcase and compare it to the
expected result.
@apmmachine
Copy link
Contributor

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (59/59) 💚
Files 99.346% (152/153) 👍
Classes 96.275% (336/349) 👍
Methods 90.31% (960/1063) 👍 0.094
Lines 82.271% (11202/13616) 👍 0.11
Conditionals 100.0% (0/0) 💚

@kruskall kruskall merged commit 2f08f57 into elastic:main Sep 23, 2022
@kruskall kruskall deleted the fix/exit-spans branch September 23, 2022 17:30
@axw axw self-assigned this Oct 13, 2022
@axw axw added the test-plan label Oct 13, 2022
@axw
Copy link
Member

axw commented Oct 13, 2022

There's a few cases where we're not marking spans as exit spans, and I found a panic related to ending a child of an exit span. I'll open a PR.

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

Successfully merging this pull request may close these issues.

Spans representing calls to external services are not being marked as exit spans
3 participants