Skip to content

Commit

Permalink
fix: use proper case for log session ID attribute name
Browse files Browse the repository at this point in the history
  • Loading branch information
cthomas-newrelic committed Sep 30, 2024
1 parent a367ae2 commit 4869368
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public abstract class LogReporting {
protected static final String LOG_ERROR_MESSAGE_ATTRIBUTE = "error.message";
protected static final String LOG_ERROR_STACK_ATTRIBUTE = "error.stack";
protected static final String LOG_ERROR_CLASS_ATTRIBUTE = "error.class";
protected static final String lOG_SESSION_ID = "sessionId";
protected static final String LOG_SESSION_ID = "sessionId";

protected static LogLevel logLevel = LogLevel.WARN;
protected static AgentLogger agentLogger = new AgentLogger();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package com.newrelic.agent.android.logging;

import com.newrelic.agent.android.AgentConfiguration;
import com.newrelic.agent.android.harvest.Harvest;
import com.newrelic.agent.android.harvest.HarvestLifecycleAware;
import com.newrelic.agent.android.util.NamedThreadFactory;

Expand Down Expand Up @@ -247,7 +246,7 @@ static Map<String, Object> getCommonBlockAttributes() {

attrs.put(LogReporting.LOG_TIMESTAMP_ATTRIBUTE, System.currentTimeMillis());
attrs.put(LogReporting.LOG_ENTITY_ATTRIBUTE, AgentConfiguration.getInstance().getEntityGuid());
attrs.put(LogReporting.lOG_SESSION_ID, AgentConfiguration.getInstance().getSessionID());
attrs.put(LogReporting.LOG_SESSION_ID, AgentConfiguration.getInstance().getSessionID());

return attrs;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public void log() throws Exception {
JsonObject jsonObject = jsonArray.get(0).getAsJsonObject();
Assert.assertTrue(jsonObject.get(LogReporting.LOG_TIMESTAMP_ATTRIBUTE).getAsLong() >= tStart);
Assert.assertFalse(jsonObject.has(LogReporting.LOG_ATTRIBUTES_ATTRIBUTE));
Assert.assertTrue(jsonObject.has(LogReporting.lOG_SESSION_ID));
Assert.assertEquals(jsonObject.get(LogReporting.lOG_SESSION_ID).getAsString(), AgentConfiguration.getInstance().getSessionID());
Assert.assertTrue(jsonObject.has(LogReporting.LOG_SESSION_ID));
Assert.assertEquals(jsonObject.get(LogReporting.LOG_SESSION_ID).getAsString(), AgentConfiguration.getInstance().getSessionID());
}

@Test
Expand All @@ -122,8 +122,8 @@ public void logThrowable() throws Exception {
Assert.assertTrue(jsonObject.get(LogReporting.LOG_TIMESTAMP_ATTRIBUTE).getAsLong() >= tStart);
Assert.assertEquals(jsonObject.get(LogReporting.LOG_MESSAGE_ATTRIBUTE).getAsString(), throwable.getLocalizedMessage());
Assert.assertFalse(jsonObject.has(LogReporting.LOG_ATTRIBUTES_ATTRIBUTE));
Assert.assertTrue(jsonObject.has(LogReporting.lOG_SESSION_ID));
Assert.assertEquals(jsonObject.get(LogReporting.lOG_SESSION_ID).getAsString(), AgentConfiguration.getInstance().getSessionID());
Assert.assertTrue(jsonObject.has(LogReporting.LOG_SESSION_ID));
Assert.assertEquals(jsonObject.get(LogReporting.LOG_SESSION_ID).getAsString(), AgentConfiguration.getInstance().getSessionID());
}

@Test
Expand All @@ -142,8 +142,8 @@ public void logAttributes() throws Exception {
JsonObject jsonObject = jsonArray.get(0).getAsJsonObject();
Assert.assertTrue(jsonObject.get(LogReporting.LOG_TIMESTAMP_ATTRIBUTE).getAsLong() >= tStart);
Assert.assertEquals(jsonObject.get(LogReporting.LOG_MESSAGE_ATTRIBUTE).getAsString(), msg);
Assert.assertTrue(jsonObject.has(LogReporting.lOG_SESSION_ID));
Assert.assertEquals(jsonObject.get(LogReporting.lOG_SESSION_ID).getAsString(), AgentConfiguration.getInstance().getSessionID());
Assert.assertTrue(jsonObject.has(LogReporting.LOG_SESSION_ID));
Assert.assertEquals(jsonObject.get(LogReporting.LOG_SESSION_ID).getAsString(), AgentConfiguration.getInstance().getSessionID());
}

@Test
Expand All @@ -162,8 +162,8 @@ public void logAll() throws Exception {
JsonObject jsonObject = jsonArray.get(0).getAsJsonObject();
Assert.assertTrue(jsonObject.get(LogReporting.LOG_TIMESTAMP_ATTRIBUTE).getAsLong() >= tStart);
Assert.assertEquals(jsonObject.get(LogReporting.LOG_MESSAGE_ATTRIBUTE).getAsString(), msg);
Assert.assertTrue(jsonObject.has(LogReporting.lOG_SESSION_ID));
Assert.assertEquals(jsonObject.get(LogReporting.lOG_SESSION_ID).getAsString(), AgentConfiguration.getInstance().getSessionID());
Assert.assertTrue(jsonObject.has(LogReporting.LOG_SESSION_ID));
Assert.assertEquals(jsonObject.get(LogReporting.LOG_SESSION_ID).getAsString(), AgentConfiguration.getInstance().getSessionID());
}

@Test
Expand All @@ -179,8 +179,8 @@ public void appendLog() throws Exception {
Assert.assertTrue(jsonObject.get(LogReporting.LOG_TIMESTAMP_ATTRIBUTE).getAsLong() >= tStart);
Assert.assertEquals(jsonObject.get(LogReporting.LOG_MESSAGE_ATTRIBUTE).getAsString(), msg);
Assert.assertFalse(jsonObject.has(LogReporting.LOG_ATTRIBUTES_ATTRIBUTE));
Assert.assertTrue(jsonObject.has(LogReporting.lOG_SESSION_ID));
Assert.assertEquals(jsonObject.get(LogReporting.lOG_SESSION_ID).getAsString(), AgentConfiguration.getInstance().getSessionID());
Assert.assertTrue(jsonObject.has(LogReporting.LOG_SESSION_ID));
Assert.assertEquals(jsonObject.get(LogReporting.LOG_SESSION_ID).getAsString(), AgentConfiguration.getInstance().getSessionID());
}

// @Test FIXME flakey test
Expand Down Expand Up @@ -211,8 +211,8 @@ public void testPayloadFormat() throws IOException {
JsonObject json = jsonElement.getAsJsonObject();
Assert.assertTrue("Log json should contain timestamp", json.has(LogReporting.LOG_TIMESTAMP_ATTRIBUTE));
Assert.assertTrue("Log json should contain log level", json.has(LogReporting.LOG_LEVEL_ATTRIBUTE));
Assert.assertTrue(json.has(LogReporting.lOG_SESSION_ID));
Assert.assertEquals(json.get(LogReporting.lOG_SESSION_ID).getAsString(), AgentConfiguration.getInstance().getSessionID());
Assert.assertTrue(json.has(LogReporting.LOG_SESSION_ID));
Assert.assertEquals(json.get(LogReporting.LOG_SESSION_ID).getAsString(), AgentConfiguration.getInstance().getSessionID());
}

// Element 1:
Expand Down Expand Up @@ -275,8 +275,8 @@ public void testEntityGuid() throws IOException {
JsonObject jsonObject = jsonArray.get(0).getAsJsonObject();
Assert.assertTrue(jsonObject.get(LogReporting.LOG_TIMESTAMP_ATTRIBUTE).getAsLong() >= tStart);
Assert.assertEquals(jsonObject.get(LogReporting.LOG_ENTITY_ATTRIBUTE).getAsString(), AgentConfiguration.getInstance().getEntityGuid());
Assert.assertTrue(jsonObject.has(LogReporting.lOG_SESSION_ID));
Assert.assertEquals(jsonObject.get(LogReporting.lOG_SESSION_ID).getAsString(), AgentConfiguration.getInstance().getSessionID());
Assert.assertTrue(jsonObject.has(LogReporting.LOG_SESSION_ID));
Assert.assertEquals(jsonObject.get(LogReporting.LOG_SESSION_ID).getAsString(), AgentConfiguration.getInstance().getSessionID());
}

/**
Expand Down Expand Up @@ -389,8 +389,8 @@ public void testConcurrentLoad() throws Exception {
Assert.assertTrue(jsonObject.get(LogReporting.LOG_TIMESTAMP_ATTRIBUTE).getAsLong() >= tStart);
Assert.assertTrue(jsonObject.has(LogReporting.LOG_MESSAGE_ATTRIBUTE));
Assert.assertFalse(jsonObject.has(LogReporting.LOG_ATTRIBUTES_ATTRIBUTE));
Assert.assertTrue(jsonObject.has(LogReporting.lOG_SESSION_ID));
Assert.assertEquals(jsonObject.get(LogReporting.lOG_SESSION_ID).getAsString(), AgentConfiguration.getInstance().getSessionID());
Assert.assertTrue(jsonObject.has(LogReporting.LOG_SESSION_ID));
Assert.assertEquals(jsonObject.get(LogReporting.LOG_SESSION_ID).getAsString(), AgentConfiguration.getInstance().getSessionID());
}
}

Expand Down

0 comments on commit 4869368

Please sign in to comment.