Repository navigation
Description
I'd like to enable the ember-cli instrumentation using the .env file from ember-cli-dotenv but it appears doing it that way sets the environment variable too late in the process. The init is set up here
Lines 6 to 14 in a473454
| let initInstrumentation; | |
| if (instrumentation.instrumentationEnabled()) { | |
| const heimdall = require('heimdalljs'); | |
| let initInstrumentationToken = heimdall.start('init'); | |
| initInstrumentation = { | |
| token: initInstrumentationToken, | |
| node: heimdall.current, | |
| }; | |
| } |
ember server I get the following error
➜ instrumentation-dotenv git:(master) ember server
No such instrumentation "init"
Error: No such instrumentation "init"
at Instrumentation._instrumentationFor (/Users/patocallaghan/src/me/instrumentation-dotenv/node_modules/ember-cli/lib/models/instrumentation.js:171:13)
at Instrumentation.stopAndReport (/Users/patocallaghan/src/me/instrumentation-dotenv/node_modules/ember-cli/lib/models/instrumentation.js:227:22)
at Promise.resolve.then (/Users/patocallaghan/src/me/instrumentation-dotenv/node_modules/ember-cli/lib/cli/cli.js:153:25)
at tryCatch (/Users/patocallaghan/src/me/instrumentation-dotenv/node_modules/rsvp/dist/rsvp.js:525:12)
at invokeCallback (/Users/patocallaghan/src/me/instrumentation-dotenv/node_modules/rsvp/dist/rsvp.js:538:13)
at /Users/patocallaghan/src/me/instrumentation-dotenv/node_modules/rsvp/dist/rsvp.js:606:14
at flush (/Users/patocallaghan/src/me/instrumentation-dotenv/node_modules/rsvp/dist/rsvp.js:2415:5)
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
My use case is I'd like to collect metrics, i.e. initial and rebuild times, from my team but would rather they didn't have to:
- set the
EMBER_CLI_INSTRUMENTATIONvar themselves - provide a script which they'd use instead of
ember serverwhich sets the var and callsember server.
I'd rather it configured by default i.e. turned on by some sort of config file.
I have a replication repo of the issue here https://github.com/patocallaghan/instrumentation-dotenv
I'm not tied to ember-cli-dotenv so if you have any suggestions how to achieve what I'm trying to do I'd appreciate it, or if you directions on how to fix the issue I'd be happy to put the PR together myself.
Output from ember version --verbose && npm --version && yarn --version:
ember-cli: 2.16.2
http_parser: 2.7.0
node: 7.10.1
v8: 5.5.372.43
uv: 1.11.0
zlib: 1.2.11
ares: 1.10.1-DEV
modules: 51
openssl: 1.0.2k
icu: 58.2
unicode: 9.0
cldr: 30.0.3
tz: 2016j
os: darwin x64
4.2.0
1.2.1
Activity
rwjblue commentedon Nov 9, 2017
The use case seems good to me. Not sure about the best path forward, but the first thing that jumps out at me is that the projects
.ember-clifile seems like the right place for this kind of thing...patocallaghan commentedon Nov 9, 2017
I was thinking of something like that myself. I'd be happy to attempt a PR to make the changes.
I guess two questions I have:
.ember-cliconfig file at the top of the file before the instrumentation init setup or should theinitinstrumentation setup be moved to within themodule.exports?.ember-cliconfig file within theutilities/instrumentation.jsfile as it contains all the other "enabling" logic?I'll see how I get on with it and if I have any questions I'll ping on a PR or jump into #dev-ember-cli.
twokul commentedon Nov 11, 2017
@patocallaghan I think it might reasonable to move this code within
module.exports. That way we would be able to access.ember-clifile and enable/disable instrumentation. All therequires in the file are "lazy" by default to optimize for a boot performance.patocallaghan commentedon Nov 12, 2017
Thanks for the guidance @twokul. I'll work on this and ping you guys when ready. 🙇
hjdivad commentedon Nov 14, 2017
@twokul not quite following your suggestion. Measuring cost of
requireing modules is one of the main points of startinginitinstrumentation that early.twokul commentedon Nov 14, 2017
@hjdivad hm, makes sense. I was thinking of how to provide access to
.ember-cli. also, if we want to measure the cost ofrequireing modules, wouldn't we want to place instrumentation here?hjdivad commentedon Nov 14, 2017
@twokul we have much more difficult compatibility requirements with
bin/emberso we leave it alone. A consequence is that there's a small bit of startup that isn't measured duringinit, but we keep it as small as we can (basically as much as possible without requiring changes tobin/ember).can't we have instrumentationEnabled read
.ember-cli(perhaps indirectly via some other API) and cache the result in module scope?@twokul @rwjblue @patocallaghan thoughts?
hjdivad commentedon Nov 14, 2017
Okay I see that I'm just echoing @patocallaghan's earlier suggestion ^_^
Anyway this seems good to me (maybe with module scope caching as I think this function is called a few times).
patocallaghan commentedon Nov 15, 2017
@hjdivad @twokul ok thanks, so I'll go with the approach of checking the
.ember-clifrom withinutilities/instrumentationEnabled.I'll probably need to move the following logic to its own model/module to remove duplication from both locations.
@hjdivad that's what you were thinking of saying
perhaps indirectly via some other API?hjdivad commentedon Nov 15, 2017
yes exactly
patocallaghan commentedon Apr 12, 2018
Closing as I shipped the ability to turn this on using
.ember-cliin #7491