Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/opentelemetry-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ async function doSomething() {
} catch (err) {
span.setStatus({
// use an appropriate status code here
code: api.StatusCode.ERROR,
code: api.SpanStatusCode.ERROR,
message: err.message,
});
span.end();
Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-api/src/baggage/Baggage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { EntryValue } from './EntryValue';
import { BaggageEntryValue } from './EntryValue';

/**
* Baggage represents collection of entries. Each key of
Expand All @@ -25,5 +25,5 @@ import { EntryValue } from './EntryValue';
* dimension to the metric or additional contest properties to logs and traces.
*/
export interface Baggage {
[entryKey: string]: EntryValue;
[entryKey: string]: BaggageEntryValue;
}
10 changes: 5 additions & 5 deletions packages/opentelemetry-api/src/baggage/EntryValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface EntryValue {
/** `String` value of the `EntryValue`. */
export interface BaggageEntryValue {
/** `String` value of the `BaggageEntryValue`. */
value: string;
/**
* ttl is an integer that represents number of hops an entry can
* propagate.
*/
ttl?: EntryTtl;
ttl?: BaggageEntryTtl;
}

/**
* EntryTtl is an integer that represents number of hops an entry can propagate.
* BaggageEntryTtl is an integer that represents number of hops an entry can propagate.
*
* For now, ONLY special values (0 and -1) are supported.
*/
export enum EntryTtl {
export enum BaggageEntryTtl {
/**
* NO_PROPAGATION is considered to have local context and is used within the
* process it created.
Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-api/src/trace/Event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

import { Attributes } from './attributes';
import { SpanAttributes } from './attributes';

/** A text annotation with a set of attributes. */
export interface Event {
/** The name of the event. */
name: string;
/** The attributes of the event. */
attributes?: Attributes;
attributes?: SpanAttributes;
}
10 changes: 5 additions & 5 deletions packages/opentelemetry-api/src/trace/NoopSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

import { Exception } from '../common/Exception';
import { TimeInput } from '../common/Time';
import { Attributes } from './attributes';
import { SpanAttributes } from './attributes';
import { Span } from './span';
import { SpanContext } from './span_context';
import { Status } from './status';
import { SpanStatus } from './status';
import { INVALID_SPAN_CONTEXT } from './spancontext-utils';

/**
Expand All @@ -43,17 +43,17 @@ export class NoopSpan implements Span {
}

// By default does nothing
setAttributes(_attributes: Attributes): this {
setAttributes(_attributes: SpanAttributes): this {
return this;
}

// By default does nothing
addEvent(_name: string, _attributes?: Attributes): this {
addEvent(_name: string, _attributes?: SpanAttributes): this {
return this;
}

// By default does nothing
setStatus(_status: Status): this {
setStatus(_status: SpanStatus): this {
return this;
}

Expand Down
6 changes: 3 additions & 3 deletions packages/opentelemetry-api/src/trace/Sampler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { Context } from '@opentelemetry/context-base';
import { Attributes } from './attributes';
import { SpanAttributes } from './attributes';
import { Link } from './link';
import { SamplingResult } from './SamplingResult';
import { SpanKind } from './span_kind';
Expand All @@ -35,7 +35,7 @@ export interface Sampler {
* span to be created starts a new trace.
* @param spanName of the span to be created.
* @param spanKind of the span to be created.
* @param attributes Initial set of Attributes for the Span being constructed.
* @param attributes Initial set of SpanAttributes for the Span being constructed.
* @param links Collection of links that will be associated with the Span to
* be created. Typically useful for batch operations.
* @returns a {@link SamplingResult}.
Expand All @@ -45,7 +45,7 @@ export interface Sampler {
traceId: string,
spanName: string,
spanKind: SpanKind,
attributes: Attributes,
attributes: SpanAttributes,
links: Link[]
): SamplingResult;

Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-api/src/trace/SamplingResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { Attributes } from './attributes';
import { SpanAttributes } from './attributes';

/**
* A sampling decision that determines how a {@link Span} will be recorded
Expand Down Expand Up @@ -52,5 +52,5 @@ export interface SamplingResult {
* Caller may call {@link Sampler}.shouldSample any number of times and
* can safely cache the returned value.
*/
attributes?: Readonly<Attributes>;
attributes?: Readonly<SpanAttributes>;
}
4 changes: 2 additions & 2 deletions packages/opentelemetry-api/src/trace/SpanOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { TimeInput } from '../common/Time';
import { Attributes } from './attributes';
import { SpanAttributes } from './attributes';
import { Link } from './link';
import { SpanKind } from './span_kind';

Expand All @@ -30,7 +30,7 @@ export interface SpanOptions {
kind?: SpanKind;

/** A span's attributes */
attributes?: Attributes;
attributes?: SpanAttributes;

/** {@link Link}s span to other spans */
links?: Link[];
Expand Down
6 changes: 3 additions & 3 deletions packages/opentelemetry-api/src/trace/attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
* limitations under the License.
*/

export interface Attributes {
[attributeKey: string]: AttributeValue | undefined;
export interface SpanAttributes {
[attributeKey: string]: SpanAttributeValue | undefined;
}

/**
* Attribute values may be any non-nullish primitive value except an object.
*
* null or undefined attribute values are invalid and will result in undefined behavior.
*/
export type AttributeValue =
export type SpanAttributeValue =
| string
| number
| boolean
Expand Down
6 changes: 3 additions & 3 deletions packages/opentelemetry-api/src/trace/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { Attributes } from './attributes';
import { SpanAttributes } from './attributes';
import { LinkContext } from './link_context';

/**
Expand All @@ -35,6 +35,6 @@ import { LinkContext } from './link_context';
export interface Link {
/** The {@link LinkContext} of a linked span. */
context: LinkContext;
/** A set of {@link Attributes} on the link. */
attributes?: Attributes;
/** A set of {@link SpanAttributes} on the link. */
attributes?: SpanAttributes;
}
16 changes: 8 additions & 8 deletions packages/opentelemetry-api/src/trace/span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

import { Exception } from '../common/Exception';
import { TimeInput } from '../common/Time';
import { Attributes, AttributeValue } from './attributes';
import { SpanAttributes, SpanAttributeValue } from './attributes';
import { SpanContext } from './span_context';
import { Status } from './status';
import { SpanStatus } from './status';

/**
* An interface that represents a span. A span represents a single operation
Expand Down Expand Up @@ -50,7 +50,7 @@ export interface Span {
* @param value the value for this attribute. Setting a value null or
* undefined is invalid and will result in undefined behavior.
*/
setAttribute(key: string, value?: AttributeValue): this;
setAttribute(key: string, value?: SpanAttributeValue): this;

/**
* Sets attributes to the span.
Expand All @@ -59,7 +59,7 @@ export interface Span {
* null or undefined attribute values
* are invalid and will result in undefined behavior.
*/
setAttributes(attributes: Attributes): this;
setAttributes(attributes: SpanAttributes): this;

/**
* Adds an event to the Span.
Expand All @@ -72,18 +72,18 @@ export interface Span {
*/
addEvent(
name: string,
attributesOrStartTime?: Attributes | TimeInput,
attributesOrStartTime?: SpanAttributes | TimeInput,
startTime?: TimeInput
): this;

/**
* Sets a status to the span. If used, this will override the default Span
* status. Default is {@link StatusCode.UNSET}. SetStatus overrides the value
* status. Default is {@link SpanStatusCode.UNSET}. SetStatus overrides the value
* of previous calls to SetStatus on the Span.
*
* @param status the Status to set.
* @param status the SpanStatus to set.
*/
setStatus(status: Status): this;
setStatus(status: SpanStatus): this;

/**
* Updates the Span name.
Expand Down
6 changes: 3 additions & 3 deletions packages/opentelemetry-api/src/trace/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface Status {
export interface SpanStatus {
/** The status code of this message. */
code: StatusCode;
code: SpanStatusCode;
/** A developer-facing error message. */
message?: string;
}

/**
* An enumeration of status codes.
*/
export enum StatusCode {
export enum SpanStatusCode {
/**
* The default status.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import * as assert from 'assert';
import {
StatusCode,
SpanStatusCode,
INVALID_SPANID,
INVALID_TRACEID,
NoopSpan,
Expand All @@ -39,7 +39,7 @@ describe('NoopSpan', () => {
span.addEvent('sent');
span.addEvent('sent', { id: '42', key: 'value' });

span.setStatus({ code: StatusCode.ERROR });
span.setStatus({ code: SpanStatusCode.ERROR });

span.updateName('my-span');

Expand Down
8 changes: 4 additions & 4 deletions packages/opentelemetry-core/src/common/attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AttributeValue, Attributes } from '@opentelemetry/api';
import { SpanAttributeValue, SpanAttributes } from '@opentelemetry/api';

export function sanitizeAttributes(attributes: unknown): Attributes {
const out: Attributes = {};
export function sanitizeAttributes(attributes: unknown): SpanAttributes {
const out: SpanAttributes = {};

if (attributes == null || typeof attributes !== 'object') {
return out;
Expand All @@ -35,7 +35,7 @@ export function sanitizeAttributes(attributes: unknown): Attributes {
return out;
}

export function isAttributeValue(val: unknown): val is AttributeValue {
export function isAttributeValue(val: unknown): val is SpanAttributeValue {
if (val == null) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import {
Attributes,
SpanAttributes,
Context,
getSpanContext,
Link,
Expand Down Expand Up @@ -64,7 +64,7 @@ export class ParentBasedSampler implements Sampler {
traceId: string,
spanName: string,
spanKind: SpanKind,
attributes: Attributes,
attributes: SpanAttributes,
links: Link[]
): SamplingResult {
const parentContext = getSpanContext(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { StatusCode, TraceFlags } from '@opentelemetry/api';
import { SpanStatusCode, TraceFlags } from '@opentelemetry/api';
import {
Counter,
ObserverResult,
Expand Down Expand Up @@ -120,7 +120,7 @@ export const mockedReadableSpan: ReadableSpan = {
startTime: [1574120165, 429803070],
endTime: [1574120165, 438688070],
ended: true,
status: { code: StatusCode.OK },
status: { code: SpanStatusCode.OK },
attributes: { component: 'document-load' },
links: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { StatusCode, TraceFlags } from '@opentelemetry/api';
import { SpanStatusCode, TraceFlags } from '@opentelemetry/api';
import {
Counter,
ObserverResult,
Expand Down Expand Up @@ -104,7 +104,7 @@ export const mockedReadableSpan: ReadableSpan = {
startTime: [1574120165, 429803070],
endTime: [1574120165, 438688070],
ended: true,
status: { code: StatusCode.OK },
status: { code: SpanStatusCode.OK },
attributes: { component: 'document-load' },
links: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { Attributes, Logger, NoopLogger } from '@opentelemetry/api';
import { SpanAttributes, Logger, NoopLogger } from '@opentelemetry/api';
import { ExportResult, ExportResultCode } from '@opentelemetry/core';
import {
CollectorExporterError,
Expand All @@ -34,7 +34,7 @@ export abstract class CollectorExporterBase<
public readonly url: string;
public readonly logger: Logger;
public readonly hostname: string | undefined;
public readonly attributes?: Attributes;
public readonly attributes?: SpanAttributes;
protected _concurrencyLimit: number;
protected _isShutdown: boolean = false;
private _shuttingDownPromise: Promise<void> = Promise.resolve();
Expand Down
Loading