npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

inscriber

v0.0.6

Published

Trace and Span logger

Downloads

3

Readme

Inscriber

ES6 Basic Trace and Span Tracker. Use it to add some structure to your server logs.

Trace and Span Tracker

0.0.4 Basic Release

Implementation

const inscriber = require('inscriber');
const trace = new inscriber.trace(id, name);
const span = new inscriber.span(name, trace, traceId, tags);

Log Class

  • info(message)
  • success(message)
  • error(message)

Trace Class (extends Log)

  • init()
  • recieved()
  • completed()
  • failed()
  • inherited()
  • returnedg()

Span Class (extends Log)

  • init()
  • completed()
  • failed()

Simple example

Talking between two Express servers - in this example local testing on port 3000 and 3090.

Assume the first server is for a Bot and the second for an API.

Send custom headers X-Trace and Trace-Parent-ID.

// Server one on localhost:3000
const inscriber = require('inscriber');

app.get('/log', (req, res) => {
	// Server one
	const trace = new Log.trace('id-reference', 'Log Routing');
	const spanOne = new Log.span('Bot /log route', trace.name, trace.id);

	trace.init();
	span.init()
		.info('Route accessed')
		.info('Attempting to contact API');

	axios.get('http://localhost:3090/apilog', {
			headers: {
				'X-Trace': trace.name,
				'Trace-Parent-ID': trace.id
			}
		})
		.then(data => {
			const spanTwo = new Log.span('Bot /log data returned', trace.name, trace.id);

			span.info('Route return')
				.completed();
			trace.completed();
			spanTwo.completed();

			res.send('Success');
		})
		.catch(err => {
			span.failed();
			trace.failed();
			res.send('err');
		});

});

// Server two on localhost:3090
const inscriber = require('inscriber');

app.get('/log', function(req, res) {
	const trace = new inscriber.trace(req.get('Trace-Parent-ID'), req.get('X-Trace'));
	trace.inherited()
		.info('Trace id and name recieved from other server');
	const span = new inscriber.span('API /log route', trace.name, trace.id);
	res.send('Server is healthy');

	span.completed();
	trace.returned();
});

OUTPUT

# Server One
::TRACE [Log Routing] [Thu Jul 13 2017 17:00:29 GMT+1000 (AEST)]:: TRACE_INIT (id-reference) Log Routing
::SPAN [Log Routing] [Thu Jul 13 2017 17:00:29 GMT+1000 (AEST)]:: (Bot /log route): SPAN_INIT Bot /log route
::SPAN [Log Routing] [Thu Jul 13 2017 17:00:29 GMT+1000 (AEST)]:: (Bot /log route): Route accessed
::SPAN [Log Routing] [Thu Jul 13 2017 17:00:29 GMT+1000 (AEST)]:: (Bot /log route): Attempting to contact GraphQL
::SPAN [Log Routing] [Thu Jul 13 2017 17:00:29 GMT+1000 (AEST)]:: (Bot /log route): Route return
::SPAN [Log Routing] [Thu Jul 13 2017 17:00:29 GMT+1000 (AEST)]:: (Bot /log route): SPAN_COMPLETED Bot /log route
::TRACE [Log Routing] [Thu Jul 13 2017 17:00:29 GMT+1000 (AEST)]:: TRACE_COMPLETED (id-reference) Log Routing
::SPAN [Log Routing] [Thu Jul 13 2017 17:00:29 GMT+1000 (AEST)]:: (Bot /log data returned): SPAN_COMPLETED Bot /log data returned

# Server Two
::TRACE [Log Routing] [Thu Jul 13 2017 17:00:29 GMT+1000 (AEST)]:: TRACE_INHERITED (id-reference) Log Routing
::TRACE [Log Routing] [Thu Jul 13 2017 17:00:29 GMT+1000 (AEST)]:: Trace id and name recieved from other server
::SPAN [Log Routing] [Thu Jul 13 2017 17:00:29 GMT+1000 (AEST)]:: (API /log route): SPAN_COMPLETED API /log route
::TRACE [Log Routing] [Thu Jul 13 2017 17:00:29 GMT+1000 (AEST)]:: TRACE_RETURNED (id-reference) Log Routing