Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TraceWriter

A class representing a service that publishes traces in the background.

Hierarchy

  • Service
    • TraceWriter

Index

Constructors

constructor

  • Constructs a new TraceWriter instance.

    constructor

    Parameters

    • config: TraceWriterConfig

      A config object containing information about authorization credentials.

    • logger: Logger

      The Trace Agent's logger object.

    Returns TraceWriter

Properties

Promise

Promise: PromiseConstructor

authClient

authClient: GoogleAuth

baseUrl

baseUrl: string

buffer

buffer: string[]

Stringified traces to be published

defaultLabels

defaultLabels: LabelObject

Default labels to be attached to written spans

isActive

isActive: boolean

Whether the trace writer is active

makeAuthenticatedRequest

makeAuthenticatedRequest: MakeAuthenticatedRequest

projectId

projectId: string

Methods

Private flushBuffer

  • flushBuffer(): void
  • Serializes the buffered traces to be published asynchronously.

    Returns void

getConfig

getHostname

  • getHostname(cb: function): void
  • Parameters

    • cb: function
        • (hostname: string): void
        • Parameters

          • hostname: string

          Returns void

    Returns void

getInstanceId

  • getInstanceId(cb: function): void
  • Parameters

    • cb: function
        • (instanceId?: undefined | number): void
        • Parameters

          • Optional instanceId: undefined | number

          Returns void

    Returns void

getProjectId

  • getProjectId(): Promise<string>

Protected getProjectIdAsync

  • getProjectIdAsync(): Promise<string>
  • Returns Promise<string>

initialize

  • initialize(cb: function): void
  • Parameters

    • cb: function
        • (err?: Error): void
        • Parameters

          • Optional err: Error

          Returns void

    Returns void

Private publish

  • publish(json: string): void
  • Publishes flushed traces to the network.

    Parameters

    • json: string

      The stringified json representation of the queued traces.

    Returns void

Private queueTrace

  • queueTrace(trace: Trace): void
  • Buffers the provided trace to be published.

    Parameters

    • trace: Trace

      The trace to be queued.

    Returns void

Private request

  • request(reqOpts: DecorateRequestOptions): Promise<r.Response>
  • request(reqOpts: DecorateRequestOptions, callback: BodyResponseCallback): void
  • Make an authenticated API request.

    Parameters

    • reqOpts: DecorateRequestOptions

      Request options that are passed to request.

    Returns Promise<r.Response>

  • Parameters

    • reqOpts: DecorateRequestOptions
    • callback: BodyResponseCallback

    Returns void

Private requestStream

  • requestStream(reqOpts: DecorateRequestOptions): r.Request
  • Make an authenticated API request.

    Parameters

    • reqOpts: DecorateRequestOptions

      Request options that are passed to request.

    Returns r.Request

Private request_

  • request_(reqOpts: StreamRequestOptions): r.Request
  • request_(reqOpts: DecorateRequestOptions): Promise<r.Response>
  • Make an authenticated API request.

    Parameters

    • reqOpts: StreamRequestOptions

      Request options that are passed to request.

    Returns r.Request

  • Parameters

    • reqOpts: DecorateRequestOptions

    Returns Promise<r.Response>

Private scheduleFlush

  • scheduleFlush(): void
  • Flushes the buffer of traces at a regular interval controlled by the flushDelay property of this TraceWriter's config.

    Returns void

stop

  • stop(): void

writeSpan

  • writeSpan(trace: Trace): void
  • Ensures that all sub spans of the provided Trace object are closed and then queues the span data to be published.

    Parameters

    • trace: Trace

      The trace to be queued.

    Returns void

Generated using TypeDoc