Created
September 27, 2024 09:41
-
-
Save nebsta/0053c64592247b1c6bc6bfe73ef393c2 to your computer and use it in GitHub Desktop.
SentrySpan.swift
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
// Copyright © 2023 Trustpilot. All rights reserved. | |
import Foundation | |
import Sentry | |
class SentrySpan: SentrySpanProtocol { | |
private let sentrySpan: Span | |
init(span: Span) { | |
self.sentrySpan = span | |
} | |
func startChild(operation: String) -> SentrySpanProtocol { | |
let sentrySpan = self.sentrySpan.startChild(operation: operation) | |
return SentrySpan(span: sentrySpan) | |
} | |
func finish(status: TrustpilotSpanStatus) { | |
sentrySpan.finish(status: status.toSentrySpanStatus()) | |
} | |
func finish() { | |
sentrySpan.finish() | |
} | |
} | |
extension TrustpilotSpanStatus { | |
func toSentrySpanStatus() -> SentrySpanStatus { | |
switch self { | |
case .internalError: return .internalError | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment