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

Tracing: Add lttng support for tracing on Linux. #702

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,9 @@ jslint:

CPPLINT_EXCLUDE ?=
CPPLINT_EXCLUDE += src/node_dtrace.cc
CPPLINT_EXCLUDE += src/node_dtrace.cc
CPPLINT_EXCLUDE += src/node_lttng.cc
CPPLINT_EXCLUDE += src/node_root_certs.h
CPPLINT_EXCLUDE += src/node_lttng_tp.h
CPPLINT_EXCLUDE += src/node_win32_perfctr_provider.cc
CPPLINT_EXCLUDE += src/queue.h
CPPLINT_EXCLUDE += src/tree.h
Expand Down
14 changes: 14 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ parser.add_option('--with-dtrace',
dest='with_dtrace',
help='build with DTrace (default is true on sunos)')

parser.add_option('--with-lttng',
action='store_true',
dest='with_lttng',
help='build with Lttng (Only available to Linux)')
Copy link
Contributor

Choose a reason for hiding this comment

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

Can it default to 'on' on Linux, or will that break Linuxen that don't have LTTNG?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It cannot default to 'on' on Linux as the library won't be accessible to the compiler if its not installed.


parser.add_option('--with-etw',
action='store_true',
dest='with_etw',
Expand Down Expand Up @@ -524,6 +529,15 @@ def configure_node(o):
else:
o['variables']['node_use_dtrace'] = 'false'

# Enable Lttng if --with-lttng was defined. Use logic similar to
# ETW for windows. Lttng is only available on the Linux platform.
if flavor == 'linux':
o['variables']['node_use_lttng'] = b(options.with_lttng)
elif options.with_lttng:
raise Exception('lttng is only supported on Linux.')
else:
o['variables']['node_use_lttng'] = 'false'

# if we're on illumos based systems wrap the helper library into the
# executable
if flavor == 'solaris':
Expand Down
2 changes: 2 additions & 0 deletions lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ ClientRequest.prototype.aborted = undefined;

ClientRequest.prototype._finish = function() {
DTRACE_HTTP_CLIENT_REQUEST(this, this.connection);
LTTNG_HTTP_CLIENT_REQUEST(this, this.connection);
COUNTER_HTTP_CLIENT_REQUEST();
OutgoingMessage.prototype._finish.call(this);
};
Expand Down Expand Up @@ -386,6 +387,7 @@ function parserOnIncomingClient(res, shouldKeepAlive) {


DTRACE_HTTP_CLIENT_RESPONSE(socket, req);
LTTNG_HTTP_CLIENT_RESPONSE(socket, req);
COUNTER_HTTP_CLIENT_RESPONSE();
req.res = res;
res.req = req;
Expand Down
2 changes: 2 additions & 0 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ util.inherits(ServerResponse, OutgoingMessage);

ServerResponse.prototype._finish = function() {
DTRACE_HTTP_SERVER_RESPONSE(this.connection);
LTTNG_HTTP_SERVER_RESPONSE(this.connection);
COUNTER_HTTP_SERVER_RESPONSE();
OutgoingMessage.prototype._finish.call(this);
};
Expand Down Expand Up @@ -416,6 +417,7 @@ function connectionListener(socket) {

res.shouldKeepAlive = shouldKeepAlive;
DTRACE_HTTP_SERVER_REQUEST(req, socket);
LTTNG_HTTP_SERVER_REQUEST(req, socket);
COUNTER_HTTP_SERVER_REQUEST();

if (socket._httpMessage) {
Expand Down
2 changes: 2 additions & 0 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ Socket.prototype.end = function(data, encoding) {
stream.Duplex.prototype.end.call(this, data, encoding);
this.writable = false;
DTRACE_NET_STREAM_END(this);
LTTNG_NET_STREAM_END(this);

// just in case we're waiting for an EOF.
if (this.readable && !this._readableState.endEmitted)
Expand Down Expand Up @@ -1324,6 +1325,7 @@ function onconnection(err, clientHandle) {
socket.server = self;

DTRACE_NET_SERVER_CONNECTION(socket);
LTTNG_NET_SERVER_CONNECTION(socket);
COUNTER_NET_SERVER_CONNECTION(socket);
self.emit('connection', socket);
}
Expand Down
12 changes: 12 additions & 0 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
'variables': {
'v8_use_snapshot%': 'false',
'node_use_dtrace%': 'false',
'node_use_lttng%': 'false',
'node_use_etw%': 'false',
'node_use_perfctr%': 'false',
'node_has_winsdk%': 'false',
Expand Down Expand Up @@ -260,6 +261,14 @@
}
] ]
} ],
[ 'node_use_lttng=="true"', {
'defines': [ 'HAVE_LTTNG=1' ],
'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)' ],
'libraries': [ '-llttng-ust' ],
'sources': [
'src/node_lttng.cc'
],
} ],
[ 'node_use_mdb=="true"', {
'dependencies': [ 'node_mdb' ],
'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)' ],
Expand Down Expand Up @@ -450,6 +459,9 @@
[ 'node_use_dtrace=="false" and node_use_etw=="false"', {
'inputs': [ 'src/notrace_macros.py' ]
}],
['node_use_lttng=="false"', {
'inputs': [ 'src/nolttng_macros.py' ]
}],
[ 'node_use_perfctr=="false"', {
'inputs': [ 'src/perfctr_macros.py' ]
}]
Expand Down
8 changes: 8 additions & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
#include "node_dtrace.h"
#endif

#if defined HAVE_LTTNG
#include "node_lttng.h"
#endif

#include "ares.h"
#include "async-wrap.h"
#include "async-wrap-inl.h"
Expand Down Expand Up @@ -2871,6 +2875,10 @@ void LoadEnvironment(Environment* env) {
InitDTrace(env, global);
#endif

#if defined HAVE_LTTNG
InitLTTNG(env, global);
#endif

#if defined HAVE_PERFCTR
InitPerfCounters(env, global);
#endif
Expand Down
Loading