Class RequestTelemetry

java.lang.Object
com.microsoft.applicationinsights.telemetry.BaseTelemetry
com.microsoft.applicationinsights.telemetry.RequestTelemetry
All Implemented Interfaces:
Telemetry

public final class RequestTelemetry extends BaseTelemetry
Encapsulates information about a web request handled by the application.

You can send information about requests processed by your web application to Application Insights by passing an instance of this class to the 'trackRequest' method of the TelemetryClient

  • Constructor Details

    • RequestTelemetry

      public RequestTelemetry(String name, Date timestamp, Duration duration, String responseCode, boolean success)
      Creates a new instance of the HttpRequestTelemetry class with the given name, time stamp, duration, HTTP response code and success property values.
      Parameters:
      name - A user-friendly name for the request.
      timestamp - The time of the request.
      duration - The duration, as an Duration instance, of the request processing.
      responseCode - The HTTP response code.
      success - 'true' if the request was a success, 'false' otherwise.
    • RequestTelemetry

      public RequestTelemetry(String name, Date timestamp, long duration, String responseCode, boolean success)
      Creates a new instance of the HttpRequestTelemetry class with the given name, time stamp, duration, HTTP response code and success property values.
      Parameters:
      name - A user-friendly name for the request.
      timestamp - The time of the request.
      duration - The duration, in milliseconds, of the request processing.
      responseCode - The HTTP response code.
      success - 'true' if the request was a success, 'false' otherwise.
    • RequestTelemetry

      public RequestTelemetry()
      Initializes a new instance of the HttpRequestTelemetry class.
  • Method Details

    • setTimestamp

      public void setTimestamp(Date timestamp)
      Sets the StartTime.
      Specified by:
      setTimestamp in interface Telemetry
      Overrides:
      setTimestamp in class BaseTelemetry
    • getName

      public String getName()
      Gets or human-readable name of the requested page.
    • setName

      public void setName(String name)
      Sets or human-readable name of the requested page.
    • getId

      public String getId()
      Gets the unique identifier of the request.
    • setId

      public void setId(String id)
      Sets the unique identifier of the request.
    • getResponseCode

      public String getResponseCode()
      Gets response code returned by the application after handling the request.
    • setResponseCode

      public void setResponseCode(String responseCode)
      Sets response code returned by the application after handling the request.
    • getSource

      public String getSource()
      Gets the source for the request telemetry object. This often is an ID identifying the caller.
    • setSource

      public void setSource(String value)
      Sets the source for the request telemetry object. This often is an ID identifying the caller.
    • isSuccess

      public boolean isSuccess()
      Gets a value indicating whether application handled the request successfully.
    • setSuccess

      public void setSuccess(boolean success)
      Sets a value indicating whether application handled the request successfully.
    • getDuration

      public Duration getDuration()
      Gets the amount of time it took the application to handle the request.
    • setDuration

      public void setDuration(Duration duration)
      Sets the amount of time it took the application to handle the request.
    • getUrl

      @Nullable public URL getUrl() throws MalformedURLException
      Gets request url.
      Throws:
      MalformedURLException
    • setUrl

      public void setUrl(URL url)
      Sets request url.
    • setUrl

      public void setUrl(String url) throws MalformedURLException
      Sets request url.
      Throws:
      MalformedURLException
    • getMetrics

      public ConcurrentMap<String,Double> getMetrics()
      Gets a map of application-defined request metrics.
    • getData

      protected RequestData getData()
      Specified by:
      getData in class BaseTelemetry