Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
### Fixes

- Continuous profile stop requests are cancelled by subsequent timely calls to start (#4993)
- Crash in setMeasurement when name is nil (#5064)

### Improvements

Expand Down
4 changes: 4 additions & 0 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
621F61F12BEA073A005E654F /* SentryEnabledFeaturesBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 621F61F02BEA073A005E654F /* SentryEnabledFeaturesBuilder.swift */; };
62212B872D520CB00062C2FA /* SentryEventCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62212B862D520CB00062C2FA /* SentryEventCodable.swift */; };
6221BBCA2CAA932100C627CA /* SentryANRType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6221BBC92CAA932100C627CA /* SentryANRType.swift */; };
62277BBC2DA5183500EF06B7 /* SentryTracer+Test.m in Sources */ = {isa = PBXBuildFile; fileRef = 62277BBB2DA5183500EF06B7 /* SentryTracer+Test.m */; };
622C08DB29E554B9002571D4 /* SentrySpanContext+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 622C08D929E554B9002571D4 /* SentrySpanContext+Private.h */; };
62375FB92B47F9F000CC55F1 /* SentryDependencyContainerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62375FB82B47F9F000CC55F1 /* SentryDependencyContainerTests.swift */; };
623C45B02A651D8200D9E88B /* SentryCoreDataTracker+Test.m in Sources */ = {isa = PBXBuildFile; fileRef = 623C45AF2A651D8200D9E88B /* SentryCoreDataTracker+Test.m */; };
Expand Down Expand Up @@ -1172,6 +1173,7 @@
621F61F02BEA073A005E654F /* SentryEnabledFeaturesBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryEnabledFeaturesBuilder.swift; sourceTree = "<group>"; };
62212B862D520CB00062C2FA /* SentryEventCodable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryEventCodable.swift; sourceTree = "<group>"; };
6221BBC92CAA932100C627CA /* SentryANRType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryANRType.swift; sourceTree = "<group>"; };
62277BBB2DA5183500EF06B7 /* SentryTracer+Test.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "SentryTracer+Test.m"; sourceTree = "<group>"; };
622C08D929E554B9002571D4 /* SentrySpanContext+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "SentrySpanContext+Private.h"; path = "include/SentrySpanContext+Private.h"; sourceTree = "<group>"; };
62375FB82B47F9F000CC55F1 /* SentryDependencyContainerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryDependencyContainerTests.swift; sourceTree = "<group>"; };
623C45AE2A651C4500D9E88B /* SentryCoreDataTracker+Test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SentryCoreDataTracker+Test.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3170,6 +3172,7 @@
8E70B0FC25CB72BE002B3155 /* SentrySpanTests.swift */,
D88817DB26D72B7B00BF2251 /* SentryTraceContextTests.swift */,
7BBEB16026AEE5EF00C06C03 /* SentryTracer+Test.h */,
62277BBB2DA5183500EF06B7 /* SentryTracer+Test.m */,
8EAC7FF7265C8910005B44E5 /* SentryTracerTests.swift */,
62950F0F29E7FE0100A42624 /* SentryTransactionContextTests.swift */,
7B6C5ED5264E62CA0010D138 /* SentryTransactionTests.swift */,
Expand Down Expand Up @@ -5373,6 +5376,7 @@
7B72D23A28D074BC0014798A /* TestExtensions.swift in Sources */,
7BBD18BB24530D2600427C76 /* SentryFileManagerTests.swift in Sources */,
63FE722020DA66EC00CDBAE8 /* SentryCrashObjC_Tests.m in Sources */,
62277BBC2DA5183500EF06B7 /* SentryTracer+Test.m in Sources */,
7B58816727FC5D790098B121 /* SentryDiscardReasonMapperTests.swift in Sources */,
63FE720320DA66EC00CDBAE8 /* SentryCrashCPU_Tests.m in Sources */,
63FE721020DA66EC00CDBAE8 /* SentryCrashCachedData_Tests.m in Sources */,
Expand Down
16 changes: 15 additions & 1 deletion Sources/Sentry/SentryTracer.m
Original file line number Diff line number Diff line change
Expand Up @@ -423,13 +423,27 @@
- (void)setMeasurement:(NSString *)name value:(NSNumber *)value
{
SentryMeasurementValue *measurement = [[SentryMeasurementValue alloc] initWithValue:value];
_measurements[name] = measurement;

[self setMeasurement:name measurement:measurement];

Check warning on line 427 in Sources/Sentry/SentryTracer.m

View check run for this annotation

Codecov / codecov/patch

Sources/Sentry/SentryTracer.m#L427

Added line #L427 was not covered by tests
}

- (void)setMeasurement:(NSString *)name value:(NSNumber *)value unit:(SentryMeasurementUnit *)unit
{

SentryMeasurementValue *measurement = [[SentryMeasurementValue alloc] initWithValue:value
unit:unit];
[self setMeasurement:name measurement:measurement];

Check warning on line 435 in Sources/Sentry/SentryTracer.m

View check run for this annotation

Codecov / codecov/patch

Sources/Sentry/SentryTracer.m#L435

Added line #L435 was not covered by tests
}

- (void)setMeasurement:(NSString *)name measurement:(SentryMeasurementValue *)measurement
{

Check warning on line 439 in Sources/Sentry/SentryTracer.m

View check run for this annotation

Codecov / codecov/patch

Sources/Sentry/SentryTracer.m#L439

Added line #L439 was not covered by tests
// Although name is nonnull we saw edge cases where it was nil and then leading to crashes. If
// the name is nil we can discard the measurement
if (name == nil) {
SENTRY_LOG_ERROR(@"The name of the measurement is nil. Discarding the measurement.");
return;

Check warning on line 444 in Sources/Sentry/SentryTracer.m

View check run for this annotation

Codecov / codecov/patch

Sources/Sentry/SentryTracer.m#L442-L444

Added lines #L442 - L444 were not covered by tests
}

_measurements[name] = measurement;
}

Expand Down
5 changes: 5 additions & 0 deletions Tests/SentryTests/Transaction/SentryTracer+Test.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ NS_ASSUME_NONNULL_BEGIN

@end

void testing_setMeasurementWithNilName(SentryTracer *tracer, NSNumber *value);

void testing_setMeasurementWithNilNameAndUnit(
SentryTracer *tracer, NSNumber *value, SentryMeasurementUnit *unit);

NS_ASSUME_NONNULL_END
22 changes: 22 additions & 0 deletions Tests/SentryTests/Transaction/SentryTracer+Test.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#import "SentryTracer+Test.h"
#import <Foundation/Foundation.h>

void
testing_setMeasurementWithNilName(SentryTracer *tracer, NSNumber *value)
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnonnull"
[tracer setMeasurement:nil value:value];
#pragma clang diagnostic pop
}

void
testing_setMeasurementWithNilNameAndUnit(
SentryTracer *tracer, NSNumber *value, SentryMeasurementUnit *unit)
{

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnonnull"
[tracer setMeasurement:nil value:value unit:unit];
#pragma clang diagnostic pop
}
17 changes: 17 additions & 0 deletions Tests/SentryTests/Transaction/SentryTracerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,23 @@ class SentryTracerTests: XCTestCase {
XCTAssertEqual(unit.unit, try XCTUnwrap(measurement["unit"] as? String))
}

func testMeasurement_NameIsNil_MeasurementsGetsDiscarded() throws {
// Arrange
let sut = fixture.getSut()

// Act
testing_setMeasurementWithNilName(sut, 0.0)
testing_setMeasurementWithNilNameAndUnit(sut, 0.0, MeasurementUnitFraction.percent)

// Assert
sut.finish()

XCTAssertEqual(1, fixture.hub.capturedEventsWithScopes.count)
let serializedTransaction = fixture.hub.capturedEventsWithScopes.first?.event.serialize()

XCTAssertNil(serializedTransaction?["measurements"])
}

func testFinish_WithUnfinishedChildren() {
let sut = fixture.getSut(waitForChildren: false)
let child1 = sut.startChild(operation: fixture.transactionOperation)
Expand Down
2 changes: 1 addition & 1 deletion scripts/.clang-format-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.1.1
20.1.2
2 changes: 1 addition & 1 deletion scripts/.swiftlint-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.58.2
0.59.0
Loading