Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@opencensus/exporter-zipkin

Package Overview
Dependencies
Maintainers
7
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opencensus/exporter-zipkin - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

34

build/src/zipkin.d.ts

@@ -16,4 +16,5 @@ /**

*/
import { Exporter, ExporterBuffer, ExporterConfig, RootSpan } from '@opencensus/core';
import { Exporter, ExporterBuffer, ExporterConfig, RootSpan, Span } from '@opencensus/core';
import { Logger } from '@opencensus/core';
export declare const MICROS_PER_MILLI = 1000;
export interface ZipkinExporterOptions extends ExporterConfig {

@@ -23,2 +24,24 @@ url?: string;

}
export interface TranslatedSpan {
traceId: string;
name: string;
id: string;
parentId?: string;
kind: string;
timestamp: number;
duration: number;
debug: boolean;
shared: boolean;
localEndpoint: {
serviceName: string;
};
annotations: Annotation[];
tags: {
[key: string]: string;
};
}
export interface Annotation {
timestamp?: number;
value?: string;
}
/** Zipkin Exporter manager class */

@@ -54,4 +77,11 @@ export declare class ZipkinTraceExporter implements Exporter {

*/
private translateSpan;
translateSpan(span: Span | RootSpan): TranslatedSpan;
/** Converts OpenCensus Attributes ans Status to Zipkin Tags format. */
private createTags;
/**
* Converts OpenCensus Annotation and MessageEvent to Zipkin Annotations
* format.
*/
private createAnnotations;
/**
* Send the rootSpans to zipkin service

@@ -58,0 +88,0 @@ * @param rootSpans RootSpan array

@@ -22,2 +22,10 @@ "use strict";

const url = require("url");
const STATUS_CODE = 'census.status_code';
const STATUS_DESCRIPTION = 'census.status_description';
const MESSAGE_EVENT_TYPE_TRANSLATION = {
0: 'UNSPECIFIED',
1: 'SENT',
2: 'RECEIVED'
};
exports.MICROS_PER_MILLI = 1000;
/** Zipkin Exporter manager class */

@@ -111,12 +119,50 @@ class ZipkinTraceExporter {

id: span.id,
parentId: span.parentSpanId,
kind: 'SERVER',
timestamp: span.startTime.getTime() * 1000,
duration: Math.round(span.duration * 1000),
// Zipkin API for span kind only accept
// (CLIENT|SERVER|PRODUCER|CONSUMER)
kind: span.kind === core_1.SpanKind.CLIENT ? 'CLIENT' : 'SERVER',
timestamp: span.startTime.getTime() * exports.MICROS_PER_MILLI,
duration: Math.round(span.duration * exports.MICROS_PER_MILLI),
debug: true,
shared: true,
localEndpoint: { serviceName: this.serviceName }
localEndpoint: { serviceName: this.serviceName },
tags: this.createTags(span.attributes, span.status),
annotations: this.createAnnotations(span.annotations, span.messageEvents)
};
if (span.parentSpanId) {
spanTraslated.parentId = span.parentSpanId;
}
return spanTraslated;
}
/** Converts OpenCensus Attributes ans Status to Zipkin Tags format. */
createTags(attributes, status) {
const tags = {};
for (const key of Object.keys(attributes)) {
tags[key] = String(attributes[key]);
}
tags[STATUS_CODE] = String(status.code);
if (status.message) {
tags[STATUS_DESCRIPTION] = status.message;
}
return tags;
}
/**
* Converts OpenCensus Annotation and MessageEvent to Zipkin Annotations
* format.
*/
createAnnotations(annotationTimedEvents, messageEventTimedEvents) {
let annotations = [];
if (annotationTimedEvents) {
annotations = annotationTimedEvents.map((annotation) => ({
timestamp: annotation.timestamp * exports.MICROS_PER_MILLI,
value: annotation.description
}));
}
if (messageEventTimedEvents) {
annotations.push(...messageEventTimedEvents.map((messageEvent) => ({
timestamp: messageEvent.timestamp * exports.MICROS_PER_MILLI,
value: MESSAGE_EVENT_TYPE_TRANSLATION[messageEvent.type]
})));
}
return annotations;
}
// TODO: review return of method publish from exporter interface - today is

@@ -123,0 +169,0 @@ // returning void

28

package.json
{
"name": "@opencensus/exporter-zipkin",
"version": "0.0.9",
"version": "0.0.10",
"description": "OpenCensus Zipkin Exporter allows the user to send collected traces with OpenCensus Node.js to Zipkin.",

@@ -9,3 +9,3 @@ "main": "build/src/index.js",

"scripts": {
"test": "nyc mocha build/test/**/*.js",
"test": "nyc ts-mocha -p ./tsconfig.json test/**/*.ts",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json",

@@ -17,3 +17,2 @@ "clean": "rimraf build/*",

"prepare": "npm run compile",
"pretest": "npm run compile",
"posttest": "npm run check"

@@ -40,2 +39,13 @@ },

],
"nyc": {
"extension": [
".ts",
".tsx"
],
"exclude": [
"**/*.d.ts",
"build/**/**/*.js"
],
"all": true
},
"publishConfig": {

@@ -48,16 +58,14 @@ "access": "public"

"@types/node": "^10.12.12",
"@types/semver": "^5.5.0",
"@types/uuid": "^3.4.3",
"codecov": "^3.1.0",
"gts": "^0.9.0",
"mocha": "^5.0.4",
"ncp": "^2.0.0",
"mocha": "^6.0.0",
"nock": "^10.0.0",
"nyc": "13.1.0",
"ts-node": "^7.0.1",
"nyc": "13.3.0",
"ts-mocha": "^6.0.0",
"ts-node": "^8.0.0",
"typescript": "~3.2.0"
},
"dependencies": {
"@opencensus/core": "^0.0.9"
"@opencensus/core": "^0.0.10"
}
}

@@ -1,6 +0,11 @@

# OpenCensus Zipkin Exporter for Node.js
# OpenCensus Zipkin Trace Exporter
[![Gitter chat][gitter-image]][gitter-url]
OpenCensus Zipkin Exporter allows the user to send collected traces with [OpenCensus Node.js](https://github.com/census-instrumentation/opencensus-node) to Zipkin.
OpenCensus Zipkin Trace Exporter allows the user to send collected traces with [OpenCensus Node.js](https://github.com/census-instrumentation/opencensus-node) to Zipkin.
[Zipkin](http://zipkin.io/) is a distributed
tracing system. It helps gather timing data needed to troubleshoot
latency problems in microservice architectures. It manages both the
collection and lookup of this data.
This project is still at an early stage of development. It's subject to change.

@@ -18,3 +23,3 @@

To use Zipkin as your exporter, first, download from any of the three available options on [Quickstart](https://zipkin.io/pages/quickstart.html): through Docker, on Java or manually compiling the source code. Tests were executed running Zipkin with Java, through the following commands on terminal:
To use [Zipkin](http://zipkin.io/) as your exporter, first, download from any of the three available options on [Quickstart](https://zipkin.io/pages/quickstart.html): through Docker, on Java or manually compiling the source code. Tests were executed running Zipkin with Java, through the following commands on terminal:

@@ -31,12 +36,12 @@ ```bash

```javascript
var tracing = require('@opencensus/nodejs');
var zipkin = require('@opencensus/exporter-zipkin');
const tracing = require('@opencensus/nodejs');
const zipkin = require('@opencensus/exporter-zipkin');
// Add your zipkin url (ex http://localhost:9411/api/v2/spans)
// and application name to the Zipkin options
var options = {
const options = {
url: 'your-zipkin-url',
serviceName: 'your-application-name'
}
var exporter = new zipkin.ZipkinTraceExporter(options);
const exporter = new zipkin.ZipkinTraceExporter(options);
```

@@ -70,2 +75,4 @@

```
## Viewing your traces:
Please visit the Zipkin UI endpoint http://localhost:9411

@@ -75,2 +82,3 @@ ## Useful links

- To checkout the OpenCensus for Node.js, visit: <https://github.com/census-instrumentation/opencensus-node>
- For Zipkin project at https://zipkin.io/
- For help or feedback on this project, join us on [gitter](https://gitter.im/census-instrumentation/Lobby)

@@ -77,0 +85,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc