Skip to content

Commit

Permalink
rename DistributedContext to CorrelationContext (#834)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurkale22 authored Mar 4, 2020
1 parent 1b21464 commit fd9c7ab
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
import { EntryValue } from './EntryValue';

/**
* DistributedContext represents collection of entries. Each key of
* DistributedContext is associated with exactly one value. DistributedContext
* CorrelationContext represents collection of entries. Each key of
* CorrelationContext is associated with exactly one value. CorrelationContext
* is serializable, to facilitate propagating it not only inside the process
* but also across process boundaries. DistributedContext is used to annotate
* but also across process boundaries. CorrelationContext is used to annotate
* telemetry with the name:value pair Entry. Those values can be used to add
* dimension to the metric or additional contest properties to logs and traces.
*/
export interface DistributedContext {
export interface CorrelationContext {
[entryKey: string]: EntryValue;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/**
* {@link EntryValue} contains properties associated with a {@link
* DistributedContext}.
* CorrelationContext}.
*/
export interface EntryValue {
/** `String` value of the `EntryValue`. */
Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export * from './common/Logger';
export * from './common/Time';
export * from './context/propagation/carrier';
export * from './context/propagation/HttpTextFormat';
export * from './distributed_context/DistributedContext';
export * from './distributed_context/EntryValue';
export * from './correlation_context/CorrelationContext';
export * from './correlation_context/EntryValue';
export * from './metrics/BoundInstrument';
export * from './metrics/Meter';
export * from './metrics/MeterProvider';
Expand Down
9 changes: 5 additions & 4 deletions packages/opentelemetry-api/src/metrics/BoundInstrument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { DistributedContext } from '../distributed_context/DistributedContext';
import { CorrelationContext } from '../correlation_context/CorrelationContext';
import { SpanContext } from '../trace/span_context';

/** An Instrument for Counter Metric. */
Expand All @@ -31,15 +31,16 @@ export interface BoundMeasure {
/**
* Records the given value to this measure.
* @param value the measurement to record.
* @param distContext the distContext associated with the measurements.
* @param correlationContext the correlationContext associated with the
* measurements.
* @param spanContext the {@link SpanContext} that identifies the {@link Span}
* for which the measurements are associated with.
*/
record(value: number): void;
record(value: number, distContext: DistributedContext): void;
record(value: number, correlationContext: CorrelationContext): void;
record(
value: number,
distContext: DistributedContext,
correlationContext: CorrelationContext,
spanContext: SpanContext
): void;
}
6 changes: 3 additions & 3 deletions packages/opentelemetry-api/src/metrics/Metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { DistributedContext } from '../distributed_context/DistributedContext';
import { CorrelationContext } from '../correlation_context/CorrelationContext';
import { SpanContext } from '../trace/span_context';

/**
Expand Down Expand Up @@ -118,13 +118,13 @@ export interface MetricUtils {
record(
value: number,
labelSet: LabelSet,
distContext: DistributedContext
correlationContext: CorrelationContext
): void;

record(
value: number,
labelSet: LabelSet,
distContext: DistributedContext,
correlationContext: CorrelationContext,
spanContext: SpanContext
): void;
}
Expand Down
12 changes: 6 additions & 6 deletions packages/opentelemetry-api/src/metrics/NoopMeter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { Meter } from './Meter';
import { MetricOptions, Metric, Labels, LabelSet, MetricUtils } from './Metric';
import { BoundMeasure, BoundCounter } from './BoundInstrument';
import { DistributedContext } from '../distributed_context/DistributedContext';
import { CorrelationContext } from '../correlation_context/CorrelationContext';
import { SpanContext } from '../trace/span_context';

/**
Expand Down Expand Up @@ -107,15 +107,15 @@ export class NoopMeasureMetric extends NoopMetric<BoundMeasure>
record(
value: number,
labelSet: LabelSet,
distContext?: DistributedContext,
correlationContext?: CorrelationContext,
spanContext?: SpanContext
) {
if (typeof distContext === 'undefined') {
if (typeof correlationContext === 'undefined') {
this.bind(labelSet).record(value);
} else if (typeof spanContext === 'undefined') {
this.bind(labelSet).record(value, distContext);
this.bind(labelSet).record(value, correlationContext);
} else {
this.bind(labelSet).record(value, distContext, spanContext);
this.bind(labelSet).record(value, correlationContext, spanContext);
}
}
}
Expand All @@ -129,7 +129,7 @@ export class NoopBoundCounter implements BoundCounter {
export class NoopBoundMeasure implements BoundMeasure {
record(
value: number,
distContext?: DistributedContext,
correlationContext?: CorrelationContext,
spanContext?: SpanContext
): void {
return;
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-api/src/trace/span_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { TraceState } from './trace_state';

/**
* A SpanContext represents the portion of a {@link Span} which must be
* serialized and propagated along side of a {@link DistributedContext}.
* serialized and propagated along side of a {@link CorrelationContext}.
*/
export interface SpanContext {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-metrics/src/BoundInstrument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class BoundMeasure extends BaseBoundInstrument

record(
value: number,
distContext?: types.DistributedContext,
correlationContext?: types.CorrelationContext,
spanContext?: types.SpanContext
): void {
if (this._absolute && value < 0) {
Expand Down

0 comments on commit fd9c7ab

Please sign in to comment.