Skip to content
Merged
Show file tree
Hide file tree
Changes from 87 commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
196c9aa
feat(metrics): Add integration with installation by SDK
philprime Dec 2, 2025
81d9980
update changelog
philprime Dec 2, 2025
420d68e
update changelog
philprime Dec 2, 2025
dcc65ff
change type of SUT in MetricsIntegrationTests
philprime Dec 2, 2025
46e42f5
Add metrics to TestOptions.removeAllIntegrations
philprime Dec 2, 2025
8dfb9e6
change default value in disableEverything
philprime Dec 2, 2025
1210307
add missing test tear down
philprime Dec 2, 2025
303d533
feat(metrics): Add implementation for metrics envelope item
philprime Dec 2, 2025
b991cda
Remove unrelated change
philprime Dec 2, 2025
e5611fb
Add enableMetrics to public header
philprime Dec 2, 2025
2aa1f43
fix compilation
philprime Dec 2, 2025
6dfe9bb
Merge branch 'philprime/metrics-bootstrap' into philprime/metrics-env…
philprime Dec 2, 2025
3ca02d7
refactor(refactor): Add generic internal item batcher
philprime Dec 9, 2025
193c27b
Add SentryItemBatcherTests to enhance item batching functionality
philprime Dec 9, 2025
b1891d3
fixed tests and added more protocols
philprime Dec 9, 2025
e89eab0
Merge remote-tracking branch 'origin/main' into philprime/log-batcher…
philprime Dec 10, 2025
eb09954
refactor item batcher
philprime Dec 10, 2025
cc065bb
refactor item batcher into protocols
philprime Dec 11, 2025
8be32e7
cleanup
philprime Dec 11, 2025
21d4e61
Update Sources/Swift/Protocol/SentryAttribute.swift
philprime Dec 11, 2025
c17ef37
Enhance Batcher and TestCurrentDateProvider functionality
philprime Dec 11, 2025
421210a
Merge branch 'philprime/log-batcher-abstraction' into philprime/metrics
philprime Dec 11, 2025
d3c3b47
Merge branch 'philprime/metrics' into philprime/metrics-bootstrap
philprime Dec 11, 2025
0ae250e
Merge branch 'philprime/metrics-bootstrap' into philprime/metrics-env…
philprime Dec 11, 2025
f463844
Merge remote-tracking branch 'origin/main' into philprime/metrics
philprime Dec 11, 2025
6a56d9c
Merge branch 'philprime/metrics' into philprime/metrics-bootstrap
philprime Dec 11, 2025
a7c7df9
Merge branch 'philprime/metrics-bootstrap' into philprime/metrics-env…
philprime Dec 11, 2025
f17e9e1
Merge remote-tracking branch 'origin/main' into philprime/metrics
philprime Dec 15, 2025
c46d92c
Merge branch 'philprime/metrics' into philprime/metrics-bootstrap
philprime Dec 15, 2025
c143d90
Merge branch 'philprime/metrics-bootstrap' into philprime/metrics-env…
philprime Dec 15, 2025
70d5fd3
refactor latest item batcher
philprime Dec 15, 2025
64cc81f
fixes
philprime Dec 15, 2025
c69eb95
update changelog
philprime Dec 15, 2025
5f4299a
Remove unneeded code
philprime Dec 15, 2025
f7a67bb
Merge branch 'philprime/metrics-bootstrap' into philprime/metrics-env…
philprime Dec 15, 2025
70241f7
cleanup
philprime Dec 15, 2025
46a2f3e
add missing options setter
philprime Dec 15, 2025
40b52a3
Merge branch 'philprime/metrics-bootstrap' into philprime/metrics-env…
philprime Dec 15, 2025
861161b
cleanup
philprime Dec 15, 2025
c6ce033
WIP
philprime Dec 15, 2025
d073e22
WIP
philprime Dec 15, 2025
4980aad
cleanup
philprime Dec 15, 2025
56320d5
Remove spanId from Metric struct and related tests; update BatcherSco…
philprime Dec 15, 2025
3eca8ca
fix warnings on set
philprime Dec 15, 2025
1b939e6
add comment explaining reasoning for jsonserialization in tests
philprime Dec 15, 2025
6ece2f8
test: Add unit tests for enabling and disabling metrics feature
philprime Dec 15, 2025
1d80fda
test: Update MetricsIntegrationTests to assert integration name
philprime Dec 15, 2025
06e863a
Merge branch 'philprime/metrics-bootstrap' into philprime/metrics-env…
philprime Dec 15, 2025
74902aa
WIP
philprime Dec 15, 2025
6dca42f
Update Sources/Swift/Integrations/Metrics/MetricsIntegration.swift
philprime Dec 15, 2025
922ea27
WIP
philprime Dec 15, 2025
b9ed1a3
fix integration setup in tests
philprime Dec 15, 2025
99f563e
Merge remote-tracking branch 'origin/main' into philprime/metrics-boo…
philprime Dec 16, 2025
2a05eb7
Merge branch 'philprime/metrics-bootstrap' into philprime/metrics-env…
philprime Dec 16, 2025
c8b4ab5
fix tests for integraiton checking
philprime Dec 16, 2025
bd60a8c
fix(logs): Use sendDefaultPii and span_id for attributes
philprime Dec 16, 2025
3a22103
Update changelog
philprime Dec 16, 2025
23057b4
Merge branch 'philprime/logs-span-id' into philprime/metrics-bootstrap
philprime Dec 16, 2025
1a6cf02
Merge branch 'philprime/metrics-bootstrap' into philprime/metrics-env…
philprime Dec 16, 2025
62ee6ad
change metric batcher to struct
philprime Dec 16, 2025
fe0a0ef
update public api
philprime Dec 16, 2025
e3c7019
update public api
philprime Dec 16, 2025
f10a253
update changelog
philprime Dec 16, 2025
28fc0dd
Apply suggestions from code review
philprime Dec 16, 2025
3b2eba9
remove scope sendDefaultPii
philprime Dec 17, 2025
ac1b46e
remove scope sendDefaultPii
philprime Dec 17, 2025
872c2d4
Update CHANGELOG.md
philprime Dec 17, 2025
f8dd108
fix test assert
philprime Dec 17, 2025
b092849
Merge remote-tracking branch 'origin/philprime/logs-span-id' into phi…
philprime Dec 17, 2025
5dab77e
move option to experimental
philprime Dec 17, 2025
15f7316
Merge remote-tracking branch 'origin/main' into philprime/metrics-boo…
philprime Dec 17, 2025
0a2b72f
move option to experimental
philprime Dec 17, 2025
86e21d3
cleanup
philprime Dec 17, 2025
f9efc90
Merge branch 'philprime/metrics-bootstrap' into philprime/metrics-env…
philprime Dec 17, 2025
a12babf
WIP
philprime Dec 17, 2025
ba4edde
cleanup
philprime Dec 17, 2025
57b889a
move option to experimental
philprime Dec 17, 2025
7f2f81d
cleanup
philprime Dec 17, 2025
31dc8c8
remove duplicate setter
philprime Dec 17, 2025
28d56ce
apply feedback from PR review
philprime Dec 17, 2025
8d2f500
change encodable conformance to be internal
philprime Dec 17, 2025
146146e
update public api
philprime Dec 17, 2025
19293d4
Refactor SentryMetricsBatcher: Update buffer size to 1MB, enhance doc…
philprime Dec 17, 2025
0273433
fix experimental options and add beforeSendMetrics to changelog
philprime Dec 17, 2025
7e9e86f
Merge remote-tracking branch 'origin/main' into philprime/metrics-boo…
philprime Dec 18, 2025
14f9cdd
add missing experimental subtype
philprime Dec 18, 2025
082e70b
Merge branch 'philprime/metrics-bootstrap' into philprime/metrics-env…
philprime Dec 18, 2025
e61661b
Merge remote-tracking branch 'origin/main' into philprime/metrics-boo…
philprime Dec 18, 2025
b9bd8cc
Merge branch 'philprime/metrics-bootstrap' into philprime/metrics-env…
philprime Dec 18, 2025
84255ec
Refactor SentryMetric to merge value and type
philprime Dec 19, 2025
d73700c
apply feedback from PR review
philprime Dec 22, 2025
550d3cb
Merge remote-tracking branch 'origin/main' into philprime/metrics-boo…
philprime Jan 8, 2026
21f64bd
Merge branch 'philprime/metrics-bootstrap' into philprime/metrics-env…
philprime Jan 8, 2026
51775d5
Merge remote-tracking branch 'origin/main' into philprime/metrics-boo…
philprime Jan 9, 2026
54b3eeb
Merge remote-tracking branch 'origin/main' into philprime/metrics-boo…
philprime Jan 9, 2026
ebe0984
Merge branch 'philprime/metrics-bootstrap' into philprime/metrics-env…
philprime Jan 9, 2026
8639f31
revert unneeded changes
philprime Jan 9, 2026
38467ab
refactor: Update SentryMetric attribute handling to use SentryAttribu…
philprime Jan 9, 2026
b715cd2
fix: use span traceId when span is active in BatcherScope
philprime Jan 9, 2026
be43bd8
fix: correct attribute assignment in SentryMetric to use string initi…
philprime Jan 9, 2026
2c83491
test: fix testApplyToItem_withAllAttributes to set span traceId
philprime Jan 9, 2026
0ebf819
Merge remote-tracking branch 'origin/main' into philprime/metrics-env…
philprime Jan 15, 2026
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

### Features

- Add integration to collect Metrics, can be enabled by setting `options.experimental.enableMetrics = true` (#6956)
- Add implementation for Metrics Protocol with modification of items in `options.experimental.beforeSendMetrics` (#6960)

### Fixes

- The transport now correctly discard envelopes on 4xx and 5xx responses and records client reports `send_error` (#6618) This also fixes edge cases in which the SDK kept retrying sending a faulty envelope until the offline cache overflowed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public enum SentrySDKOverrides: String, CaseIterable {
case .tracing: return SentrySDKOverrides.Tracing.allCases
case .profiling: return SentrySDKOverrides.Profiling.allCases
case .networking: return SentrySDKOverrides.Networking.allCases
case .metrics: return SentrySDKOverrides.Metrics.allCases
}
}

Expand Down Expand Up @@ -167,6 +168,11 @@ public enum SentrySDKOverrides: String, CaseIterable {
case immediateStop = "--io.sentry.profiling.continuous-profiler-immediate-stop"
}
case profiling = "Profiling"

public enum Metrics: String, SentrySDKOverride {
case enable = "--io.sentry.metrics.enable"
}
case metrics = "Metrics"
}

// MARK: Public flag/variable value access
Expand Down Expand Up @@ -348,6 +354,14 @@ extension SentrySDKOverrides.Special {
}
}

extension SentrySDKOverrides.Metrics {
public var overrideType: OverrideType {
switch self {
case .enable: return .boolean
}
}
}

// MARK: Disable Everything Helper

// These are listed exhaustively, without using default cases, so that when new cases are added to the enums above, the compiler helps remind you to annotate what type it is down here.
Expand Down Expand Up @@ -429,4 +443,11 @@ extension SentrySDKOverrides.Special {
}
}

extension SentrySDKOverrides.Metrics {
public var ignoresDisableEverything: Bool {
switch self {
case .enable: return true
}
}
}
// swiftlint:enable file_length
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,17 @@ public struct SentrySDKWrapper {
options.configureUserFeedback = configureFeedback(config:)
#endif // !os(macOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)

// Integration: Logs
options.enableLogs = true

// Integration: Metrics
options.experimental.enableMetrics = SentrySDKOverrides.Metrics.enable.boolValue
options.experimental.beforeSendMetric = { metric in
var metric = metric // Make the metric mutable because it's a value type
metric.attributes["custom-attribute"] = .init(string: "some-value")
return metric
}

// Experimental features
options.enableFileManagerSwizzling = !SentrySDKOverrides.Other.disableFileManagerSwizzling.boolValue
options.experimental.enableUnhandledCPPExceptionsV2 = true
Expand Down
3 changes: 3 additions & 0 deletions Samples/Shared/feature-flags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ schemeTemplates:
"--io.sentry.other.reject-view-hierarchy-in-before-capture-view-hierarchy": false
"--io.sentry.other.reject-all-spans": false

# metrics
"--io.sentry.metrics.enable": true

environmentVariables:
# events
- variable: "--io.sentry.events.sampleRate"
Expand Down
44 changes: 42 additions & 2 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,13 @@
D46712622DCD059900D4074A /* SentryRedactDefaultOptionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D46712612DCD059500D4074A /* SentryRedactDefaultOptionsTests.swift */; };
D46712642DCD063800D4074A /* PreviewRedactOptionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D46712632DCD062700D4074A /* PreviewRedactOptionsTests.swift */; };
D468C0622D3669A200964230 /* SentryFileIOTracker+SwiftHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = D468C0612D3669A200964230 /* SentryFileIOTracker+SwiftHelpers.swift */; };
D46B041D2EDF168400AF4A0A /* SentryMetricsIntegration.swift in Sources */ = {isa = PBXBuildFile; fileRef = D46B041C2EDF167D00AF4A0A /* SentryMetricsIntegration.swift */; };
D46B04202EDF175C00AF4A0A /* SentryMetricsIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D46B041F2EDF175600AF4A0A /* SentryMetricsIntegrationTests.swift */; };
D46B04482EDF25E100AF4A0A /* SentryMetric.swift in Sources */ = {isa = PBXBuildFile; fileRef = D46B04472EDF25E100AF4A0A /* SentryMetric.swift */; };
D46B044F2EDF260A00AF4A0A /* SentryMetricsBatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = D46B044E2EDF260A00AF4A0A /* SentryMetricsBatcher.swift */; };
D473ACD72D8090FC000F1CC6 /* FileManager+SentryTracing.swift in Sources */ = {isa = PBXBuildFile; fileRef = D473ACD62D8090FC000F1CC6 /* FileManager+SentryTracing.swift */; };
D4749EF02EF042C1000F9AE7 /* SentryMetricTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4749EEF2EF042C1000F9AE7 /* SentryMetricTests.swift */; };
D4749F482EF062FD000F9AE7 /* SentryMetricsBatcherTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4749F472EF062FD000F9AE7 /* SentryMetricsBatcherTests.swift */; };
D480F9D92DE47A50009A0594 /* TestSentryScopePersistentStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = D480F9D82DE47A48009A0594 /* TestSentryScopePersistentStore.swift */; };
D480F9DB2DE47AF2009A0594 /* SentryScopePersistentStoreTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D480F9DA2DE47AEB009A0594 /* SentryScopePersistentStoreTests.swift */; };
D48225A12EEC4B6D00CDF32C /* BatcherMetadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48225A02EEC4B6D00CDF32C /* BatcherMetadata.swift */; };
Expand Down Expand Up @@ -2147,9 +2153,15 @@
D46712612DCD059500D4074A /* SentryRedactDefaultOptionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryRedactDefaultOptionsTests.swift; sourceTree = "<group>"; };
D46712632DCD062700D4074A /* PreviewRedactOptionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewRedactOptionsTests.swift; sourceTree = "<group>"; };
D468C0612D3669A200964230 /* SentryFileIOTracker+SwiftHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SentryFileIOTracker+SwiftHelpers.swift"; sourceTree = "<group>"; };
D46B041C2EDF167D00AF4A0A /* SentryMetricsIntegration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryMetricsIntegration.swift; sourceTree = "<group>"; };
D46B041F2EDF175600AF4A0A /* SentryMetricsIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryMetricsIntegrationTests.swift; sourceTree = "<group>"; };
D46B04472EDF25E100AF4A0A /* SentryMetric.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryMetric.swift; sourceTree = "<group>"; };
D46B044E2EDF260A00AF4A0A /* SentryMetricsBatcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryMetricsBatcher.swift; sourceTree = "<group>"; };
D46D45E12D5F3FD600A1CB35 /* Sentry_Base.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = Sentry_Base.xctestplan; sourceTree = "<group>"; };
D46D45E92D5F411700A1CB35 /* SentrySwiftUI_Base.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = SentrySwiftUI_Base.xctestplan; path = Plans/SentrySwiftUI_Base.xctestplan; sourceTree = SOURCE_ROOT; };
D473ACD62D8090FC000F1CC6 /* FileManager+SentryTracing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileManager+SentryTracing.swift"; sourceTree = "<group>"; };
D4749EEF2EF042C1000F9AE7 /* SentryMetricTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryMetricTests.swift; sourceTree = "<group>"; };
D4749F472EF062FD000F9AE7 /* SentryMetricsBatcherTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryMetricsBatcherTests.swift; sourceTree = "<group>"; };
D480F9D82DE47A48009A0594 /* TestSentryScopePersistentStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestSentryScopePersistentStore.swift; sourceTree = "<group>"; };
D480F9DA2DE47AEB009A0594 /* SentryScopePersistentStoreTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryScopePersistentStoreTests.swift; sourceTree = "<group>"; };
D48225A02EEC4B6D00CDF32C /* BatcherMetadata.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BatcherMetadata.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3446,6 +3458,7 @@
7BFC16AC2524BCE700FF6266 /* SentryMessageTests.swift */,
7BFC16B82524D4AF00FF6266 /* SentryMessage+Equality.h */,
7BFC16B92524D4AF00FF6266 /* SentryMessage+Equality.m */,
D4749EEF2EF042C1000F9AE7 /* SentryMetricTests.swift */,
7BC6EC03255C235F0059822A /* SentryFrameTests.swift */,
7BC6EC07255C36DE0059822A /* SentryStacktraceTests.swift */,
7BC6EC0B255C3DF80059822A /* SentryThreadTests.swift */,
Expand Down Expand Up @@ -3521,6 +3534,7 @@
F498EBA52EE0B8E400F57509 /* SentrySwiftIntegrationInstallerTests.swift */,
843FB3422D156B9900558F18 /* Feedback */,
7BF6505D292B77D100BBA5A8 /* MetricKit */,
D46B041E2EDF173A00AF4A0A /* Metrics */,
D808FB85281AB2EF009A2A33 /* UIEvents */,
D8AB40D92806EBDC00E5E9F7 /* Screenshot */,
0A9BF4E528A123070068D266 /* ViewHierarchy */,
Expand Down Expand Up @@ -4394,6 +4408,24 @@
path = IO;
sourceTree = "<group>";
};
D46B04162EDF167800AF4A0A /* Metrics */ = {
isa = PBXGroup;
children = (
D46B044E2EDF260A00AF4A0A /* SentryMetricsBatcher.swift */,
D46B041C2EDF167D00AF4A0A /* SentryMetricsIntegration.swift */,
);
path = Metrics;
sourceTree = "<group>";
};
D46B041E2EDF173A00AF4A0A /* Metrics */ = {
isa = PBXGroup;
children = (
D4749F472EF062FD000F9AE7 /* SentryMetricsBatcherTests.swift */,
D46B041F2EDF175600AF4A0A /* SentryMetricsIntegrationTests.swift */,
);
path = Metrics;
sourceTree = "<group>";
};
D46D45E22D5F3FD600A1CB35 /* Plans */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -4665,12 +4697,12 @@
isa = PBXGroup;
children = (
D4D7AA6D2EEAD89300E28DFB /* Batcher */,
F451FAA52E0B304E0050ACF2 /* LoadValidator.swift */,
FA94E68B2E6B92BE00576666 /* SentryClientReport.swift */,
FA01BCB12E69352A00968DFA /* SentryDiscardedEvent.swift */,
FAE57C072E83092A00B710F9 /* SentryDispatchFactory.swift */,
FA94E6B12E6D265500576666 /* SentryEnvelope.swift */,
FA3AEE772E68E2830092283E /* SentryEnvelopeHeader.swift */,
FA01BCB12E69352A00968DFA /* SentryDiscardedEvent.swift */,
F451FAA52E0B304E0050ACF2 /* LoadValidator.swift */,
FA34C1A22E692A5000BC52AA /* SentryEnvelopeItem.swift */,
92235CAB2E15369900865983 /* SentryLogBatcher.swift */,
92235CAD2E15549C00865983 /* SentryLogger.swift */,
Expand Down Expand Up @@ -4878,6 +4910,7 @@
children = (
F4FE86BC2EECAC31003D845F /* Screenshot */,
925189AB2EDDA6A300557BD1 /* Log */,
D46B04162EDF167800AF4A0A /* Metrics */,
FAB0073C2E9F47DE001C806A /* Session */,
FAE579B42E7DBE9400B710F9 /* SentryGlobalEventProcessor.swift */,
FAD882C12EDAADF90055AA44 /* SwiftAsyncIntegration.swift */,
Expand All @@ -4898,6 +4931,7 @@
92ECD73F2E05AD500063EC10 /* SentryAttribute.swift */,
92ECD73D2E05AD2B0063EC10 /* SentryLogLevel.swift */,
9264E1EA2E2E385B00B077CF /* SentryLogMessage.swift */,
D46B04472EDF25E100AF4A0A /* SentryMetric.swift */,
F458D1122E180BB00028273E /* SentryFileManagerProtocol.swift */,
);
path = Protocol;
Expand Down Expand Up @@ -5829,8 +5863,10 @@
D8ACE3C82762187200F5A213 /* SentryFileIOTrackerHelper.m in Sources */,
D8B088B729C9E3FF00213258 /* SentryTracerConfiguration.m in Sources */,
FA7206E12E0B37C80072FDD4 /* SentryProfileCollector.mm in Sources */,
D46B044F2EDF260A00AF4A0A /* SentryMetricsBatcher.swift in Sources */,
9264E1EB2E2E385E00B077CF /* SentryLogMessage.swift in Sources */,
8ECC674A25C23A20000E2BF6 /* SentryTransactionContext.m in Sources */,
D46B04482EDF25E100AF4A0A /* SentryMetric.swift in Sources */,
03BCC38C27E1C01A003232C7 /* SentryTime.mm in Sources */,
A8F17B342902870300990B25 /* SentryHttpStatusCodeRange.m in Sources */,
62C97D3A2CC64E6B00DDA204 /* SentryUncaughtNSExceptions.m in Sources */,
Expand Down Expand Up @@ -6195,6 +6231,7 @@
62E59A5A2E8FB85300DB7A7B /* SentryTracePropagation.m in Sources */,
FAB007522E9FE2FF001C806A /* SentrySwizzleWrapper.swift in Sources */,
62E300942D5202890037AA3F /* SentryExceptionCodable.swift in Sources */,
D46B041D2EDF168400AF4A0A /* SentryMetricsIntegration.swift in Sources */,
0A2D8D5B289815C0008720F6 /* SentryBaseIntegration.m in Sources */,
639FCF991EBC7B9700778193 /* SentryEvent.m in Sources */,
D820CDB72BB1895F00BA339D /* SentrySessionReplayIntegration.m in Sources */,
Expand Down Expand Up @@ -6282,6 +6319,7 @@
7BFAA6E7297AA16A00E7E02E /* SentryCrashMonitor_CppException_Tests.mm in Sources */,
9286059929A50BAB00F96038 /* SentryGeoTests.swift in Sources */,
621655662DB12A8900810504 /* SentryCrashMach-OTests.m in Sources */,
D46B04202EDF175C00AF4A0A /* SentryMetricsIntegrationTests.swift in Sources */,
62B220BB2E93A9EC004620FF /* SentryTracePropagationTests.swift in Sources */,
D8B76B0828081461000A58C4 /* TestSentryScreenshotProvider.swift in Sources */,
A8AFFCD22907DA7600967CD7 /* SentryHttpStatusCodeRangeTests.swift in Sources */,
Expand Down Expand Up @@ -6391,6 +6429,7 @@
63FE722520DA66EC00CDBAE8 /* SentryCrashFileUtils_Tests.m in Sources */,
D86130122BB563FD004C0F5E /* SentrySessionReplayIntegrationTests.swift in Sources */,
7BFC16BA2524D4AF00FF6266 /* SentryMessage+Equality.m in Sources */,
D4749EF02EF042C1000F9AE7 /* SentryMetricTests.swift in Sources */,
92136D672C9D7660002A9FB8 /* SentryNSURLRequestBuilderTests.swift in Sources */,
F48E2E0A2E6637840073CB22 /* TestSentryCrashWrapper.swift in Sources */,
D855B3E827D652AF00BCED76 /* SentryCoreDataTrackingIntegrationTest.swift in Sources */,
Expand All @@ -6404,6 +6443,7 @@
7B16FD022654F86B008177D3 /* SentrySysctlTests.swift in Sources */,
7BAF3DB5243C743E008A5414 /* SentryClientTests.swift in Sources */,
D8F67AF12BE0D33F00C9197B /* UIImageHelperTests.swift in Sources */,
D4749F482EF062FD000F9AE7 /* SentryMetricsBatcherTests.swift in Sources */,
8EAE8E5E2681768000D6958B /* URLSessionTaskMock.m in Sources */,
62CB191E2E77F8B500AF5DA2 /* SentryDispatchSourceWrapperTests.swift in Sources */,
D8CE69BC277E39C700C6EC5C /* SentryFileIOTrackingIntegrationObjCTests.m in Sources */,
Expand Down
6 changes: 6 additions & 0 deletions SentryTestUtils/Sources/TestClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,10 @@ public class TestClient: SentryClientInternal {
public override func captureLogs() {
captureLogsInvocations.record(())
}

public var captureMetricsDataInvocations = Invocations<(data: Data, count: NSNumber)>()
public override func captureMetricsData(_ data: Data, with itemCount: NSNumber) {
captureMetricsDataInvocations.record((data, itemCount))
super.captureMetricsData(data, with: itemCount)
}
}
1 change: 1 addition & 0 deletions SentryTestUtils/Sources/TestOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public extension Options {
attachViewHierarchy = false
enableUIViewControllerTracing = false
#endif
experimental.enableMetrics = false
}

static func noIntegrations() -> Options {
Expand Down
28 changes: 23 additions & 5 deletions Sources/Sentry/SentryClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -1114,11 +1114,29 @@ - (void)captureLogs

- (void)captureLogsData:(NSData *)data with:(NSNumber *)itemCount
{
SentryEnvelopeItem *envelopeItem =
[[SentryEnvelopeItem alloc] initWithType:SentryEnvelopeItemTypes.log
data:data
contentType:@"application/vnd.sentry.items.log+json"
itemCount:itemCount];
[self captureData:data
with:itemCount
type:SentryEnvelopeItemTypes.log
contentType:@"application/vnd.sentry.items.log+json"];
}

- (void)captureMetricsData:(NSData *)data with:(NSNumber *)itemCount
{
[self captureData:data
with:itemCount
type:SentryEnvelopeItemTypes.traceMetric
contentType:@"application/vnd.sentry.items.trace-metric+json"];
}

- (void)captureData:(NSData *)data
with:(NSNumber *)itemCount
type:(NSString *)type
contentType:(NSString *)contentType
{
SentryEnvelopeItem *envelopeItem = [[SentryEnvelopeItem alloc] initWithType:type
data:data
contentType:contentType
itemCount:itemCount];
SentryEnvelope *envelope = [[SentryEnvelope alloc] initWithHeader:[SentryEnvelopeHeader empty]
singleItem:envelopeItem];
[self captureEnvelope:envelope];
Expand Down
9 changes: 9 additions & 0 deletions Sources/Sentry/SentryDataCategoryMapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
NSString *const kSentryDataCategoryNameSpan = @"span";
NSString *const kSentryDataCategoryNameFeedback = @"feedback";
NSString *const kSentryDataCategoryNameLogItem = @"log_item";
NSString *const kSentryDataCategoryNameTraceMetric = @"trace_metric";
NSString *const kSentryDataCategoryNameUnknown = @"unknown";

NS_ASSUME_NONNULL_BEGIN
Expand Down Expand Up @@ -57,6 +58,9 @@
if ([itemType isEqualToString:SentryEnvelopeItemTypes.log]) {
return kSentryDataCategoryLogItem;
}
if ([itemType isEqualToString:SentryEnvelopeItemTypes.traceMetric]) {
return kSentryDataCategoryTraceMetric;
}

return kSentryDataCategoryDefault;
}
Expand Down Expand Up @@ -113,6 +117,9 @@
if ([value isEqualToString:kSentryDataCategoryNameLogItem]) {
return kSentryDataCategoryLogItem;
}
if ([value isEqualToString:kSentryDataCategoryNameTraceMetric]) {
return kSentryDataCategoryTraceMetric;
}

return kSentryDataCategoryUnknown;
}
Expand Down Expand Up @@ -148,6 +155,8 @@
return kSentryDataCategoryNameFeedback;
case kSentryDataCategoryLogItem:
return kSentryDataCategoryNameLogItem;
case kSentryDataCategoryTraceMetric:
return kSentryDataCategoryNameTraceMetric;

default: // !!!: fall-through!
case kSentryDataCategoryUnknown:
Expand Down
1 change: 1 addition & 0 deletions Sources/Sentry/include/SentryClient+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)_swiftCaptureLog:(NSObject *)log withScope:(SentryScope *)scope;

- (void)captureLogs;
- (void)captureMetricsData:(NSData *)data with:(NSNumber *)itemCount;

@end

Expand Down
3 changes: 2 additions & 1 deletion Sources/Sentry/include/SentryDataCategory.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ typedef NS_ENUM(NSUInteger, SentryDataCategory) {
kSentryDataCategorySpan = 11,
kSentryDataCategoryFeedback = 12,
kSentryDataCategoryLogItem = 13,
kSentryDataCategoryUnknown = 14,
kSentryDataCategoryTraceMetric = 14,
kSentryDataCategoryUnknown = 15,
};
Comment thread
philprime marked this conversation as resolved.
3 changes: 2 additions & 1 deletion Sources/Swift/Core/Integrations/Integrations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ private struct AnyIntegration {

var integrations: [AnyIntegration] = [
.init(SwiftAsyncIntegration.self),
.init(SentryAutoSessionTrackingIntegration.self)
.init(SentryAutoSessionTrackingIntegration.self),
.init(SentryMetricsIntegration.self)
]

#if os(iOS) && !SENTRY_NO_UIKIT
Expand Down
3 changes: 3 additions & 0 deletions Sources/Swift/Helper/SentryEnabledFeaturesBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ import Foundation
if options.experimental.enableUnhandledCPPExceptionsV2 {
features.append("unhandledCPPExceptionsV2")
}
if options.experimental.enableMetrics {
features.append("metrics")
}

return features
}
Expand Down
1 change: 1 addition & 0 deletions Sources/Swift/Helper/SentryEnvelopeItemType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
public static let statsd = "statsd"
public static let profileChunk = "profile_chunk"
public static let log = "log"
public static let traceMetric = "trace_metric"
}
Loading
Loading