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

Merged
merged 20 commits into from
Dec 5, 2024

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

tests/test_distributed.py Outdated Show resolved Hide resolved
tests/test_distributed.py Outdated Show resolved Hide resolved
tests/test_distributed.py Outdated Show resolved Hide resolved
@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
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 two more comments but overall this migration looks good to me. Good job!

assert link1["trace_id"] == 1
assert link1["span_id"] == 987654321
assert link1["attributes"] == {"reason": "terminated_context", "context_headers": "tracecontext"}
assert link1["tracestate"] == "dd=s:2;t.tid:1111111111111111,foo=1"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Assertion on tracestate could get tricky. I don't think every library sets this field in the same way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm this test isn't expected to pass as of now, and exists as a result of extracting the tests that are expected to pass versus the ones that test fields that do not have a spec currently. I think keeping it here is fine right now, as it is marked as missing_feature due to lack of spec.

assert link1.get("tracestate") == None


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.

nit: can we move utils.parametric.spec.trace.retrieve_span_links() to a new shared module (ex: utils.trace.py) so that we can re-use this function in weblog tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was addressed by @cbeauchesne above. If a new weblog test will use the function, we can move it out then?

Copy link
Collaborator

@cbeauchesne cbeauchesne left a comment

Choose a reason for hiding this comment

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

Some test are failing in the CI. But the rest is fine to me

@cbeauchesne
Copy link
Collaborator

CI failures are the msgpack issue ?

@cbeauchesne
Copy link
Collaborator

yes it is. Checking

@cbeauchesne
Copy link
Collaborator

You may have found a real issue in this tracer, the agent does not like either the data from the lib, here is its response :

msgp: attempted to decode type \"array\" with method for \"str\" at 21/0\\n

@cbeauchesne
Copy link
Collaborator

I've sent a message on slack to the java guild, let's wait for their response

@cbeauchesne
Copy link
Collaborator

cbeauchesne commented Nov 28, 2024

Waiting for #3587 to move forward. Once it's merged, we'll skip the test for spring-boot-native
https://datadoghq.atlassian.net/browse/APMAPI-928

Copy link
Collaborator

@cbeauchesne cbeauchesne left a comment

Choose a reason for hiding this comment

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

@cbeauchesne
Copy link
Collaborator

The java error has been fixed by DataDog/dd-trace-java#8036

@mhlidd mhlidd requested a review from cbeauchesne December 2, 2024 17:38
Copy link
Collaborator

@cbeauchesne cbeauchesne left a comment

Choose a reason for hiding this comment

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

Failures are not related.

@mhlidd mhlidd merged commit 8f7c6ee into main Dec 5, 2024
430 of 431 checks passed
@mhlidd mhlidd deleted the mhlidd/migrate_span_links_to_weblog branch December 5, 2024 18:20
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.

4 participants