# inscriber

> Trace and Span logger

Latest version **0.0.6** (published 2017-07-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install inscriber
pnpm add inscriber
yarn add inscriber
bun add inscriber
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2017-07-13 |
| First published | 2017-07-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Dennis O'Keeffe |
| Maintainers | okeeffed |
| Keywords | trace, log, span |

## Links

- npm: https://www.npmjs.com/package/inscriber
- Repository: https://github.com/okeeffed/inscriber
- Homepage: https://github.com/okeeffed/inscriber#readme
- Issues: https://github.com/okeeffed/inscriber/issues
- npm.io page: https://npm.io/package/inscriber

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.0.6 (latest) — 2017-07-13
- 0.0.5 — 2017-07-13
- 0.0.4 — 2017-07-13
- 1.0.4 — 2017-07-13
- 1.0.3 — 2017-07-13
- 1.0.2 — 2017-07-13
- 1.0.1 — 2017-07-13
- 1.0.0 — 2017-07-13

## 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`.

```javascript
// 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
```

---
_Source: https://npm.io/package/inscriber · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
