Skip to content

Commit

Permalink
ref: Mark [SpanProtocol setExtraValue:forKey] as deprecated (#2413)
Browse files Browse the repository at this point in the history
Marked `[SpanProtocol setExtraValue:forKey]' deprecated
  • Loading branch information
brustolin authored Nov 22, 2022
1 parent d10145a commit dcac8ad
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

This version adds a dependency on Swift.

### Breaking Changes

- Mark `- [SpanProtocol setExtraValue:forKey:]` as deprecated (#2413)

### Features

- Properly demangle Swift class name (#2162)
Expand Down
5 changes: 3 additions & 2 deletions Sources/Sentry/Public/SentrySpanProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ NS_SWIFT_NAME(Span)

/**
* Use setDataValue instead. This method calls setDataValue, was added by mistake, and will be
* deprecated in a future version.
* removed in a future version.
*/
- (void)setExtraValue:(nullable id)value forKey:(NSString *)key NS_SWIFT_NAME(setExtra(value:key:));
- (void)setExtraValue:(nullable id)value
forKey:(NSString *)key DEPRECATED_ATTRIBUTE NS_SWIFT_NAME(setExtra(value:key:));

/**
* Removes a data value.
Expand Down
1 change: 1 addition & 0 deletions Sources/Sentry/SentryNoOpSpan.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ SENTRY_NO_INIT
@property (nullable, readonly) NSDictionary<NSString *, id> *data;
@property (readonly) NSDictionary<NSString *, NSString *> *tags;

- (void)setExtraValue:(nullable id)value forKey:(NSString *)key DEPRECATED_ATTRIBUTE;
@end

NS_ASSUME_NONNULL_END
1 change: 1 addition & 0 deletions Sources/Sentry/include/SentrySpan.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ SENTRY_NO_INIT
*/
- (instancetype)initWithTracer:(SentryTracer *)transaction context:(SentrySpanContext *)context;

- (void)setExtraValue:(nullable id)value forKey:(NSString *)key DEPRECATED_ATTRIBUTE;
@end

NS_ASSUME_NONNULL_END
2 changes: 2 additions & 0 deletions Sources/Sentry/include/SentryTracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ static NSTimeInterval const SentryTracerDefaultTimeout = 3.0;
*/
- (void)spanFinished:(id<SentrySpan>)finishedSpan;

- (void)setExtraValue:(nullable id)value forKey:(NSString *)key DEPRECATED_ATTRIBUTE;

/**
* Get the tracer from a span.
*/
Expand Down
1 change: 1 addition & 0 deletions Tests/SentryTests/Performance/SentryTracerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,7 @@ class SentryTracerTests: XCTestCase {
}
#endif

@available(*, deprecated)
func testSetExtra_ForwardsToSetData() {
let sut = fixture.getSut()
sut.setExtra(value: 0, key: "key")
Expand Down
1 change: 0 additions & 1 deletion Tests/SentryTests/Transaction/SentryNoOpSpanTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class SentryNoOpSpanTests: XCTestCase {
let sut = SentryNoOpSpan.shared()
XCTAssertNil(sut.data)
sut.setData(value: "tet", key: "key")
sut.setExtra(value: "tet", key: "key")
sut.removeData(key: "any")
XCTAssertNil(sut.data)
}
Expand Down
15 changes: 8 additions & 7 deletions Tests/SentryTests/Transaction/SentrySpanTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ class SentrySpanTests: XCTestCase {
XCTAssertFalse(logOutput.loggedMessages.filter({ $0.contains(" Starting a child on a finished span is not supported; it won\'t be sent to Sentry.") }).isEmpty)
}

func testAddAndRemoveExtras() {
func testAddAndRemoveData() {
let span = fixture.getSut()

span.setExtra(value: fixture.extraValue, key: fixture.extraKey)
span.setData(value: fixture.extraValue, key: fixture.extraKey)

XCTAssertEqual(span.data!.count, 1)
XCTAssertEqual(span.data![fixture.extraKey] as! String, fixture.extraValue)
Expand All @@ -214,7 +214,7 @@ class SentrySpanTests: XCTestCase {
func testSerialization() {
let span = fixture.getSut()

span.setExtra(value: fixture.extraValue, key: fixture.extraKey)
span.setData(value: fixture.extraValue, key: fixture.extraKey)
span.setTag(value: fixture.extraValue, key: fixture.extraKey)
span.finish()

Expand All @@ -234,7 +234,7 @@ class SentrySpanTests: XCTestCase {
func testSanitizeData() {
let span = fixture.getSut()

span.setExtra(value: Date(timeIntervalSince1970: 10), key: "date")
span.setData(value: Date(timeIntervalSince1970: 10), key: "date")
span.finish()

let serialization = span.serialize()
Expand All @@ -244,7 +244,7 @@ class SentrySpanTests: XCTestCase {
func testSanitizeDataSpan() {
let span = SentrySpan(tracer: fixture.tracer, context: SpanContext(operation: fixture.someOperation, sampled: .undecided))

span.setExtra(value: Date(timeIntervalSince1970: 10), key: "date")
span.setData(value: Date(timeIntervalSince1970: 10), key: "date")
span.finish()

let serialization = span.serialize()
Expand Down Expand Up @@ -305,13 +305,14 @@ class SentrySpanTests: XCTestCase {
XCTAssertEqual(header.value(), "\(span.context.traceId)-\(span.context.spanId)")
}

@available(*, deprecated)
func testSetExtra_ForwardsToSetData() {
let sut = SentrySpan(tracer: fixture.tracer, context: SpanContext(operation: "test"))
sut.setExtra(value: 0, key: "key")

XCTAssertEqual(["key": 0], sut.data as! [String: Int])
}

func testSpanWithoutTracer_StartChild_ReturnsNoOpSpan() {
// Span has a weak reference to tracer. If we don't keep a reference
// to the tracer ARC will deallocate the tracer.
Expand Down Expand Up @@ -349,7 +350,7 @@ class SentrySpanTests: XCTestCase {
queue.async {

for j in 0..<innerLoop {
span.setExtra(value: value, key: "\(i)-\(j)")
span.setData(value: value, key: "\(i)-\(j)")
span.setTag(value: value, key: "\(i)-\(j)")
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/SentryTests/Transaction/TestSentrySpan.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ NS_ASSUME_NONNULL_BEGIN

@interface TestSentrySpan : NSObject <SentrySpan>

- (void)setExtraValue:(nullable id)value forKey:(nonnull NSString *)key DEPRECATED_ATTRIBUTE;

@end

NS_ASSUME_NONNULL_END

0 comments on commit dcac8ad

Please sign in to comment.