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

@uptrace/core

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uptrace/core - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

7

build/src/client.d.ts

@@ -1,2 +0,2 @@

import { TracerProvider, Attributes } from '@opentelemetry/api';
import { TracerProvider, Span, Attributes } from '@opentelemetry/api';
import { Tracer, TracerConfig } from '@opentelemetry/tracing';

@@ -10,9 +10,10 @@ import { Config } from './config';

constructor(cfg: Config);
close(): void;
close(): Promise<void>;
getProvider(): TracerProvider;
getTracer(name: string, version?: string, config?: TracerConfig): Tracer;
reportException(err: Error | string, attrs?: Attributes): void;
traceUrl(span: Span): string;
private _internalTracer;
}
export declare function createClient(cfg?: Config): Client;
export declare function createClient(cfg?: Partial<Config>): Client;
//# sourceMappingURL=client.d.ts.map

@@ -16,2 +16,7 @@ "use strict";

}
if (!this._cfg.dsn) {
console.error('uptrace: UPTRACE_DSN is empty or missing' +
' (to hide this message, use UPTRACE_DISABLED=True)');
this._cfg.disabled = true;
}
var exporter = new exporter_1.Exporter(cfg);

@@ -26,3 +31,3 @@ this._bsp = new tracing_1.BatchSpanProcessor(exporter, {

Client.prototype.close = function () {
this._bsp.shutdown();
return this._bsp.shutdown();
};

@@ -40,2 +45,5 @@ Client.prototype.getProvider = function () {

if (attrs === void 0) { attrs = {}; }
if (this._cfg.disabled) {
return;
}
var startedSpan = false;

@@ -61,2 +69,8 @@ var tracer = this._internalTracer();

};
Client.prototype.traceUrl = function (span) {
var u = this._cfg.dsnURL;
var host = u.host.slice(4);
var traceId = span.context().traceId;
return u.protocol + "//" + host + u.pathname + "/search?q=" + traceId;
};
Client.prototype._internalTracer = function () {

@@ -73,2 +87,13 @@ if (!this._tracer) {

if (cfg === void 0) { cfg = {}; }
if (cfg.dsn) {
try {
cfg.dsnURL = new URL(cfg.dsn);
}
catch (err) {
throw new Error("uptrace: can't parse dsn: " + err.message);
}
}
if (!cfg.provider) {
throw new Error('uptrace: provider is required');
}
if (!cfg.filters) {

@@ -75,0 +100,0 @@ cfg.filters = [];

@@ -11,5 +11,6 @@ import { Sampler } from '@opentelemetry/api';

disabled?: boolean;
filters?: SpanFilter[];
provider?: BasicTracerProvider;
dsnURL: URL;
filters: SpanFilter[];
provider: BasicTracerProvider;
}
//# sourceMappingURL=config.d.ts.map

@@ -6,15 +6,12 @@ "use strict";

var core_1 = require("@opentelemetry/core");
var api_1 = require("@opentelemetry/api");
var Exporter = /** @class */ (function () {
function Exporter(cfg) {
this._endpoint = '';
this._headers = {};
this._cfg = cfg;
if (!cfg.dsn) {
throw new Error('uptrace: dsn is required');
if (this._cfg.disabled) {
return;
}
var u;
try {
u = new URL(cfg.dsn);
}
catch (err) {
throw new Error("uptrace: can't parse dsn: " + err.message);
}
var u = this._cfg.dsnURL;
this._endpoint = u.protocol + "//" + u.host + "/api/v1/tracing" + u.pathname + "/spans";

@@ -40,3 +37,3 @@ this._headers = {

if (this._cfg.disabled) {
resultCallback(core_1.ExportResult.SUCCESS);
resultCallback({ code: core_1.ExportResultCode.SUCCESS });
return;

@@ -71,7 +68,14 @@ }

})
.then(function () {
// resp: Response
.then(function (resp) {
if (resp.status !== 200) {
resp.json().then(function (json) {
console.log(json);
});
}
})
.catch(function (error) {
console.log('uptrace send failed', error);
})
.finally(function () {
resultCallback(core_1.ExportResult.SUCCESS);
resultCallback({ code: core_1.ExportResultCode.SUCCESS });
});

@@ -92,5 +96,6 @@ };

name: span.name,
kind: span.kind,
kind: expoKind(span.kind),
startTime: core_1.hrTimeToTimeStamp(span.startTime),
endTime: core_1.hrTimeToTimeStamp(span.endTime),
statusCode: expoStatus(span.status.code),
attrs: span.attributes,

@@ -102,2 +107,5 @@ events: expoEvents(span.events),

};
if (span.status.message) {
expo.statusMessage = span.status.message;
}
return expo;

@@ -129,2 +137,26 @@ }

}
function expoKind(kind) {
switch (kind) {
case api_1.SpanKind.SERVER:
return 'server';
case api_1.SpanKind.CLIENT:
return 'client';
case api_1.SpanKind.PRODUCER:
return 'producer';
case api_1.SpanKind.CONSUMER:
return 'producer';
default:
return 'internal';
}
}
function expoStatus(code) {
switch (code) {
case api_1.StatusCode.OK:
return 'ok';
case api_1.StatusCode.ERROR:
return 'error';
default:
return 'unset';
}
}
//# sourceMappingURL=exporter.js.map
import { Attributes } from '@opentelemetry/api';
export interface SpanData {
id: string;
parentId: string;
parentId?: string;
name: string;
kind: number;
kind: string;
startTime: string;
endTime: string;
statusCode: string;
statusMessage: string;
attrs: Attributes;

@@ -10,0 +12,0 @@ events: EventData[];

@@ -1,2 +0,2 @@

export declare const VERSION = "0.2.0";
export declare const VERSION = "0.3.0";
//# sourceMappingURL=version.d.ts.map

@@ -5,3 +5,3 @@ "use strict";

// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '0.2.0';
exports.VERSION = '0.3.0';
//# sourceMappingURL=version.js.map
{
"name": "@uptrace/core",
"version": "0.2.0",
"version": "0.3.0",
"description": "Uptrace JS core",

@@ -52,20 +52,22 @@ "main": "build/src/index.js",

"dependencies": {
"@opentelemetry/api": "^0.12.0",
"@opentelemetry/core": "^0.12.0",
"@opentelemetry/tracing": "^0.12.0",
"@opentelemetry/api": "^0.13.0",
"@opentelemetry/core": "^0.13.0",
"@opentelemetry/tracing": "^0.13.0",
"cross-fetch": "^3.0.5"
},
"devDependencies": {
"@types/mocha": "8.0.3",
"@types/node": "14.14.5",
"@typescript-eslint/eslint-plugin": "4.6.0",
"eslint": "7.12.0",
"@types/mocha": "8.0.4",
"@types/node": "14.14.10",
"@types/sinon": "^9.0.9",
"@typescript-eslint/eslint-plugin": "4.9.0",
"eslint": "7.15.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-prettier": "3.1.4",
"gts": "3.0.2",
"mocha": "8.2.0",
"eslint-plugin-prettier": "3.2.0",
"gts": "3.0.3",
"mocha": "8.2.1",
"nyc": "15.1.0",
"sinon": "^9.2.1",
"ts-mocha": "8.0.0",
"typescript": "4.0.5"
"typescript": "4.1.2"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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