Skip to content
Open
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
303d533
feat(metrics): Add implementation for metrics envelope item
philprime Dec 2, 2025
b991cda
Remove unrelated change
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
0ae250e
Merge branch 'philprime/metrics-bootstrap' into philprime/metrics-env…
philprime Dec 11, 2025
a7c7df9
Merge branch 'philprime/metrics-bootstrap' into philprime/metrics-env…
philprime Dec 11, 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
f7a67bb
Merge branch 'philprime/metrics-bootstrap' into philprime/metrics-env…
philprime Dec 15, 2025
70241f7
cleanup
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
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
2a05eb7
Merge branch 'philprime/metrics-bootstrap' into philprime/metrics-env…
philprime Dec 16, 2025
c8b4ab5
fix tests for integraiton checking
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
f10a253
update changelog
philprime Dec 16, 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
082e70b
Merge branch 'philprime/metrics-bootstrap' into philprime/metrics-env…
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
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

### Features

- Add integration to collect Metrics, can be enabled by setting `options.enableMetrics = true` (#6956)
- 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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,19 @@ public struct SentrySDKWrapper {

// Integration: Metrics
options.experimental.enableMetrics = SentrySDKOverrides.Metrics.enable.boolValue
options.experimental.beforeSendMetric = { metric in
// Modify the metric in the callback
var modifiedMetric = metric

// Modify the value of the metric
if case .counter(let value) = modifiedMetric.value, modifiedMetric.name == "test.metric" {
modifiedMetric.value = .counter(value + 100)
}

// Add a custom attribute to the metric
modifiedMetric.attributes["custom-attribute"] = .init(string: "some-value")
return modifiedMetric
}

// Experimental features
options.enableFileManagerSwizzling = !SentrySDKOverrides.Other.disableFileManagerSwizzling.boolValue
Expand Down
32 changes: 30 additions & 2 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,11 @@
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 All @@ -789,6 +793,9 @@
D48891CC2E98F22A00212823 /* SentryInfoPlistWrapperProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48891C62E98F21D00212823 /* SentryInfoPlistWrapperProvider.swift */; };
D48891CE2E98F28E00212823 /* SentryInfoPlistWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48891CD2E98F28E00212823 /* SentryInfoPlistWrapper.swift */; };
D48891D02E98F2E700212823 /* SentryInfoPlistError.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48891CF2E98F2E600212823 /* SentryInfoPlistError.swift */; };
D48953FE2EF5756A0086F240 /* SentryMetricValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48953FD2EF5756A0086F240 /* SentryMetricValue.swift */; };
D48954052EF575960086F240 /* SentryMetricValueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48954042EF575960086F240 /* SentryMetricValueTests.swift */; };
D48954072EF579360086F240 /* SentryEnvelopeItemTypesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48954062EF579320086F240 /* SentryEnvelopeItemTypesTests.swift */; };
D48E8B8B2D3E79610032E35E /* SentryTraceOrigin.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48E8B8A2D3E79610032E35E /* SentryTraceOrigin.swift */; };
D48E8B9D2D3E82AC0032E35E /* SentrySpanOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48E8B9C2D3E82AC0032E35E /* SentrySpanOperation.swift */; };
D490648A2DFAE1F600555785 /* SentryScreenshotOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D49064892DFAE1F600555785 /* SentryScreenshotOptions.swift */; };
Expand Down Expand Up @@ -2151,9 +2158,13 @@
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 All @@ -2163,6 +2174,9 @@
D48891C62E98F21D00212823 /* SentryInfoPlistWrapperProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryInfoPlistWrapperProvider.swift; sourceTree = "<group>"; };
D48891CD2E98F28E00212823 /* SentryInfoPlistWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryInfoPlistWrapper.swift; sourceTree = "<group>"; };
D48891CF2E98F2E600212823 /* SentryInfoPlistError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryInfoPlistError.swift; sourceTree = "<group>"; };
D48953FD2EF5756A0086F240 /* SentryMetricValue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryMetricValue.swift; sourceTree = "<group>"; };
D48954042EF575960086F240 /* SentryMetricValueTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryMetricValueTests.swift; sourceTree = "<group>"; };
D48954062EF579320086F240 /* SentryEnvelopeItemTypesTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryEnvelopeItemTypesTests.swift; sourceTree = "<group>"; };
D48E8B8A2D3E79610032E35E /* SentryTraceOrigin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryTraceOrigin.swift; sourceTree = "<group>"; };
D48E8B9C2D3E82AC0032E35E /* SentrySpanOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySpanOperation.swift; sourceTree = "<group>"; };
D49064892DFAE1F600555785 /* SentryScreenshotOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryScreenshotOptions.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3450,6 +3464,8 @@
7BFC16AC2524BCE700FF6266 /* SentryMessageTests.swift */,
7BFC16B82524D4AF00FF6266 /* SentryMessage+Equality.h */,
7BFC16B92524D4AF00FF6266 /* SentryMessage+Equality.m */,
D4749EEF2EF042C1000F9AE7 /* SentryMetricTests.swift */,
D48954042EF575960086F240 /* SentryMetricValueTests.swift */,
7BC6EC03255C235F0059822A /* SentryFrameTests.swift */,
7BC6EC07255C36DE0059822A /* SentryStacktraceTests.swift */,
7BC6EC0B255C3DF80059822A /* SentryThreadTests.swift */,
Expand Down Expand Up @@ -3623,6 +3639,7 @@
62F05D2A2C0DB1F100916E3F /* SentryLogTestHelper.m */,
7BBD18BA24530D2600427C76 /* SentryFileManagerTests.swift */,
FA21A2E92E60E9C700E7EADB /* EnvelopeComparison.swift */,
D48954062EF579320086F240 /* SentryEnvelopeItemTypesTests.swift */,
7BD4E8E727FD95900086C410 /* SentryMigrateSessionInitTests.m */,
631501BA1EE6F30B00512C5B /* SentrySwizzleTests.m */,
7B34721628086A9D0041F047 /* SentrySwizzleWrapperTests.swift */,
Expand Down Expand Up @@ -4402,6 +4419,7 @@
D46B04162EDF167800AF4A0A /* Metrics */ = {
isa = PBXGroup;
children = (
D46B044E2EDF260A00AF4A0A /* SentryMetricsBatcher.swift */,
D46B041C2EDF167D00AF4A0A /* SentryMetricsIntegration.swift */,
);
path = Metrics;
Expand All @@ -4410,6 +4428,7 @@
D46B041E2EDF173A00AF4A0A /* Metrics */ = {
isa = PBXGroup;
children = (
D4749F472EF062FD000F9AE7 /* SentryMetricsBatcherTests.swift */,
D46B041F2EDF175600AF4A0A /* SentryMetricsIntegrationTests.swift */,
);
path = Metrics;
Expand Down Expand Up @@ -4686,12 +4705,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 @@ -4920,6 +4939,8 @@
92ECD73F2E05AD500063EC10 /* SentryAttribute.swift */,
92ECD73D2E05AD2B0063EC10 /* SentryLogLevel.swift */,
9264E1EA2E2E385B00B077CF /* SentryLogMessage.swift */,
D46B04472EDF25E100AF4A0A /* SentryMetric.swift */,
D48953FD2EF5756A0086F240 /* SentryMetricValue.swift */,
F458D1122E180BB00028273E /* SentryFileManagerProtocol.swift */,
);
path = Protocol;
Expand Down Expand Up @@ -5851,8 +5872,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 All @@ -5861,6 +5884,7 @@
8453421628BE8A9500C22EEC /* SentrySpanStatus.m in Sources */,
6292585B2DAFA5F70049388F /* SentryCrashCxaThrowSwapper.c in Sources */,
FA8AFCEF2E843903007A0E18 /* SentryFileIOTracker.swift in Sources */,
D48953FE2EF5756A0086F240 /* SentryMetricValue.swift in Sources */,
F4FE86BD2EECAC31003D845F /* SentryScreenshotOptions.swift in Sources */,
F4FE86BE2EECAC31003D845F /* SentryScreenshotIntegration.swift in Sources */,
92D957732E05A44600E20E66 /* SentryAsyncLog.m in Sources */,
Expand Down Expand Up @@ -6255,6 +6279,7 @@
FAC62B652E15A4100003909D /* SentrySDKThreadTests.swift in Sources */,
D82915632C85EF0C00A6CDD4 /* SentryViewPhotographerTests.swift in Sources */,
D8DBE0CA2C0E093000FAB1FD /* SentryTouchTrackerTests.swift in Sources */,
D48954072EF579360086F240 /* SentryEnvelopeItemTypesTests.swift in Sources */,
D4AF7D2C2E9404ED004F0F59 /* SentryUIRedactBuilderTests+EdgeCases.swift in Sources */,
D8F67AF42BE10F9600C9197B /* SentryUIRedactBuilderTests.swift in Sources */,
92ECD7482E05B57C0063EC10 /* SentryAttributeTests.swift in Sources */,
Expand Down Expand Up @@ -6395,6 +6420,7 @@
F49D419A2DEA2FB000D9244E /* SentryCrashExceptionApplicationTests.swift in Sources */,
D88817DD26D72BA500BF2251 /* SentryTraceContextTests.swift in Sources */,
D4E3F35D2D4A864600F79E2B /* SentryNSDictionarySanitizeTests.swift in Sources */,
D48954052EF575960086F240 /* SentryMetricValueTests.swift in Sources */,
7B984A9F28E572AF001F4BEE /* CrashReport.swift in Sources */,
927D21FB2ED5DE8A00916D31 /* FlushLogsIntegrationTests.swift in Sources */,
D4AF00252D2E93C400F5F3D7 /* SentryNSFileManagerSwizzlingTests.m in Sources */,
Expand All @@ -6415,6 +6441,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 @@ -6428,6 +6455,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)
}
}
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,
};
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