Index

Methods

getAttribute

  • getAttribute(attrstring):string |undefined
  • Retrieves the value that the custom attribute is set to.

    Parameters

    • attr:string

      Name of the custom attribute.

    Returnsstring |undefined

getAttributes

  • getAttributes():{}
  • Returns a map of all custom attributes of atraceinstance.

    Returns{}

    • [key:string]:string

getMetric

  • getMetric(metricNamestring):number
  • Returns the value of the custom metric by that name. If a custom metric with that name doesnot exist returns zero.

    Parameters

    • metricName:string

      Name of the custom metric.

    Returnsnumber

incrementMetric

  • incrementMetric(metricNamestring, num?: number):void
  • Adds to the value of a custom metric. If a custom metric with the provided name does notexist, it creates one with that name and the value equal to the given number.

    Parameters

    • metricName:string

      The name of the custom metric.

    • Optional num:number

      The number to be added to the value of the custom metric. If not provided, ituses a default value of one.

    Returnsvoid

putAttribute

  • putAttribute(attrstring, valuestring):void
  • Set a custom attribute of atrace to a certain value.

    Parameters

    • attr:string

      Name of the custom attribute.

    • value:string

      Value of the custom attribute.

    Returnsvoid

putMetric

  • putMetric(metricNamestring, numnumber):void
  • Sets the value of the specified custom metric to the given number regardless of whethera metric with that name already exists on thetraceinstance or not.

    Parameters

    • metricName:string

      Name of the custom metric.

    • num:number

      Value to of the custom metric.

    Returnsvoid

record

  • record(startTimenumber, durationnumber, options?: {attributes?:{};metrics?:{} }):void
  • Records atrace from given parameters. This provides adirect way to usetrace without a need to start/stop.This is useful for use cases in which thetrace cannotdirectly be used (e.g. if the duration was captured before the Performance SDK was loaded).

    Parameters

    • startTime:number

      Trace start time since epoch in millisec.

    • duration:number

      The duraction of the trace in millisec.

    • Optional options:{attributes?:{};metrics?:{} }

      An object which can optionally hold maps of custom metrics andcustom attributes.

      • Optional attributes?:{}
        • [key:string]:string
      • Optional metrics?:{}
        • [key:string]:number

    Returnsvoid

removeAttribute

  • removeAttribute(attrstring):void
  • Removes the specified custom attribute from atraceinstance.

    Parameters

    • attr:string

      Name of the custom attribute.

    Returnsvoid

start

  • start():void
  • Starts the timing for thetrace instance.

    Returnsvoid

stop

  • stop():void
  • Stops the timing of thetrace instance and logs thedata of the instance.

    Returnsvoid

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2022-07-27 UTC.