-
Notifications
You must be signed in to change notification settings - Fork 1k
Api separation #727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Api separation #727
Changes from 1 commit
357267e
bb1c264
bb13ea8
53e4197
298ee9e
0def03a
7a30fc1
b53bfbe
4769174
23232ed
814891c
8e6a95e
9a671ae
a6b7db8
9314357
7fc7247
fb91c52
d9e81d1
2d5f329
ebab028
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /*! | ||
| * Copyright 2020, OpenTelemetry Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { MeterRegistry } from '../metrics/MeterRegistry'; | ||
| import { NOOP_METER_REGISTRY } from '../metrics/NoopMeterRegistry'; | ||
|
|
||
| export class MetricsAPI { | ||
| private static _instance?: MetricsAPI; | ||
| private _meterRegistry: MeterRegistry = NOOP_METER_REGISTRY; | ||
|
|
||
| private constructor() {} | ||
|
|
||
| public static getInstance(): MetricsAPI { | ||
| if (!this._instance) { | ||
| this._instance = new MetricsAPI(); | ||
| } | ||
|
|
||
| return this._instance; | ||
| } | ||
|
|
||
| public initGlobalMeterRegistry(registry: MeterRegistry) { | ||
| this._meterRegistry = registry; | ||
| } | ||
|
|
||
| public getMeterRegistry(): MeterRegistry { | ||
| return this._meterRegistry; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /*! | ||
| * Copyright 2020, OpenTelemetry Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { NOOP_TRACER_REGISTRY } from '../trace/NoopTracerRegistry'; | ||
| import { TracerRegistry } from '../trace/tracer_registry'; | ||
|
|
||
| export class TracingAPI { | ||
dyladan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
dyladan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| private static _instance?: TracingAPI; | ||
| private _tracerRegistry: TracerRegistry = NOOP_TRACER_REGISTRY; | ||
|
|
||
| private constructor() {} | ||
|
|
||
| public static getInstance(): TracingAPI { | ||
| if (!this._instance) { | ||
| this._instance = new TracingAPI(); | ||
| } | ||
|
|
||
| return this._instance; | ||
| } | ||
|
|
||
| public initGlobalTracerRegistry(registry: TracerRegistry) { | ||
| this._tracerRegistry = registry; | ||
| } | ||
|
|
||
| public getTracerRegistry(): TracerRegistry { | ||
| return this._tracerRegistry; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,21 +14,33 @@ | |
| * limitations under the License. | ||
| */ | ||
|
|
||
| import * as types from '@opentelemetry/types'; | ||
| import { INVALID_SPAN_CONTEXT } from '../trace/spancontext-utils'; | ||
| import { TimeInput } from '../common/Time'; | ||
| import { Attributes } from './attributes'; | ||
| import { Span } from './span'; | ||
| import { SpanContext } from './span_context'; | ||
| import { Status } from './status'; | ||
| import { TraceFlags } from './trace_flags'; | ||
|
|
||
| export const INVALID_TRACE_ID = '0'; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is it
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was the exact example in the old |
||
| export const INVALID_SPAN_ID = '0'; | ||
| const INVALID_SPAN_CONTEXT: SpanContext = { | ||
| traceId: INVALID_TRACE_ID, | ||
| spanId: INVALID_SPAN_ID, | ||
| traceFlags: TraceFlags.UNSAMPLED, | ||
| }; | ||
|
|
||
| /** | ||
| * The NoopSpan is the default {@link Span} that is used when no Span | ||
| * implementation is available. All operations are no-op including context | ||
| * propagation. | ||
| */ | ||
| export class NoopSpan implements types.Span { | ||
| export class NoopSpan implements Span { | ||
| constructor( | ||
| private readonly _spanContext: types.SpanContext = INVALID_SPAN_CONTEXT | ||
| private readonly _spanContext: SpanContext = INVALID_SPAN_CONTEXT | ||
| ) {} | ||
|
|
||
| // Returns a SpanContext. | ||
| context(): types.SpanContext { | ||
| context(): SpanContext { | ||
| return this._spanContext; | ||
| } | ||
|
|
||
|
|
@@ -38,22 +50,22 @@ export class NoopSpan implements types.Span { | |
| } | ||
|
|
||
| // By default does nothing | ||
| setAttributes(attributes: types.Attributes): this { | ||
| setAttributes(attributes: Attributes): this { | ||
| return this; | ||
| } | ||
|
|
||
| // By default does nothing | ||
| addEvent(name: string, attributes?: types.Attributes): this { | ||
| addEvent(name: string, attributes?: Attributes): this { | ||
| return this; | ||
| } | ||
|
|
||
| // By default does nothing | ||
| addLink(spanContext: types.SpanContext, attributes?: types.Attributes): this { | ||
| addLink(spanContext: SpanContext, attributes?: Attributes): this { | ||
| return this; | ||
| } | ||
|
|
||
| // By default does nothing | ||
| setStatus(status: types.Status): this { | ||
| setStatus(status: Status): this { | ||
| return this; | ||
| } | ||
|
|
||
|
|
@@ -63,7 +75,7 @@ export class NoopSpan implements types.Span { | |
| } | ||
|
|
||
| // By default does nothing | ||
| end(endTime?: types.TimeInput): void {} | ||
| end(endTime?: TimeInput): void {} | ||
|
|
||
| // isRecording always returns false for noopSpan. | ||
| isRecording(): boolean { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.