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

Migrating compound extraction span link tests to weblog #3499

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

mhlidd
Copy link
Contributor

@mhlidd mhlidd commented Nov 19, 2024

Motivation

Currently, we test the results of compound extraction of inconsistent headers through parametric tests. However, using the parametric app does not truly reflect the behavior exhibited through automatic instrumentation, as we have to manually call extract on the headers passed in, create a span, and add the extracted context/span links to the span. This PR aims to migrate the parametric tests into weblog tests to remove the manual process of imitating this scenario, and have the system-tests represent what actually happens when we have compound extraction on a set of inconsistent headers.

Changes

Add 2 weblog scenarios that take in DD_TRACE_PROPAGATION_STYLE_EXTRACT with values of tracecontext -> datadog -> b3 and datadog -> tracecontext -> b3 respectively. The tests create a span through the make_distant_call endpoint and we verify that we get back a span that has the appropriate span links for different scenarios.

APMAPI-899

Workflow

  1. ⚠️ Create your PR as draft ⚠️
  2. Work on you PR until the CI passes (if something not related to your task is failing, you can ignore it)
  3. Mark it as ready for review
    • Test logic is modified? -> Get a review from RFC owner. We're working on refining the codeowners file quickly.
    • Framework is modified, or non obvious usage of it -> get a review from R&P team

🚀 Once your PR is reviewed, you can merge it!

🛟 #apm-shared-testing 🛟

Reviewer checklist

  • If PR title starts with [<language>], double-check that only <language> is impacted by the change
  • No system-tests internal is modified. Otherwise, I have the approval from R&P team
  • CI is green, or failing jobs are not related to this change (and you are 100% sure about this statement)
  • A docker base image is modified?
    • the relevant build-XXX-image label is present
  • A scenario is added (or removed)?

@mhlidd mhlidd changed the title initial test for compound extraction with span links Migrating compound extraction span link tests to weblog Nov 20, 2024
Copy link
Contributor

@mabdinur mabdinur left a comment

Choose a reason for hiding this comment

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

Left some nits overall the approach looks good to me

assert False


def retrieve_span_links(span):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we reuse the existing retrieve span links function. We could move the original implementation out of parametric.utils and add it to a common directory.

self.req = weblog.get("/make_distant_call", params={"url": "http://weblog:7777"}, headers=extract_headers)

def test_span_links_from_conflicting_contexts(self):
trace = [span for _, _, span in interfaces.library.get_spans(self.req, full_trace=True)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Here can we retrieve all spans with links. We can put an if statement in the list concatenation.

print(trace)
for span in trace:
links = retrieve_span_links(span)
if links != None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: There might be more than one span with span links. One with conflicting distributed tracing headers and the other with some other span relationship. I am wondering if we should check the trace id in the if statement. That way we can guard against false negatives.

@mhlidd mhlidd marked this pull request as ready for review November 21, 2024 23:55
@mhlidd mhlidd requested review from a team as code owners November 21, 2024 23:55
@mhlidd mhlidd requested review from Kyle-Verhoog, avara1986, smola and jandro996 and removed request for a team November 21, 2024 23:55
@mhlidd mhlidd requested review from zacharycmontoya, cbeauchesne, a team and mabdinur and removed request for a team November 21, 2024 23:55
@mhlidd mhlidd force-pushed the mhlidd/migrate_span_links_to_weblog branch from fb0d288 to cb9eca1 Compare November 22, 2024 00:11
@@ -205,3 +206,35 @@ def get_free_port():
except OSError:
port += 1
raise IOError("no free ports")


def retrieve_span_links(span):
Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure if this is the best place to this method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@robertomonteromiguel Do you have any suggestions on where helper functions should go? This is a function that I want to be accessible for both weblog and parametric tests.

@@ -105,6 +105,24 @@ def all_endtoend_scenarios(test_object):
doc="Test W3C trace style",
)

trace_propagation_style_w3c_datadog_b3 = EndToEndScenario(
Copy link
Collaborator

Choose a reason for hiding this comment

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

you should add the new scenarios here:. github/workflows/run-end-to-end.yml

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

Successfully merging this pull request may close these issues.

3 participants