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

chore: add support for hapi 18. #286

Merged
merged 4 commits into from
Jul 31, 2019

Conversation

aorinevo
Copy link
Contributor

@aorinevo aorinevo commented Jul 1, 2019

CHANGE LOG

  • add support for hapi 18 by adding new scoped package name to list of instrumentations in lib/instrumentations.js

INTERNAL LINKS

NOTES

Tests

  • Security:
  • Versioned:
    • Need more unit tests to cover @hapi/hapi similar to pre/post hapi 17 unit tests although much more lightweight.

ghost
ghost previously approved these changes Jul 1, 2019
@aorinevo
Copy link
Contributor Author

aorinevo commented Jul 2, 2019

@NatalieWolfe, @psvet: Any feedback on this PR? :)

@lykkin
Copy link
Contributor

lykkin commented Jul 2, 2019

Hey @aorinevo, thanks for the PR. In order for this to get shipped, I'd like to see testing at least in parity with the versions of hapi <18. This can be done by adjusting the versions the versioned tests will run on here. This respects the usual version range syntax that npm expects.

There will also need to be some code changes for how hapi is being loaded (not the only place, but many of the tests go through this load path). This will test the new version up to parity with the older versions. It'll miss any new features, and test any deprecated/removed features (which will hopefully cause some test failures, but still something to be weary of).

@aorinevo
Copy link
Contributor Author

aorinevo commented Jul 7, 2019

With v18 of hapi, request.parameters.* is not respected when passed in attributes.include array. That is, when present, url parameters are not populated in attributes object as request.parameters.{key}, where key is a url parameter.

For example,

    server.route({
      method: 'GET',
      path: '/test/{id}/',
      handler: function(request, reply) {
        // request.params.id = 1337
        t.ok(agent.getTransaction(), 'transaction is available')
        return { status: 'ok' }
      }
    })

    agent.on('transactionFinished', function(tx) {
      var attributes = tx.trace.attributes.get(DESTINATIONS.TRANS_TRACE)
      // attributes['request.parameters.id'] is undefined
    })

    server.start().then(function() {
      port = server.info.port
      request( 'http://localhost:' + port + '/test/1337/');
    })

I couldn't Identify the root cause of why this is failing for hapi 18 but not hapi 17.

Any thoughts?

Notes

@aorinevo
Copy link
Contributor Author

aorinevo commented Jul 7, 2019

Resolved issue above.

The root cause is a pathing issue with the new scope for Hapi v18. That is, files were attempted to be loaded from instrumentation/@hapi/hapi where files actually live in instrumentations/hapi.

One way to resolve this issue is to copy over the files to the new path.

@aorinevo
Copy link
Contributor Author

aorinevo commented Jul 7, 2019

I'm thinking we should have a separate test folder for hapi 18.

Thoughts?

@aorinevo
Copy link
Contributor Author

aorinevo commented Jul 7, 2019

@lykkin, got the tests running and passing for Hapi 18.

I took a decision to copy hapi 17 unit tests to another directory for hapi-18 and rename hapi-post-17 to hapi-post-17-pre-18.

Let me know what you think.

@aorinevo
Copy link
Contributor Author

aorinevo commented Jul 9, 2019

One resolution is to copy over files to new path.

Instead, created /lib/instrumentation/@hapi/hapi.js which exports require('../hapi') and eliminates the need to copy over any files.

Copy link
Contributor

@lykkin lykkin left a comment

Choose a reason for hiding this comment

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

@aorinevo Thanks for taking the time to update the tests! It mostly looks good, just a nit and a couple questions.

Nit: hapi-post-17-pre-18 can be renamed to hapi-17 for clarity.
Question 1: The versions being tested don't cover the first two minor releases of v18, is that intended?
Question 2: This PR brings the hapi v18 support up to parity with the older versions of hapi, but ignores any possible new functionality. Are there any features/changes that might be important to support in v18 that would be worth documenting as TODO?

test/versioned/hapi/hapi-post-18/package.json Outdated Show resolved Hide resolved
@aorinevo
Copy link
Contributor Author

aorinevo commented Jul 9, 2019

Nit: hapi-post-17-pre-18 can be renamed to hapi-17 for clarity.
Question 1: The versions being tested don't cover the first two minor releases of v18, is that intended?
Question 2: This PR brings the hapi v18 support up to parity with the older versions of hapi, but ignores any possible new functionality. Are there any features/changes that might be important to support in v18 that would be worth documenting as TODO?

Thanks for the review @lykkin!

  • I changed hapi-post-17-pre-18 to hapi-17.
  • Changed test version range from >=18.3.1 to ^18.3.1.
  • Added a link to the release notes for Hapi 18. I'll review those more closely to see if there is anything worth documenting.

Is this sufficient to move forward with the PR?

@lykkin
Copy link
Contributor

lykkin commented Jul 9, 2019

@aorinevo Yep! Looks like everything is in order at this point. I'll open this up as a PR against our internal repo and we can get it out in the next couple of releases.

Thanks again for putting all this together!

@mattcphillips
Copy link

Just found this PR after troubleshooting the same issue for a while. Thanks for doing this! Do you have a rough estimate of when this might get merged and published? It'd be really great to have this fixed.

@aorinevo
Copy link
Contributor Author

aorinevo commented Jul 22, 2019

Hi @mattcphillips, this should be going out in the next couple of releases, although no set date has been shared.

In the interim, you might want to consider creating a scoped version of this fork or installing off of a github url. If the latter, I would recommend forking first and installing off of that.

We decided to go with a private scoped version of this fork for stability and security reasons.

Hope this helps :)

@astormnewrelic astormnewrelic merged commit 5ff6069 into newrelic:master Jul 31, 2019
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