Skip to content

Commit

Permalink
Merge pull request #272 from newrelic/prod75
Browse files Browse the repository at this point in the history
New Relic iOS agent 7.5.0 (Production)
  • Loading branch information
cdillard-NewRelic authored Jun 27, 2024
2 parents 9e1a24f + ae8e415 commit e80fc0b
Show file tree
Hide file tree
Showing 156 changed files with 4,152 additions and 1,110 deletions.
29 changes: 28 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,39 @@ jobs:

- name: Run tests on tvOS (using fastlane)
run: bundle exec fastlane runTVOSTests

testWatchOS:
name : TestWatchOS
# runs-on: will be set to macos-latest when running on actual GHA.
# *** runs-on: ubuntu-latest is used when running via act on mac os. ***
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true

- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '14.3'

- name: Install lcov
run: brew install lcov

- name: Update gem
run: bundle update

- name: Install gems
run: bundle install

- name: Run tests on watchOS (using fastlane)
run: bundle exec fastlane runWatchOSTests

deployS3:
name: DeployS3
# runs-on: will be set to macos-latest when running on actual GHA.
# *** runs-on: ubuntu-latest is used when running via act on mac os. ***
runs-on: macos-13
needs: [testIOS, testTVOS]
needs: [testIOS, testTVOS, testWatchOS]
if: github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/main'
outputs:
version: ${{ steps.setOutput.outputs.version }}
Expand Down
1,444 changes: 1,406 additions & 38 deletions Agent.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

72 changes: 72 additions & 0 deletions Agent.xcodeproj/xcshareddata/xcschemes/Agent-watchOS.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "348232212BC5EEE60070FAC3"
BuildableName = "NewRelic.framework"
BlueprintName = "Agent-watchOS"
ReferencedContainer = "container:Agent.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<TestPlans>
<TestPlanReference
reference = "container:Tests/Agent-watchOS.xctestplan"
default = "YES">
</TestPlanReference>
</TestPlans>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "348232212BC5EEE60070FAC3"
BuildableName = "NewRelic.framework"
BlueprintName = "Agent-watchOS"
ReferencedContainer = "container:Agent.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
2 changes: 1 addition & 1 deletion Agent.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Agent/ActivityTracing/NRMAActivityNameGenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ + (NSString*) generateActivityNameFromClass:(Class)cls selector:(SEL)selector
NSString* name = nil;
NSString* class = [self translationNameFromClass:NSStringFromClass(cls)];
NSString* sel = NSStringFromSelector(selector);
#if !TARGET_OS_WATCH
if ([cls isSubclassOfClass:[UIViewController class]]) {
if ([kNRMA_selector_viewDidLoad isEqualToString:sel] ||
[kNRMA_selector_viewWillAppear isEqualToString:sel]) {
Expand All @@ -28,6 +29,9 @@ + (NSString*) generateActivityNameFromClass:(Class)cls selector:(SEL)selector
} else {
name = class;
}
#else
name = class;
#endif

return name;
}
Expand Down
2 changes: 1 addition & 1 deletion Agent/ActivityTracing/NRMALastActivityTraceController.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ + (void) storeLastActivityStampWithName:(NSString*)name
duration:(NSNumber*)durationMillis
{
if (name == nil || timestampMillis == nil || durationMillis == nil) {
NRLOG_VERBOSE(@"Attempted to store last activity with incomplete data.");
NRLOG_AGENT_VERBOSE(@"Attempted to store last activity with incomplete data.");
return;
}
@synchronized(kNRMALastExecutedActivityLock) {
Expand Down
20 changes: 10 additions & 10 deletions Agent/ActivityTracing/NRMAThreadLocalStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ + (NRMATrace*)threadLocalTrace
+ (void)setThreadRootTrace:(NRMATrace *)root
{
if (root == nil) {
NRLOG_VERBOSE(@"Attempted to load a nil trace.");
NRLOG_AGENT_VERBOSE(@"Attempted to load a nil trace.");
return;
}

Expand All @@ -55,7 +55,7 @@ + (void)setThreadRootTrace:(NRMATrace *)root
[stack addObject:root];
}

NRLOG_VERBOSE(@"Trace %@ is now active", root);
NRLOG_AGENT_VERBOSE(@"Trace %@ is now active", root);
}

/** delete thread-local data on all threads */
Expand All @@ -77,7 +77,7 @@ + (void)destroyStore
+ (BOOL) pushChild:(NRMATrace *)childTrace forParent:(NRMATrace *)parentTrace
{
if (childTrace == nil || parentTrace == nil) {
NRLOG_VERBOSE(@"<Activity: \"%@\"> Trace enterMethod has nil child or parent trace segment. p=%@, c=%@",[NRMATraceController getCurrentActivityName], parentTrace, childTrace);
NRLOG_AGENT_VERBOSE(@"<Activity: \"%@\"> Trace enterMethod has nil child or parent trace segment. p=%@, c=%@",[NRMATraceController getCurrentActivityName], parentTrace, childTrace);
return NO;
}
BOOL parentIsOnSameThread = [self isThreadMatchForChild:childTrace parent:parentTrace];
Expand All @@ -101,7 +101,7 @@ + (int) prepareNewThread:(NSMutableArray*)stack child:(NRMATrace*)child withPare
{
int error = 0;
if (stack.count > 0) {
NRLOG_VERBOSE(@"<Activity: \"%@\"> thread local stack is not empty! Entering thread %ud from %ud, p=%@, c=%@, stack=%@",
NRLOG_AGENT_VERBOSE(@"<Activity: \"%@\"> thread local stack is not empty! Entering thread %ud from %ud, p=%@, c=%@, stack=%@",
[NRMATraceController getCurrentActivityName],
child.threadInfo.identity,
parent.threadInfo.identity,
Expand All @@ -125,7 +125,7 @@ + (int) prepareSameThread:(NSMutableArray*)stack child:(NRMATrace*)child withPar

if ([NRMAThreadLocalStore threadLocalTrace] != parent) {
if (![self validateIsSerialParent:parent child:child]) {
NRLOG_ERROR(@"<Activity: \"%@\"> threadLocalTrace is not parentTrace! On thread %ud, p=%@, c=%@, f=%@, stack=%@",
NRLOG_AGENT_ERROR(@"<Activity: \"%@\"> threadLocalTrace is not parentTrace! On thread %ud, p=%@, c=%@, f=%@, stack=%@",
[NRMATraceController getCurrentActivityName],
child.threadInfo.identity,
parent, child, [NRMAThreadLocalStore threadLocalTrace], stack);
Expand All @@ -138,7 +138,7 @@ + (int) prepareSameThread:(NSMutableArray*)stack child:(NRMATrace*)child withPar
} else if ([stack lastObject] != parent) {
if (![self validateIsSerialParent:parent child:child]) {

NRLOG_ERROR(@"<Activity: \"%@\"> parentTrace is not at bottom of threadLocalStack! On thread %ud, p=%@, c=%@, f=%@, stack=%@",
NRLOG_AGENT_ERROR(@"<Activity: \"%@\"> parentTrace is not at bottom of threadLocalStack! On thread %ud, p=%@, c=%@, f=%@, stack=%@",
[NRMATraceController getCurrentActivityName],
child.threadInfo.identity,
parent, child, [NRMAThreadLocalStore threadLocalTrace], stack);
Expand Down Expand Up @@ -184,12 +184,12 @@ + (BOOL)popCurrentTraceIfEqualTo:(NRMATrace*)trace returningParent:(NRMATrace *_
if (trace.threadInfo.identity != pthread_mach_thread_np(pthread_self()))
{
// whoops, trace is on the wrong thread
NRLOG_VERBOSE(@"<Activity: \"%@\"> popCurrentTrace: exited trace is not on the current thread! et=%@, tlc=%@",[NRMATraceController getCurrentActivityName], trace, currentTrace);
NRLOG_AGENT_VERBOSE(@"<Activity: \"%@\"> popCurrentTrace: exited trace is not on the current thread! et=%@, tlc=%@",[NRMATraceController getCurrentActivityName], trace, currentTrace);
return NO;
}

if (trace != currentTrace) {
NRLOG_VERBOSE(@"<Activity: \"%@\"> popCurrentTrace: exited trace is not the current threadLocalTrace. et=%@, tlc=%@",[NRMATraceController getCurrentActivityName], trace, currentTrace);
NRLOG_AGENT_VERBOSE(@"<Activity: \"%@\"> popCurrentTrace: exited trace is not the current threadLocalTrace. et=%@, tlc=%@",[NRMATraceController getCurrentActivityName], trace, currentTrace);
}

if ([stack lastObject] != trace) {
Expand All @@ -205,7 +205,7 @@ + (BOOL)popCurrentTraceIfEqualTo:(NRMATrace*)trace returningParent:(NRMATrace *_
}
else
{
NRLOG_VERBOSE(@"<Activity: \"%@\"> popCurrentTrace: exited trace is not on the current stack! et=%@, tlc=%@",[NRMATraceController getCurrentActivityName], trace, stack);
NRLOG_AGENT_VERBOSE(@"<Activity: \"%@\"> popCurrentTrace: exited trace is not on the current stack! et=%@, tlc=%@",[NRMATraceController getCurrentActivityName], trace, stack);
}

*parent = [stack lastObject];
Expand Down Expand Up @@ -262,7 +262,7 @@ + (NSMutableArray*)threadLocalStack {
+ (void) setThreadLocalTrace:(NRMATrace*)trace
{
if (trace == nil) {
NRLOG_ERROR(@"Attempted to set a nil trace to the thread local dictionary");
NRLOG_AGENT_ERROR(@"Attempted to set a nil trace to the thread local dictionary");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion Agent/ActivityTracing/NRMATrace.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ - (void) consumeMeasurement:(NRMAMeasurement *)measurement {
if ([measurement isKindOfClass:[NRMAHTTPTransactionMeasurement class]]) {
NSDate* sessionStartDate = [[NewRelicAgentInternal sharedInstance] getAppSessionStartDate];
if(((NRMAHTTPTransactionMeasurement*)measurement).startTime < [sessionStartDate timeIntervalSince1970]*1000) {
NRLOG_WARNING(@"Trace machine ignoring network transaction older than session. Session started at %@, where network transaction began %f milliseconds prior.",sessionStartDate, [sessionStartDate timeIntervalSince1970]*1000 - ((NRMAHTTPTransactionMeasurement*)measurement).startTime);
NRLOG_AGENT_WARNING(@"Trace machine ignoring network transaction older than session. Session started at %@, where network transaction began %f milliseconds prior.",sessionStartDate, [sessionStartDate timeIntervalSince1970]*1000 - ((NRMAHTTPTransactionMeasurement*)measurement).startTime);
return;
}
_networkTimeMillis += ((NRMAHTTPTransactionMeasurement*)measurement).totalTime;
Expand Down
16 changes: 8 additions & 8 deletions Agent/ActivityTracing/NRMATraceController.m
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ + (void) startTracingWithName:(NSString *)name interactionObject:(id __unsafe_un
return;
}

NRLOG_VERBOSE(@"\"%@\" Activity started", name);
NRLOG_AGENT_VERBOSE(@"\"%@\" Activity started", name);
[NRMATraceController startTracing:NO];
[[[NewRelicAgentInternal sharedInstance] analyticsController] setLastInteraction:name];
NRMATraceMachine* traceMach = [self traceMachine];
Expand Down Expand Up @@ -190,7 +190,7 @@ + (NRMATrace*) startTracing:(BOOL)persistentTrace
rootTrace.name = @"UI_Thread";
rootTrace.entryTimestamp = NRMAMillisecondTimestamp();

NRLOG_VERBOSE(@"Started activity with root trace : %@", rootTrace);
NRLOG_AGENT_VERBOSE(@"Started activity with root trace : %@", rootTrace);

[NRMATraceController startTracingWithRootTrace:rootTrace];

Expand Down Expand Up @@ -254,7 +254,7 @@ + (BOOL) completeActivityTraceWithExitTimestampMillis:(double)exitTimestampMilli
}

if(![NRMATraceController isTracingActive]) {
NRLOG_VERBOSE(@"completeTrace called while no trace was running.");
NRLOG_AGENT_VERBOSE(@"completeTrace called while no trace was running.");
return NO;
}
#ifndef DISABLE_NRMA_EXCEPTION_WRAPPER
Expand All @@ -265,7 +265,7 @@ + (BOOL) completeActivityTraceWithExitTimestampMillis:(double)exitTimestampMilli
[traceMach invalidateTimers]; //invalidate any timers that might be running.

NRMAActivityTrace *activityTrace = traceMach.activityTrace;
NRLOG_VERBOSE(@"\"%@\" Activity Completed.", activityTrace.name);
NRLOG_AGENT_VERBOSE(@"\"%@\" Activity Completed.", activityTrace.name);


[traceMach.tracePool removeMeasurementConsumer:activityTrace.rootTrace];
Expand Down Expand Up @@ -305,7 +305,7 @@ + (BOOL) newTraceSetup:(NRMATrace*)newTrace
parentTrace:(NRMATrace*)parentTrace
{
if (newTrace == nil || parentTrace == nil) {
NRLOG_VERBOSE(@"<Activity : \"%@\"> : newTraceSetup called with a nil parent or child trace: p=%@, c=%@",
NRLOG_AGENT_VERBOSE(@"<Activity : \"%@\"> : newTraceSetup called with a nil parent or child trace: p=%@, c=%@",
[NRMATraceController getCurrentActivityName],parentTrace, newTrace);
return NO;
}
Expand Down Expand Up @@ -437,15 +437,15 @@ + (NRMATrace*) registerNewTrace:(NSString *)name
@synchronized(localTraceMachine) {
if (localTraceMachine == nil) {

NRLOG_VERBOSE(@"tried to register a new trace but tracing is inactive");
NRLOG_AGENT_VERBOSE(@"tried to register a new trace but tracing is inactive");
return nil;
}

NRMATrace* childTrace = [[NRMATrace alloc] initWithName:name
traceMachine:localTraceMachine];

if( localTraceMachine.activityTrace.nodes >= NRMA_MAX_NODE_LIMIT){
NRLOG_VERBOSE(@"<Activity: \"%@\"> : NR_MAX_NODE_LIMIT(%d) reached dropping node",[NRMATraceController getCurrentActivityName],NRMA_MAX_NODE_LIMIT);
NRLOG_AGENT_VERBOSE(@"<Activity: \"%@\"> : NR_MAX_NODE_LIMIT(%d) reached dropping node",[NRMATraceController getCurrentActivityName],NRMA_MAX_NODE_LIMIT);
childTrace.ignoreNode = YES;
#ifndef DISABLE_NRMA_EXCEPTION_WRAPPER
@try {
Expand Down Expand Up @@ -621,7 +621,7 @@ + (BOOL) shouldCollectTraces
// todo: use fine grained AT capture rules later.
int currentCount = harvestData.activityTraces.count;
int maxCount = configuration.at_capture.maxTotalTraceCount;
NRLOG_VERBOSE(@"Should collect traces: %d/%d", currentCount, maxCount);
NRLOG_AGENT_VERBOSE(@"Should collect traces: %d/%d", currentCount, maxCount);
return harvestData.activityTraces.count < configuration.at_capture.maxTotalTraceCount;
}

Expand Down
7 changes: 4 additions & 3 deletions Agent/ActivityTracing/NRMATraceMachine.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,15 @@ - (void) startHealthyTimerWithInterval:(NSTimeInterval)interval
selector:@selector(healthyTimeout)
userInfo:nil
repeats:NO];
NRLOG_VERBOSE(@"Healthy trace timer started with interval: %f",interval);
// NSLog(@"Healthy trace timer started with interval: %f",interval);

[[NSRunLoop mainRunLoop] addTimer:self->healthyTimer forMode:NSDefaultRunLoopMode];
});
}

- (void) healthyTimeout
{
NRLOG_VERBOSE(@"Healthy trace timer fired");
//NRLOG_AGENT_VERBOSE(@"Healthy trace timer fired");
double currentTime = NRMAMillisecondTimestamp();
double lastUpdated = self.activityTrace.lastUpdated;

Expand Down Expand Up @@ -136,7 +137,7 @@ - (void) healthyTimeout

- (void) unhealthyTimeout
{
NRLOG_VERBOSE(@"Unhealthy trace timer fired");
//NRLOG_AGENT_VERBOSE(@"Unhealthy trace timer fired");
#ifndef DISABLE_NRMA_EXCEPTION_WRAPPER
@try {
#endif
Expand Down
4 changes: 2 additions & 2 deletions Agent/ActivityTracing/NRMATraceMachineAgentUserInterface.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ + (NSString*) startCustomActivity:(NSString*)name
{

if (![name length]) {
NRLOG_ERROR(@"Attempted to call startCustomActivity with empty \"name\" value. Aborting custom activity.");
NRLOG_AGENT_ERROR(@"Attempted to call startCustomActivity with empty \"name\" value. Aborting custom activity.");
return nil;
}

NSString* cleansedName = [NewRelicInternalUtils cleanseStringForCollector:name];

if (![cleansedName length]) {
NRLOG_ERROR(@"name = \"%@\" passed to \"start interaction\" contains no legal characters. Please constrain characters to only alpha-numeric values. Aborting custom activity.",name);
NRLOG_AGENT_ERROR(@"name = \"%@\" passed to \"start interaction\" contains no legal characters. Please constrain characters to only alpha-numeric values. Aborting custom activity.",name);
return nil;
}

Expand Down
5 changes: 5 additions & 0 deletions Agent/Analytics/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ extern NSString *const kNRMA_Attrib_file_private;
extern NSString *const kNRMA_EventStoreFilename;

extern NSString *const kNRMA_Offline_folder;

extern NSString *const kNRMA_Collector_connect_url;
extern NSString *const kNRMA_Collector_data_url;
extern NSString *const kNRMA_Collector_hex_url;

// Integer Analytics Constants
static int kNRMA_Attrib_Max_Name_Length = 256;
static int kNRMA_Attrib_Max_Value_Size_Bytes = 4096;
Expand Down
4 changes: 4 additions & 0 deletions Agent/Analytics/Constants.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,7 @@
NSString * const kNRMA_EventStoreFilename = @"eventsStore.txt";

NSString * const kNRMA_Offline_folder = @"offlineStorage";

NSString * const kNRMA_Collector_connect_url = @"/mobile/v5/connect";
NSString * const kNRMA_Collector_data_url = @"/mobile/v3/data";
NSString * const kNRMA_Collector_hex_url = @"/mobile/f";
Loading

0 comments on commit e80fc0b

Please sign in to comment.