# @skbkontur/span-aggregator-client

> Клиет для спанагрегатора

Latest version **0.2.1** (published 2017-12-27) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @skbkontur/span-aggregator-client
pnpm add @skbkontur/span-aggregator-client
yarn add @skbkontur/span-aggregator-client
bun add @skbkontur/span-aggregator-client
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2017-12-27 |
| First published | 2017-10-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+4 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | ubitso4, wkich, t1mmaas, tihonove |

## Links

- npm: https://www.npmjs.com/package/@skbkontur/span-aggregator-client
- Repository: https://git.skbkontur.ru/portal/Node.SpanAggregatorClient
- npm.io page: https://npm.io/package/@skbkontur/span-aggregator-client

## Dependencies (1)

- [nanoid](https://npm.io/package/nanoid.md) ^0.2.2

## Recent versions

- 0.2.1 (latest) — 2017-12-27
- 0.2.0 — 2017-11-13
- 0.1.0 — 2017-10-27

## README

## Клиент для формирования трассировок

Для того чтобы добавить в приложение отправку серверных спанов необходимо добавить middleware из примера ниже в поток выполнения.


```javascript
const SpanAggregatorClient = require('@skbkontur/span-aggregator-client')
const Span = require('@skbkontur/span-aggregator-client/lib/Span')

const spanAggregatorClient = new SpanAggregatorClient({
//  hostname?: string,
//  port?: number,
//  path?: string,
//  clientIdentity?: string,
//  clientHost?: string
})

const { HEADERS } = Span

app.use(async function trace({ state, request }, next) {
  const spanId = request.headers[HEADERS.spanId]
  const parentSpanId = request.headers[HEADERS.parentSpanId]
  const traceId = request.headers[HEADERS.traceId]

  const span = new Span({ spanId, parentSpanId, traceId })
  state.span = span

  await next()

  spanAggregatorClient.send(span.close())
})
```

Настройки по умолчанию для клиента
```
hostname: 'vm-ke-dtrace1.dev.kontur.ru',
port: 30001,
path: '/spanaggr/saveSpans',
clientHost: '10.34.0.122',
clientIdentity: 'SpanAggrNodeClient'
```

Для того чтобы отправлять клиентские спаны необходимо передать инстанс клиента в конструктор `@skbkontur/cluster-client`

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