-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete view spans that were started during the prewarm phase
Showing
9 changed files
with
194 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
// | ||
// TracerTests.m | ||
// BugsnagPerformance-iOSTests | ||
// | ||
// Created by Karl Stenerud on 18.10.23. | ||
// Copyright © 2023 Bugsnag. All rights reserved. | ||
// | ||
|
||
#import <XCTest/XCTest.h> | ||
#import "Tracer.h" | ||
|
||
using namespace bugsnag; | ||
|
||
@interface TracerTests : XCTestCase | ||
|
||
@end | ||
|
||
static BugsnagPerformanceConfiguration *newConfig() { | ||
return [[BugsnagPerformanceConfiguration alloc] initWithApiKey:@"11111111111111111111111111111111"]; | ||
} | ||
|
||
@implementation TracerTests | ||
|
||
- (void)testPrewarmEndBefore { | ||
auto earlyConfig = [BSGEarlyConfiguration new]; | ||
earlyConfig.appWasLaunchedPreWarmed = YES; | ||
auto config = newConfig(); | ||
auto stackingHandler = std::make_shared<SpanStackingHandler>(); | ||
auto sampler = std::make_shared<Sampler>(); | ||
sampler->setProbability(1.0); | ||
auto batch = std::make_shared<Batch>(); | ||
auto tracer = std::make_shared<Tracer>(stackingHandler, sampler, batch, ^(){}); | ||
tracer->earlyConfigure(earlyConfig); | ||
tracer->earlySetup(); | ||
tracer->configure(config); | ||
tracer->start(); | ||
|
||
SpanOptions spanOptions; | ||
auto span = tracer->startViewLoadSpan(BugsnagPerformanceViewTypeUIKit, @"myclass", spanOptions); | ||
[span end]; | ||
tracer->onPrewarmPhaseEnded(); | ||
auto spans = batch->drain(true); | ||
XCTAssertEqual(spans->size(), 1UL); | ||
} | ||
|
||
- (void)testPrewarmEndAfter { | ||
auto earlyConfig = [BSGEarlyConfiguration new]; | ||
earlyConfig.appWasLaunchedPreWarmed = YES; | ||
auto config = newConfig(); | ||
auto stackingHandler = std::make_shared<SpanStackingHandler>(); | ||
auto sampler = std::make_shared<Sampler>(); | ||
sampler->setProbability(1.0); | ||
auto batch = std::make_shared<Batch>(); | ||
auto tracer = std::make_shared<Tracer>(stackingHandler, sampler, batch, ^(){}); | ||
tracer->earlyConfigure(earlyConfig); | ||
tracer->earlySetup(); | ||
tracer->configure(config); | ||
tracer->start(); | ||
|
||
SpanOptions spanOptions; | ||
auto span = tracer->startViewLoadSpan(BugsnagPerformanceViewTypeUIKit, @"myclass", spanOptions); | ||
tracer->onPrewarmPhaseEnded(); | ||
[span end]; | ||
auto spans = batch->drain(true); | ||
XCTAssertEqual(spans->size(), 0UL); | ||
} | ||
|
||
- (void)testNoPrewarmEndBefore { | ||
auto earlyConfig = [BSGEarlyConfiguration new]; | ||
earlyConfig.appWasLaunchedPreWarmed = NO; | ||
auto config = newConfig(); | ||
auto stackingHandler = std::make_shared<SpanStackingHandler>(); | ||
auto sampler = std::make_shared<Sampler>(); | ||
sampler->setProbability(1.0); | ||
auto batch = std::make_shared<Batch>(); | ||
auto tracer = std::make_shared<Tracer>(stackingHandler, sampler, batch, ^(){}); | ||
tracer->earlyConfigure(earlyConfig); | ||
tracer->earlySetup(); | ||
tracer->configure(config); | ||
tracer->start(); | ||
|
||
SpanOptions spanOptions; | ||
auto span = tracer->startViewLoadSpan(BugsnagPerformanceViewTypeUIKit, @"myclass", spanOptions); | ||
[span end]; | ||
tracer->onPrewarmPhaseEnded(); | ||
auto spans = batch->drain(true); | ||
XCTAssertEqual(spans->size(), 1UL); | ||
} | ||
|
||
- (void)testNoPrewarmEndAfter { | ||
auto earlyConfig = [BSGEarlyConfiguration new]; | ||
earlyConfig.appWasLaunchedPreWarmed = NO; | ||
auto config = newConfig(); | ||
auto stackingHandler = std::make_shared<SpanStackingHandler>(); | ||
auto sampler = std::make_shared<Sampler>(); | ||
sampler->setProbability(1.0); | ||
auto batch = std::make_shared<Batch>(); | ||
auto tracer = std::make_shared<Tracer>(stackingHandler, sampler, batch, ^(){}); | ||
tracer->earlyConfigure(earlyConfig); | ||
tracer->earlySetup(); | ||
tracer->configure(config); | ||
tracer->start(); | ||
|
||
SpanOptions spanOptions; | ||
auto span = tracer->startViewLoadSpan(BugsnagPerformanceViewTypeUIKit, @"myclass", spanOptions); | ||
tracer->onPrewarmPhaseEnded(); | ||
[span end]; | ||
auto spans = batch->drain(true); | ||
XCTAssertEqual(spans->size(), 1UL); | ||
} | ||
|
||
@end |