Custom Segments
Monitor custom code blocks in your nodejs application.
Last updated
Monitor custom code blocks in your nodejs application.
Last updated
Just a few lines of code are needed:
This will produce a new segment in the timeline:
inspector.addSegment()
return a Promise. See the Working with Promise section below to learn more.
As showed in the example above a new segment is built with three input parameters:
Parameter | Required | Description |
callback | YES | The code block you want keep under real-time monitoring |
type | YES | This is the master category of your segments |
label | NO | Human readable label or specific task name that will be showed inside the timeline in your Inspector dashboard. If it isn't provided |
Think about how database queries is reported. That's one master category like mysql
but each query has its own custom label that simply is an extract of the sql code executed for a better timeline consultation.
mysql: master type
select * from table...: label
In this way you can mark toghether the statements related to a specific task using something like csv-export
as type parameter and use the filename
as label for each statement of this type.
What you return from your callback will be returned back by addSegment()
method.
inspector.addSegment()
return a Promise. If you want wait the execution of the callback you need to use async/await construct or then/catch.
If you need to report some contextual information, the new segment will be injected as callback parameter: