Search in sources :

Example 1 with AnalyticsEvent

use of com.newrelic.agent.model.AnalyticsEvent in project newrelic-java-agent by newrelic.

the class TransactionEventTest method testJSON.

@Test
public void testJSON() throws Exception {
    float duration = 0.001931f;
    AnalyticsEvent event = baseBuilder(duration).build();
    JSONArray jsonArray = (JSONArray) AgentHelper.serializeJSON(event);
    assertEquals(1, jsonArray.size());
    JSONObject jsonObject = (JSONObject) jsonArray.get(0);
    assertEquals(9, jsonObject.size());
    assertEquals(startTime, jsonObject.get("timestamp"));
    assertEquals(metricName, jsonObject.get("name"));
    assertEquals(duration, ((Number) jsonObject.get("duration")).floatValue(), Float.NaN);
    assertEquals("Transaction", jsonObject.get("type"));
    assertEquals(duration, ((Number) jsonObject.get("totalTime")).floatValue(), Float.NaN);
    assertEquals(.25, ((Number) jsonObject.get("priority")).floatValue(), Float.NaN);
}
Also used : AnalyticsEvent(com.newrelic.agent.model.AnalyticsEvent) JSONObject(org.json.simple.JSONObject) JSONArray(org.json.simple.JSONArray) Test(org.junit.Test)

Example 2 with AnalyticsEvent

use of com.newrelic.agent.model.AnalyticsEvent in project newrelic-java-agent by newrelic.

the class TransactionEventTest method testJSONDTIntrinsics.

@Test
public void testJSONDTIntrinsics() throws Exception {
    float duration = 0.001931f;
    AnalyticsEvent event = baseBuilder(duration).setDistributedTraceIntrinsics(Collections.<String, Object>singletonMap("dt-intrinsic", "yup")).build();
    JSONArray jsonArray = (JSONArray) AgentHelper.serializeJSON(event);
    assertEquals(1, jsonArray.size());
    JSONObject intrinsicsJson = (JSONObject) jsonArray.get(0);
    assertEquals("yup", intrinsicsJson.get("dt-intrinsic"));
}
Also used : AnalyticsEvent(com.newrelic.agent.model.AnalyticsEvent) JSONObject(org.json.simple.JSONObject) JSONArray(org.json.simple.JSONArray) JSONObject(org.json.simple.JSONObject) Test(org.junit.Test)

Aggregations

AnalyticsEvent (com.newrelic.agent.model.AnalyticsEvent)2 JSONArray (org.json.simple.JSONArray)2 JSONObject (org.json.simple.JSONObject)2 Test (org.junit.Test)2