Skip to content
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

[Core Tracing] Add plugin type to tracer interface #4668

Merged
merged 3 commits into from
Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import { Tracer } from "../../interfaces/tracer";
import { SpanOptions } from "../../interfaces/SpanOptions";
import { Span } from "../../interfaces/span";
import { SpanNoOpImpl } from "./spanNoOpImpl";
import { SupportedPlugins } from '../../utils/supportedPlugins';

export class TracerNoOpImpl implements Tracer {
public readonly pluginType = SupportedPlugins.NOOP;

getCurrentSpan(): Span {
throw new Error("Method not implemented.");
}
Expand Down
6 changes: 6 additions & 0 deletions sdk/core/core-tracing/lib/interfaces/tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { Span } from './span';
import { SpanOptions } from './SpanOptions';
import { SupportedPlugins } from '../utils/supportedPlugins';

/**
* Tracer provides an interface for creating {@link Span}s and propagating
Expand All @@ -25,6 +26,11 @@ import { SpanOptions } from './SpanOptions';
* that this class offers APIs to facilitate both usages.
*/
export interface Tracer {
/**
* Returns the type of the plugin being used by the tracer.
* @returns the type of the plugin being used by the tracer.
*/
pluginType: SupportedPlugins
/**
* Returns the current Span from the current context if available.
*
Expand Down
3 changes: 3 additions & 0 deletions sdk/core/core-tracing/lib/plugins/noop/noOpTracePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Span } from "../../interfaces/span";
import { SpanOptions } from "../../interfaces/SpanOptions";
import { NoOpSpanPlugin } from "./noOpSpanPlugin";
import { SpanNoOpImpl } from "../../implementations/noop/spanNoOpImpl";
import { SupportedPlugins } from '../../utils/supportedPlugins';

export class NoOpTracePlugin implements Tracer {
private _tracer: any;
Expand All @@ -11,6 +12,8 @@ export class NoOpTracePlugin implements Tracer {
this._tracer = tracer;
}

public readonly pluginType = SupportedPlugins.NOOP;

startSpan(name: string, options?: SpanOptions): Span {
const span = new SpanNoOpImpl();
const noOpSpanPlugin = new NoOpSpanPlugin(span);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ import { Tracer } from "../../interfaces/tracer";
import { SpanOptions } from "../../interfaces/SpanOptions";
import { Span } from "../../interfaces/span";
import { OpenCensusSpanPlugin } from "../opencensus/openCensusSpanPlugin";
import { SupportedPlugins } from '../../utils/supportedPlugins';

export class OpenCensusTracePlugin implements Tracer {
private _tracer: any;

public constructor(tracer: any) {
this._tracer = tracer;
}


public readonly pluginType = SupportedPlugins.OPENCENSUS;

startSpan(name: string, options?: SpanOptions): Span {
const parent = options
? options.parent
Expand Down
7 changes: 7 additions & 0 deletions sdk/core/core-tracing/review/core-tracing.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export class NoOpTracePlugin implements Tracer {
// (undocumented)
getHttpTextFormat(): unknown;
// (undocumented)
readonly pluginType: SupportedPlugins;
// (undocumented)
recordSpanData(span: Span): void;
// (undocumented)
startSpan(name: string, options?: SpanOptions): Span;
Expand Down Expand Up @@ -122,6 +124,8 @@ export class OpenCensusTracePlugin implements Tracer {
// (undocumented)
getHttpTextFormat(): unknown;
// (undocumented)
readonly pluginType: SupportedPlugins;
// (undocumented)
recordSpanData(span: Span): void;
// (undocumented)
startSpan(name: string, options?: SpanOptions): Span;
Expand Down Expand Up @@ -231,6 +235,7 @@ export interface Tracer {
getBinaryFormat(): unknown;
getCurrentSpan(): Span;
getHttpTextFormat(): unknown;
pluginType: SupportedPlugins;
recordSpanData(span: Span): void;
startSpan(name: string, options?: SpanOptions): Span;
withSpan<T extends (...args: unknown[]) => unknown>(span: Span, fn: T): ReturnType<T>;
Expand All @@ -245,6 +250,8 @@ export class TracerNoOpImpl implements Tracer {
// (undocumented)
getHttpTextFormat(): unknown;
// (undocumented)
readonly pluginType: SupportedPlugins;
// (undocumented)
recordSpanData(span: Span): void;
// (undocumented)
startSpan(name: string, options?: SpanOptions | undefined): Span;
Expand Down