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

[WIP] Basic tedious instrumentation #211

Closed
wants to merge 1 commit into from

Conversation

kjvalencik
Copy link

Hi! We're currently working through New Relic instrumentation and MSSQL support is a must. This PR includes basic instrumentation.

However, it does not include any tests and may only work for specific versions of tedious. I mostly wanted to submit this to gauge interest and check to see if this might be something that is already on the road map.

Let me know if I'm the right track. Thanks!

@martinkuba
Copy link
Contributor

@kjvalencik Thanks for the PR.  MS SQL is currently not on our near-term road map, but we are open to adding this in. Our main challenge would be to provide full test coverage with integration tests, as we are not currently setup to run tests with MS SQL.  In the meantime, we are happy to help you with this PR, but we would have to rely on you to fully test it.

@StyleT
Copy link
Contributor

StyleT commented Mar 10, 2016

+1 for this PR

@kjvalencik
Copy link
Author

Working through the unit tests right now. Is there a preferred method of skipping integration tests because dependencies (e.g., MSSQL instance) can't be met?

Maybe guard with an environment variable?

@martinkuba
Copy link
Contributor

@kjvalencik We don't currently disable any tests based on environment (except versions of Node and modules). Tests take the DB config from this file
https://github.com/newrelic/node-newrelic/blob/master/test/lib/params.js

I would suggest that you add to this file for now, and we will probably want to update our test suite in general to skip tests that don't have the settings they need.

@hayes
Copy link
Contributor

hayes commented Mar 10, 2016

@gfguthrie
Copy link

@kjvalencik I've been working on expanding the start that you've made (though so far have only made changes directly relevant to my project), and I'm wondering if you use tedious directly in your project or if you use the node-mssql library and thus also if it makes sense to hook into it instead to also support the other drivers that node-mssql supports.

@kjvalencik
Copy link
Author

We mostly use tedious via Sequelize, but also use it with node-mssql. The best I can tell tedious is by far the most popular driver which, in my opinion, makes it a better target than node-mssql.

While we do use this fork in production, it only targets the features that Sequelize uses. I have been waiting for the new version of New Relic to land, which includes a plugins system so that this can be developed as a plugins instead of included in core before spending substantial time on it.

@martinkuba
Copy link
Contributor

@gfguthrie @kjvalencik I would encourage you to start using the beta now. Seeing people use it and getting feedback will expedite making it a general release. Also note that the main difference between the 1.x line and the 2.x beta is the new API and our datastore instrumentations using it - the rest of the agent is pretty much the same.

https://docs.newrelic.com/docs/agents/nodejs-agent/nodejs-agent-v20-instrumentation-api-beta

@gfguthrie
Copy link

gfguthrie commented Sep 18, 2018

Just in case anyone comes looking, this is what I ended up with to instrument tedious.callProcedure

// New Relic custom MSSQL SP instrumentation
newrelic.instrumentDatastore('tedious', function (shim, tedious) {
	shim.setDatastore('MSSQL');
	shim.setParser(sql => ({operation: sql, collection: 'sp'}));
  
	shim.recordQuery(tedious.Connection.prototype, 'callProcedure', {
		query: (shim, func, name, args) => args[0].sqlTextOrProcedure,
		callback: function (shim, func, name, segment, args) {
			args[0].callback = shim.bindSegment(args[0].callback, segment);
		}
	});
});

@kjvalencik
Copy link
Author

kjvalencik commented Sep 18, 2018

Thanks @gfguthrie. We will be open sourcing our tedious plugin soon. I'll be sure to include this! CC: @CKarper

@psvet
Copy link
Contributor

psvet commented Sep 19, 2018

@gfguthrie Thanks for the update! Due to the merge conflicts and how long it's been on the shelf, we're going to close this PR, but feel free to add some tests and submit an updated one in the future.

@psvet psvet closed this Sep 19, 2018
@CKarper
Copy link

CKarper commented Sep 19, 2018

https://github.com/ckarper/tedious-newrelic

Just require this lib, and you're gtg. Proper docs, etc forthcoming. I will integrate your source as well @gfguthrie . Thanks!

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.

7 participants