@opencensus/exporter-zpages
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -81,3 +81,2 @@ "use strict"; | ||
static extractSamplingProbability() { | ||
/** */ | ||
const samplingProbability = tracing.tracer.sampler.description; | ||
@@ -84,0 +83,0 @@ if (samplingProbability === 'always') { |
@@ -127,2 +127,3 @@ "use strict"; | ||
const tracezFile = ejs.fileLoader(`${templatesDir}/tracez.ejs`).toString(); | ||
const stylesFile = ejs.fileLoader(`${templatesDir}/styles.min.css`).toString(); | ||
const summaryFile = ejs.fileLoader(`${templatesDir}/summary.ejs`).toString(); | ||
@@ -186,3 +187,4 @@ const spanCellFile = ejs.fileLoader(`${templatesDir}/span-cell.ejs`).toString(); | ||
if (json) { | ||
return JSON.stringify({ selectedTraces, spanCells }, null, 2); | ||
const jsonObj = { selectedTraces, spanCells }; | ||
return JSON.stringify(jsonObj, null, 2); | ||
} | ||
@@ -200,4 +202,5 @@ else { | ||
return ejs.render(tracezFile, { | ||
styles: stylesFile, | ||
table_content: renderedSummary + renderedSpanCells, | ||
title: 'TraceZ', | ||
title: 'TraceZ Summary', | ||
selectedTraces: renderedSelectedTraces | ||
@@ -204,0 +207,0 @@ }, options); |
@@ -19,2 +19,3 @@ /// <reference types="express" /> | ||
import * as express from 'express'; | ||
import { StatsParams } from '../zpages'; | ||
/** | ||
@@ -24,3 +25,5 @@ * Create a set of routes that consults the given TraceMap instance for span | ||
* @param traceMap A span data store. | ||
* @param statsParams An object with all registered views, registered measures | ||
* and recorded data from stats | ||
*/ | ||
export declare function createRoutes(traceMap: Map<string, Span[]>): express.Router; | ||
export declare function createRoutes(traceMap: Map<string, Span[]>, statsParams: StatsParams): express.Router; |
@@ -19,2 +19,4 @@ "use strict"; | ||
const express = require("express"); | ||
const rpcz_controller_1 = require("./controllers/rpcz.controller"); | ||
const statsz_controller_1 = require("./controllers/statsz.controller"); | ||
const traceconfigz_controller_1 = require("./controllers/traceconfigz.controller"); | ||
@@ -26,4 +28,6 @@ const tracez_controller_1 = require("./controllers/tracez.controller"); | ||
* @param traceMap A span data store. | ||
* @param statsParams An object with all registered views, registered measures | ||
* and recorded data from stats | ||
*/ | ||
function createRoutes(traceMap) { | ||
function createRoutes(traceMap, statsParams) { | ||
const router = express.Router(); | ||
@@ -35,9 +39,5 @@ // Tracez Page | ||
// RPC Stats Page | ||
router.get('/rpcz', (req, res) => { | ||
res.status(200).send('working!'); // TODO | ||
}); | ||
router.get('/rpcz', rpcz_controller_1.createRpczHandler(statsParams)); | ||
// Stats Page | ||
router.get('/statsz', (req, res) => { | ||
res.status(200).send('working!'); // TODO | ||
}); | ||
router.get('/statsz', statsz_controller_1.createStatszHandler(statsParams)); | ||
return router; | ||
@@ -44,0 +44,0 @@ } |
@@ -16,3 +16,3 @@ /** | ||
*/ | ||
import { Exporter, ExporterConfig, RootSpan, Span } from '@opencensus/core'; | ||
import { AggregationData, Exporter, ExporterConfig, Measure, Measurement, RootSpan, Span, StatsEventListener, View } from '@opencensus/core'; | ||
/** Interface to Zpages options */ | ||
@@ -27,4 +27,11 @@ export interface ZpagesExporterOptions extends ExporterConfig { | ||
} | ||
export interface StatsParams { | ||
registeredViews: View[]; | ||
registeredMeasures: Measure[]; | ||
recordedData: { | ||
[key: string]: AggregationData[]; | ||
}; | ||
} | ||
/** Class to ZpagesExporter */ | ||
export declare class ZpagesExporter implements Exporter { | ||
export declare class ZpagesExporter implements Exporter, StatsEventListener { | ||
/** ZpagesExporter default options */ | ||
@@ -40,5 +47,6 @@ static readonly defaultOptions: { | ||
private logger; | ||
private statsParams; | ||
constructor(options: ZpagesExporterOptions); | ||
/** | ||
* Is called whenever a span is started. | ||
* Called whenever a span is started. | ||
* @param root the started span | ||
@@ -48,3 +56,3 @@ */ | ||
/** | ||
* Is called whenever a span is ended. | ||
* Called whenever a span is ended. | ||
* @param root the ended span | ||
@@ -54,2 +62,13 @@ */ | ||
/** | ||
* Called whenever a view is registered | ||
* @param view the registered view | ||
*/ | ||
onRegisterView(view: View): void; | ||
/** | ||
* Called whenever a measurement is recorded | ||
* @param views the view list where the measurement was recorded | ||
* @param measurement the recorded measurement | ||
*/ | ||
onRecord(views: View[], measurement: Measurement): void; | ||
/** | ||
* Send a trace to traces array | ||
@@ -56,0 +75,0 @@ * @param trace the rootSpan to be sent to the array list |
@@ -25,2 +25,7 @@ "use strict"; | ||
this.traces = new Map(); | ||
this.statsParams = { | ||
registeredViews: [], | ||
registeredMeasures: [], | ||
recordedData: {} | ||
}; | ||
/** create express app */ | ||
@@ -38,3 +43,3 @@ this.app = express(); | ||
/** defining routes */ | ||
this.app.use(routes_1.createRoutes(this.traces)); | ||
this.app.use(routes_1.createRoutes(this.traces, this.statsParams)); | ||
/** start the server if the startServer option is true */ | ||
@@ -46,3 +51,3 @@ if (startServer) { | ||
/** | ||
* Is called whenever a span is started. | ||
* Called whenever a span is started. | ||
* @param root the started span | ||
@@ -54,3 +59,3 @@ */ | ||
/** | ||
* Is called whenever a span is ended. | ||
* Called whenever a span is ended. | ||
* @param root the ended span | ||
@@ -62,2 +67,34 @@ */ | ||
/** | ||
* Called whenever a view is registered | ||
* @param view the registered view | ||
*/ | ||
onRegisterView(view) { | ||
// Adds the view to registeredViews array if it doesn't contain yet | ||
if (!this.statsParams.registeredViews.find(v => v.name === view.name)) { | ||
this.statsParams.registeredViews.push(view); | ||
} | ||
// Adds the measure to registeredMeasures array if it doesn't contain yet | ||
if (!this.statsParams.registeredMeasures.find(m => m.name === view.measure.name)) { | ||
this.statsParams.registeredMeasures.push(view.measure); | ||
} | ||
} | ||
/** | ||
* Called whenever a measurement is recorded | ||
* @param views the view list where the measurement was recorded | ||
* @param measurement the recorded measurement | ||
*/ | ||
onRecord(views, measurement) { | ||
views.map(view => { | ||
const snapshot = view.getSnapshot(measurement.tags); | ||
// Check if there is no data for the current view | ||
if (!this.statsParams.recordedData[view.name]) { | ||
this.statsParams.recordedData[view.name] = [snapshot]; | ||
} | ||
else if (!this.statsParams.recordedData[view.name].find(s => s === snapshot)) { | ||
// Push the snapshot if it hasn't recoreded before | ||
this.statsParams.recordedData[view.name].push(snapshot); | ||
} | ||
}); | ||
} | ||
/** | ||
* Send a trace to traces array | ||
@@ -64,0 +101,0 @@ * @param trace the rootSpan to be sent to the array list |
{ | ||
"name": "@opencensus/exporter-zpages", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "A collection of HTML pages to display stats and trace data and allow library configuration control", | ||
@@ -42,3 +42,3 @@ "main": "build/src/index.js", | ||
"devDependencies": { | ||
"@opencensus/nodejs": "^0.0.4", | ||
"@opencensus/nodejs": "^0.0.5", | ||
"@types/ejs": "^2.6.0", | ||
@@ -59,3 +59,3 @@ "@types/express": "^4.11.1", | ||
"dependencies": { | ||
"@opencensus/core": "^0.0.4", | ||
"@opencensus/core": "^0.0.5", | ||
"ejs": "^2.5.8", | ||
@@ -62,0 +62,0 @@ "express": "^4.16.3", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
111973
41
1658
1
+ Added@opencensus/core@0.0.5(transitive)
- Removed@opencensus/core@0.0.4(transitive)
Updated@opencensus/core@^0.0.5