Skip to content

Backward compatibility with svc target and dest resource#7925

Merged
lahsivjar merged 11 commits intomainfrom
7734_backward_compatibility
May 18, 2022
Merged

Backward compatibility with svc target and dest resource#7925
lahsivjar merged 11 commits intomainfrom
7734_backward_compatibility

Conversation

@lahsivjar
Copy link
Copy Markdown
Contributor

@lahsivjar lahsivjar commented Apr 21, 2022

Motivation/summary

  1. Deprecate span.context.destination.service.resource
  2. Infer span.context.service.target.{type, name} from span.context.destination.service.resource if the former not provided

Full spec list available at elastic/apm#627

Checklist

How to test these changes

Case 1

  1. Send span.context.service.target.{type, name} via the intake API
  2. Observe the generated span documents to contain service.target.name and service.target.type values

Case 2

  1. Send span.context.destination.service.resource via the intake API along with span.context.service.target.{type, name}
  2. Observe the generated span documents to contain service.target.name and service.target.type values as passed via the intake API

Case 3

  1. Send span.context.destination.service.resource via the intake API WITHOUT span.context.service.target.{type, name} in 3 formats via 3 separate requests, example:
    • postgres/testdb
    • postgres
    • localhost:8080
  2. Observe the generated span document to contain service.target.name and service.target.type values based on the spec. Example based on point 1:
    • target.type = postgres and target.name = testdb
    • target.type = postgres
    • target.type = "" and target.name = localhost:8080

Related issues

Closes #7734

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Apr 21, 2022

This pull request does not have a backport label. Could you fix it @lahsivjar? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-7.x is the label to automatically backport to the 7.x branch.
  • backport-7./d is the label to automatically backport to the 7./d branch. /d is the digit

NOTE: backport-skip has been added to this pull request.

@mergify mergify bot added the backport-skip Skip notification from the automated backport with mergify label Apr 21, 2022
@ghost
Copy link
Copy Markdown

ghost commented Apr 21, 2022

💔 Tests Failed

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-05-18T07:57:30.822+0000

  • Duration: 28 min 58 sec

Test stats 🧪

Test Results
Failed 2
Passed 3982
Skipped 13
Total 3997

Test errors 2

Expand to view the tests failures

Build and Test / System and Environment Tests / Test_warmup/16_agent_[100_1000_100000]_events – github.com/elastic/apm-server/systemtest/benchtest
    Expand to view the error details

     Failed 
    

    Expand to view the stacktrace

     === RUN   Test_warmup/16_agent_[100_1000_100000]_events
        main_test.go:89: 
            	Error Trace:	main_test.go:89
            	Error:      	Received unexpected error:
            	            	13 errors: context deadline exceeded; context deadline exceeded; context deadline exceeded; context deadline exceeded; context deadline exceeded; context deadline exceeded; context deadline exceeded; context deadline exceeded; context deadline exceeded; context deadline exceeded; context deadline exceeded; context deadline exceeded; context deadline exceeded
            	Test:       	Test_warmup/16_agent_[100_1000_100000]_events
        --- FAIL: Test_warmup/16_agent_[100_1000_100000]_events (80.89s)
     
    

Build and Test / System and Environment Tests / Test_warmup – github.com/elastic/apm-server/systemtest/benchtest
    Expand to view the error details

     Failed 
    

    Expand to view the stacktrace

     === RUN   Test_warmup
    --- FAIL: Test_warmup (84.58s)
     
    

Steps errors 1

Expand to view the steps failures

Run Linux tests
  • Took 15 min 19 sec . View more details here
  • Description: ./.ci/scripts/linux-test.sh

🤖 GitHub comments

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

  • /test : Re-trigger the build.

  • /hey-apm : Run the hey-apm benchmark.

  • /package : Generate and publish the docker images.

  • /test windows : Build & tests on Windows.

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

@lahsivjar lahsivjar force-pushed the 7734_backward_compatibility branch from b8366d1 to c7ec339 Compare April 21, 2022 05:36
@lahsivjar
Copy link
Copy Markdown
Contributor Author

/test

@ghost
Copy link
Copy Markdown

ghost commented Apr 28, 2022

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (42/42) 💚
Files 91.878% (181/197) 👍
Classes 93.392% (424/454) 👍
Methods 89.238% (1078/1208) 👍 0.009
Lines 76.915% (13071/16994) 👍 0.13
Conditionals 100.0% (0/0) 💚

@lahsivjar lahsivjar force-pushed the 7734_backward_compatibility branch from c7ec339 to 35a7111 Compare May 11, 2022 06:57
@lahsivjar
Copy link
Copy Markdown
Contributor Author

/test

@lahsivjar lahsivjar force-pushed the 7734_backward_compatibility branch from 35a7111 to 05c369f Compare May 11, 2022 08:12
@lahsivjar lahsivjar force-pushed the 7734_backward_compatibility branch from 05c369f to 2546636 Compare May 11, 2022 09:01
@lahsivjar lahsivjar marked this pull request as ready for review May 11, 2022 09:33
@lahsivjar lahsivjar requested review from a team and SylvainJuge May 11, 2022 09:34
Copy link
Copy Markdown
Contributor

@stuartnelson3 stuartnelson3 left a comment

Choose a reason for hiding this comment

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

looks good! could you add a unit test to verify this is being called and doing the right thing within the mapping code path?

Copy link
Copy Markdown
Member

@SylvainJuge SylvainJuge left a comment

Choose a reason for hiding this comment

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

LGTM on my side, definitely seems to fit the spec. +100 on adding automated tests for that as this kind of mapping tend to break easily over time. As I'm not go-fluent and very familiar with apm-server codebase, don´t block merging this PR on my approval.

I would be able to validate this with an agent once #7924 is merged.

@SylvainJuge
Copy link
Copy Markdown
Member

In the Case 3, when not sending the new fields, for the last case, on top of checking that target.name = localhost:8080, we need to check that target.type = "" (empty string). This is important as it allows the UI to query on target.{name,type} and use the empty target.type as an indicator to use the resource for display (might be covered in elastic/kibana#131923)

This should also apply to the general case where the resource can't be parsed to any known format, in this case the field target.type should be set to an empty value.

Copy link
Copy Markdown
Contributor

@marclop marclop left a comment

Choose a reason for hiding this comment

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

I'm also in favor to adding some tests here to ensure it behaves as expected.

Comment thread model/modeldecoder/v2/decoder.go Outdated
Comment thread model/modeldecoder/v2/decoder.go Outdated
Comment thread model/modeldecoder/v2/decoder.go Outdated
Comment thread model/modeldecoder/v2/decoder.go Outdated
Copy link
Copy Markdown
Contributor

@marclop marclop left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for all the changes

@marclop
Copy link
Copy Markdown
Contributor

marclop commented May 17, 2022

Mind adding a changelog entry as well? It seems that's the only thing missing.

@lahsivjar
Copy link
Copy Markdown
Contributor Author

Mind adding a changelog entry as well? It seems that's the only thing missing.

@marclop Added changelog entry

Copy link
Copy Markdown
Contributor

@stuartnelson3 stuartnelson3 left a comment

Choose a reason for hiding this comment

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

looks good!

@lahsivjar lahsivjar enabled auto-merge (squash) May 18, 2022 07:07
@lahsivjar
Copy link
Copy Markdown
Contributor Author

/test

@lahsivjar lahsivjar disabled auto-merge May 18, 2022 09:18
@lahsivjar
Copy link
Copy Markdown
Contributor Author

lahsivjar commented May 18, 2022

Failing tests are flaky, merging based on this comment

@stuartnelson3
Copy link
Copy Markdown
Contributor

tested with d920cdd

case 1:

# cat doc1.json | jq .span
{
  "duration": {
    "us": 32592
  },
  "name": "GET /api/types",
  "id": "1234abcdef567895",
  "type": "request"
}

# cat doc1.json | jq .service.target
{
  "name": "myname",
  "type": "abc123"
}

Is this correct? The test case says the data should be available under span.service.target.*, but it's actually under _source.service.target*. Not sure if you meant _source to represent the span document data, or if it's to be nested under span within the document.

case 2: same question; assuming this is correct then 👌

case 3: same question; assuming this is correct then 👌

@lahsivjar
Copy link
Copy Markdown
Contributor Author

@stuartnelson3 You are correct, it should be _source.service.target.*, I have updated the summary. Thanks for the tests.

@stuartnelson3
Copy link
Copy Markdown
Contributor

cool, then 👍 confirmed

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

Labels

backport-skip Skip notification from the automated backport with mergify

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backend dependencies granularity: keep backwards compatibility

5 participants