Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 62f5859

Browse files
fabiogomessilvakjin
authored andcommitted
refactor: rename core package and remove exporter namespaces: types and classes (#61)
* refactor: rename core package to @opencensus/core and remove export namespaces: types and classes * refactor: changes to address review comments PR #61 * refactor: changes to address remaining review comments PR #61 * chore: fix @types/node dep
1 parent db46f4f commit 62f5859

68 files changed

Lines changed: 426 additions & 511 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/opencensus-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@opencensus/opencensus-core",
2+
"name": "@opencensus/core",
33
"version": "0.0.2",
44
"description": "OpenCensus is a toolkit for collecting application performance and behavior data.",
55
"main": "build/src/index.js",

packages/opencensus-core/src/common/console-logger.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,8 @@ export class ConsoleLogger implements types.Logger {
106106
* https://github.com/cainus/logdriver/blob/bba1761737ca72f04d6b445629848538d038484a/index.js#L50
107107
* @param options A logger options or strig to logger in console
108108
*/
109-
// tslint:disable-next-line:no-any
110-
const logger: any =
111-
(options?: types.LoggerOptions|string|number): types.Logger => {
112-
return new ConsoleLogger(options);
113-
};
109+
const logger = (options?: types.LoggerOptions|string|number): types.Logger => {
110+
return new ConsoleLogger(options);
111+
};
114112

115113
export {logger};

packages/opencensus-core/src/index-classes.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

packages/opencensus-core/src/index-types.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

packages/opencensus-core/src/index.ts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,31 @@
1515
*/
1616

1717

18-
import * as logger from './common/console-logger';
19-
import * as classes from './index-classes';
20-
import * as types from './index-types';
18+
// types
19+
export * from './trace/types';
20+
export * from './trace/model/types';
21+
export * from './trace/config/types';
22+
export * from './trace/sampler/types';
23+
export * from './trace/instrumentation/types';
24+
export * from './trace/propagation/types';
25+
export * from './exporters/types';
26+
export * from './common/types';
27+
28+
// classes
29+
30+
// domain models impls
31+
export * from './trace/model/tracer';
32+
33+
// sampler impl
34+
export * from './trace/sampler/sampler';
2135

22-
export {classes, logger, types};
36+
// base instrumetation class
37+
export * from './trace/instrumentation/base-plugin';
38+
39+
// console exporter and buffer impls
40+
export * from './exporters/exporter-buffer';
41+
export * from './exporters/console-exporter';
42+
43+
// logger
44+
import * as logger from './common/console-logger';
45+
export {logger};

packages/opencensus-core/src/trace/model/root-span.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ export class RootSpan extends SpanBase implements types.RootSpan {
3232
private spansLocal: types.Span[];
3333
/** It's trace ID. */
3434
private traceIdLocal: string;
35+
/** set isRootSpan = true */
36+
readonly isRootSpan = true;
3537

3638
/**
3739
* Constructs a new RootSpanImpl instance.

packages/opencensus-core/src/trace/model/span-base.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ export abstract class SpanBase implements types.Span {
5353
kind: string = null;
5454
/** A final status for this span */
5555
status: number;
56+
/** set isRootSpan */
57+
abstract get isRootSpan(): boolean;
5658

5759
/** Constructs a new SpanBaseModel instance. */
5860
constructor() {

packages/opencensus-core/src/trace/model/span.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import * as types from './types';
2323
/** Defines a Span. */
2424
export class Span extends SpanBase implements types.Span {
2525
private root: types.RootSpan;
26+
/** set isRootSpan = true */
27+
readonly isRootSpan = false;
2628

2729
/**
2830
* Constructs a new SpanImpl instance.

packages/opencensus-core/src/trace/model/tracer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import * as loggerTypes from '../../common/types';
1919
import * as cls from '../../internal/cls';
2020
import * as configTypes from '../config/types';
2121
import {Propagation} from '../propagation/types';
22-
import {Sampler} from '../sampler/sampler';
22+
import {SamplerBuilder} from '../sampler/sampler';
2323
import * as samplerTypes from '../sampler/types';
2424

2525
import {RootSpan} from './root-span';
@@ -30,7 +30,7 @@ import * as types from './types';
3030
/**
3131
* This class represent a tracer.
3232
*/
33-
export class Tracer implements types.Tracer {
33+
export class CoreTracer implements types.Tracer {
3434
/** Indicates if the tracer is active */
3535
private activeLocal: boolean;
3636
/** Manage context automatic propagation */
@@ -81,7 +81,7 @@ export class Tracer implements types.Tracer {
8181
this.activeLocal = true;
8282
this.config = config;
8383
this.logger = this.config.logger || logger.logger();
84-
this.sampler = new Sampler().probability(config.samplingRate);
84+
this.sampler = SamplerBuilder.getSampler(config.samplingRate);
8585
return this;
8686
}
8787

packages/opencensus-core/src/trace/model/types.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ export interface Span {
123123
/** Pointers from the current span to another span */
124124
links: Link[];
125125

126+
/** true if span is a RootSpan */
127+
isRootSpan: boolean;
128+
126129
/** Constructs a new SpanBaseModel instance. */
127130
readonly traceId: string;
128131

@@ -202,12 +205,6 @@ export interface RootSpan extends Span {
202205
/** Get the span list from RootSpan instance */
203206
readonly spans: Span[];
204207

205-
/** Starts the RootSpan instance */
206-
start(): void;
207-
208-
/** Ends the RootSpan instance */
209-
end(): void;
210-
211208
/** Starts a new Span instance in the RootSpan instance */
212209
startChildSpan(name: string, type: string): Span;
213210
}

0 commit comments

Comments
 (0)