Skip to content

Commit

Permalink
chore: rename registry to provider (#749)
Browse files Browse the repository at this point in the history
* chore: rename registry to provider

* chore: revert changelog modification

* chore: remove examples and getting started from rename
  • Loading branch information
dyladan authored Feb 3, 2020
1 parent 5d6c99d commit d2e96ba
Show file tree
Hide file tree
Showing 80 changed files with 588 additions and 588 deletions.
8 changes: 4 additions & 4 deletions benchmark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The minimum sample size is set to 10 to perform statistical analysis on benchmar
### `v0.3.3` release

```
Beginning NoopTracerRegistry Benchmark...
Beginning NoopTracerProvider Benchmark...
5 tests completed.
#startSpan x 731,516,636 ops/sec ±2.57% (20 runs sampled)
Expand All @@ -25,7 +25,7 @@ Beginning NoopTracerRegistry Benchmark...
#startSpan with 30 attributes x 1,658,688 ops/sec ±1.23% (20 runs sampled)
#startSpan with 100 attributes x 535,082 ops/sec ±1.55% (20 runs sampled)
Beginning BasicTracerRegistry Benchmark...
Beginning BasicTracerProvider Benchmark...
5 tests completed.
#startSpan x 80,633 ops/sec ±3.57% (20 runs sampled)
Expand All @@ -34,7 +34,7 @@ Beginning BasicTracerRegistry Benchmark...
#startSpan with 30 attributes x 36,331 ops/sec ±1.29% (20 runs sampled)
#startSpan with 100 attributes x 3,549 ops/sec ±3.59% (20 runs sampled)
Beginning BasicTracerRegistry with SimpleSpanProcessor Benchmark...
Beginning BasicTracerProvider with SimpleSpanProcessor Benchmark...
5 tests completed.
#startSpan x 74,539 ops/sec ±4.49% (20 runs sampled)
Expand All @@ -43,7 +43,7 @@ Beginning BasicTracerRegistry with SimpleSpanProcessor Benchmark...
#startSpan with 30 attributes x 26,491 ops/sec ±13.68% (20 runs sampled)
#startSpan with 100 attributes x 2,464 ops/sec ±19.64% (20 runs sampled)
Beginning BasicTracerRegistry with BatchSpanProcessor Benchmark...
Beginning BasicTracerProvider with BatchSpanProcessor Benchmark...
5 tests completed.
#startSpan x 74,974 ops/sec ±3.57% (20 runs sampled)
Expand Down
28 changes: 14 additions & 14 deletions benchmark/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@

const benchmark = require('./benchmark');
const opentelemetry = require('../packages/opentelemetry-core');
const { BasicTracerRegistry, BatchSpanProcessor, InMemorySpanExporter, SimpleSpanProcessor } = require('../packages/opentelemetry-tracing');
const { BasicTracerProvider, BatchSpanProcessor, InMemorySpanExporter, SimpleSpanProcessor } = require('../packages/opentelemetry-tracing');

const logger = new opentelemetry.NoopLogger();

const setups = [
{
name: 'NoopTracerRegistry',
registry: opentelemetry.getTracerRegistry()
name: 'NoopTracerProvider',
provider: opentelemetry.getTracerProvider()
},
{
name: 'BasicTracerRegistry',
registry: new BasicTracerRegistry({ logger })
name: 'BasicTracerProvider',
provider: new BasicTracerProvider({ logger })
},
{
name: 'BasicTracerRegistry with SimpleSpanProcessor',
registry: getRegistry(new SimpleSpanProcessor(new InMemorySpanExporter()))
name: 'BasicTracerProvider with SimpleSpanProcessor',
provider: getProvider(new SimpleSpanProcessor(new InMemorySpanExporter()))
},
{
name: 'BasicTracerRegistry with BatchSpanProcessor',
registry: getRegistry(new BatchSpanProcessor(new InMemorySpanExporter()))
name: 'BasicTracerProvider with BatchSpanProcessor',
provider: getProvider(new BatchSpanProcessor(new InMemorySpanExporter()))
}
];

for (const setup of setups) {
console.log(`Beginning ${setup.name} Benchmark...`);
const tracer = setup.registry.getTracer("benchmark");
const tracer = setup.provider.getTracer("benchmark");
const suite = benchmark(20)
.add('#startSpan', function () {
const span = tracer.startSpan('op');
Expand Down Expand Up @@ -62,9 +62,9 @@ for (const setup of setups) {
// run async
suite.run({ async: false });
}
function getRegistry(processor) {
const registry = new BasicTracerRegistry({ logger });
registry.addSpanProcessor(processor);
return registry;
function getProvider(processor) {
const provider = new BasicTracerProvider({ logger });
provider.addSpanProcessor(processor);
return provider;
}

32 changes: 16 additions & 16 deletions packages/opentelemetry-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ API entry points are defined as global singleton objects `trace` and `metrics` w
```javascript
const api = require("@opentelemetry/api")

/* Initialize TraceRegistry */
api.trace.initGlobalTracerRegistry(traceRegistry);
/* returns traceRegistry (no-op if a working registry has not been initialized) */
api.trace.getTracerRegistry();
/* returns a tracer from the registered global tracer registry (no-op if a working registry has not been initialized); */
/* Initialize TraceProvider */
api.trace.initGlobalTracerProvider(traceProvider);
/* returns traceProvider (no-op if a working provider has not been initialized) */
api.trace.getTracerProvider();
/* returns a tracer from the registered global tracer provider (no-op if a working provider has not been initialized); */
api.trace.getTracer(name, version);

/* Initialize MeterRegistry */
api.metrics.initGlobalMeterRegistry(meterRegistry);
/* returns meterRegistry (no-op if a working registry has not been initialized) */
api.metrics.getMeterRegistry();
/* returns a meter from the registered global meter registry (no-op if a working registry has not been initialized); */
/* Initialize MeterProvider */
api.metrics.initGlobalMeterProvider(meterProvider);
/* returns meterProvider (no-op if a working provider has not been initialized) */
api.metrics.getMeterProvider();
/* returns a meter from the registered global meter provider (no-op if a working provider has not been initialized); */
api.metrics.getMeter(name, version);
```

Expand All @@ -40,7 +40,7 @@ Application owners will also need a working OpenTelemetry SDK implementation. Op

#### Simple NodeJS Example

Before any other module in your application is loaded, you must initialize the global tracer and meter registries. If you fail to initialize a registry, no-op implementations will be provided to any library which acquires them from the API.
Before any other module in your application is loaded, you must initialize the global tracer and meter registries. If you fail to initialize a provider, no-op implementations will be provided to any library which acquires them from the API.

```javascript
const api = require("@opentelemetry/api");
Expand All @@ -54,14 +54,14 @@ const exporter = new JaegerExporter({
serviceName: 'basic-service'
});

// Create a registry which we will configure as the global tracer registry
const registry = new sdk.NodeTracerRegistry();
// Create a provider which we will configure as the global tracer provider
const provider = new sdk.NodeTracerProvider();

// Configure span processor to send spans to the exporter
registry.addSpanProcessor(new SimpleSpanProcessor(exporter));
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));

// Initialize the OpenTelemetry APIs to use the NodeTracerRegistry bindings
api.trace.initGlobalTracerRegistry(registry);
// Initialize the OpenTelemetry APIs to use the NodeTracerProvider bindings
api.trace.initGlobalTracerProvider(provider);

// your application code below this line
```
Expand Down
24 changes: 12 additions & 12 deletions packages/opentelemetry-api/src/api/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
*/

import { Meter } from '../metrics/Meter';
import { MeterRegistry } from '../metrics/MeterRegistry';
import { NOOP_METER_REGISTRY } from '../metrics/NoopMeterRegistry';
import { MeterProvider } from '../metrics/MeterProvider';
import { NOOP_METER_PROVIDER } from '../metrics/NoopMeterProvider';

/**
* Singleton object which represents the entry point to the OpenTelemetry Metrics API
*/
export class MetricsAPI {
private static _instance?: MetricsAPI;
private _meterRegistry: MeterRegistry = NOOP_METER_REGISTRY;
private _meterProvider: MeterProvider = NOOP_METER_PROVIDER;

/** Empty private constructor prevents end users from constructing a new instance of the API */
private constructor() {}
Expand All @@ -38,24 +38,24 @@ export class MetricsAPI {
}

/**
* Set the current global meter. Returns the initialized global meter registry.
* Set the current global meter. Returns the initialized global meter provider.
*/
public initGlobalMeterRegistry(registry: MeterRegistry): MeterRegistry {
this._meterRegistry = registry;
return registry;
public initGlobalMeterProvider(provider: MeterProvider): MeterProvider {
this._meterProvider = provider;
return provider;
}

/**
* Returns the global meter registry.
* Returns the global meter provider.
*/
public getMeterRegistry(): MeterRegistry {
return this._meterRegistry;
public getMeterProvider(): MeterProvider {
return this._meterProvider;
}

/**
* Returns a meter from the global meter registry.
* Returns a meter from the global meter provider.
*/
public getMeter(name: string, version?: string): Meter {
return this.getMeterRegistry().getMeter(name, version);
return this.getMeterProvider().getMeter(name, version);
}
}
24 changes: 12 additions & 12 deletions packages/opentelemetry-api/src/api/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
* limitations under the License.
*/

import { NOOP_TRACER_REGISTRY } from '../trace/NoopTracerRegistry';
import { TracerRegistry } from '../trace/tracer_registry';
import { NOOP_TRACER_PROVIDER } from '../trace/NoopTracerProvider';
import { TracerProvider } from '../trace/tracer_provider';
import { Tracer } from '../trace/tracer';

/**
* Singleton object which represents the entry point to the OpenTelemetry Tracing API
*/
export class TraceAPI {
private static _instance?: TraceAPI;
private _tracerRegistry: TracerRegistry = NOOP_TRACER_REGISTRY;
private _tracerProvider: TracerProvider = NOOP_TRACER_PROVIDER;

/** Empty private constructor prevents end users from constructing a new instance of the API */
private constructor() {}
Expand All @@ -38,24 +38,24 @@ export class TraceAPI {
}

/**
* Set the current global tracer. Returns the initialized global tracer registry
* Set the current global tracer. Returns the initialized global tracer provider
*/
public initGlobalTracerRegistry(registry: TracerRegistry): TracerRegistry {
this._tracerRegistry = registry;
return registry;
public initGlobalTracerProvider(provider: TracerProvider): TracerProvider {
this._tracerProvider = provider;
return provider;
}

/**
* Returns the global tracer registry.
* Returns the global tracer provider.
*/
public getTracerRegistry(): TracerRegistry {
return this._tracerRegistry;
public getTracerProvider(): TracerProvider {
return this._tracerProvider;
}

/**
* Returns a tracer from the global tracer registry.
* Returns a tracer from the global tracer provider.
*/
public getTracer(name: string, version?: string): Tracer {
return this.getTracerRegistry().getTracer(name, version);
return this.getTracerProvider().getTracer(name, version);
}
}
8 changes: 4 additions & 4 deletions packages/opentelemetry-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export * from './distributed_context/DistributedContext';
export * from './distributed_context/EntryValue';
export * from './metrics/BoundInstrument';
export * from './metrics/Meter';
export * from './metrics/MeterRegistry';
export * from './metrics/MeterProvider';
export * from './metrics/Metric';
export * from './trace/attributes';
export * from './trace/Event';
Expand All @@ -36,13 +36,13 @@ export * from './trace/span_kind';
export * from './trace/status';
export * from './trace/TimedEvent';
export * from './trace/tracer';
export * from './trace/tracer_registry';
export * from './trace/tracer_provider';
export * from './trace/trace_flags';
export * from './trace/trace_state';
export * from './trace/NoopSpan';
export * from './trace/NoopTracer';
export * from './trace/NoopTracerRegistry';
export * from './metrics/NoopMeterRegistry';
export * from './trace/NoopTracerProvider';
export * from './metrics/NoopMeterProvider';
export * from './metrics/NoopMeter';

import { TraceAPI } from './api/trace';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import { Meter } from './Meter';

/**
* MeterRegistry provides an interface for creating {@link Meter}s
* MeterProvider provides an interface for creating {@link Meter}s
*/
export interface MeterRegistry {
export interface MeterProvider {
/**
* Returns a Meter, creating one if one with the given name and version is not already created
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
*/

import { Meter } from './Meter';
import { MeterRegistry } from './MeterRegistry';
import { MeterProvider } from './MeterProvider';
import { NOOP_METER } from './NoopMeter';

/**
* An implementation of the {@link MeterRegistry} which returns an impotent Meter
* An implementation of the {@link MeterProvider} which returns an impotent Meter
* for all calls to `getMeter`
*/
export class NoopMeterRegistry implements MeterRegistry {
export class NoopMeterProvider implements MeterProvider {
getMeter(_name?: string, _version?: string): Meter {
return NOOP_METER;
}
}

export const NOOP_METER_REGISTRY = new NoopMeterRegistry();
export const NOOP_METER_PROVIDER = new NoopMeterProvider();
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@

import { NOOP_TRACER } from './NoopTracer';
import { Tracer } from './tracer';
import { TracerRegistry } from './tracer_registry';
import { TracerProvider } from './tracer_provider';

/**
* An implementation of the {@link TracerRegistry} which returns an impotent Tracer
* An implementation of the {@link TracerProvider} which returns an impotent Tracer
* for all calls to `getTracer`
*/
export class NoopTracerRegistry implements TracerRegistry {
export class NoopTracerProvider implements TracerProvider {
getTracer(_name?: string, _version?: string): Tracer {
return NOOP_TRACER;
}
}

export const NOOP_TRACER_REGISTRY = new NoopTracerRegistry();
export const NOOP_TRACER_PROVIDER = new NoopTracerProvider();
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { Logger } from '../../common/Logger';
import { TracerRegistry } from '../tracer_registry';
import { TracerProvider } from '../tracer_provider';

/** Interface Plugin to apply patch. */
// tslint:disable-next-line:no-any
Expand All @@ -32,13 +32,13 @@ export interface Plugin<T = any> {
* Method that enables the instrumentation patch.
* @param moduleExports The value of the `module.exports` property that would
* normally be exposed by the required module. ex: `http`, `https` etc.
* @param TracerRegistry a tracer registry.
* @param TracerProvider a tracer provider.
* @param logger a logger instance.
* @param [config] an object to configure the plugin.
*/
enable(
moduleExports: T,
TracerRegistry: TracerRegistry,
TracerProvider: TracerProvider,
logger: Logger,
config?: PluginConfig
): T;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import { Tracer } from './tracer';

/**
* TracerRegistry provides an interface for creating {@link Tracer}s
* TracerProvider provides an interface for creating {@link Tracer}s
*/
export interface TracerRegistry {
export interface TracerProvider {
/**
* Returns a Tracer, creating one if one with the given name and version is not already created
*
Expand Down
Loading

0 comments on commit d2e96ba

Please sign in to comment.