Skip to content

Instantly share code, notes, and snippets.

@nebsta
Created September 27, 2024 09:41
Show Gist options
  • Save nebsta/0053c64592247b1c6bc6bfe73ef393c2 to your computer and use it in GitHub Desktop.
Save nebsta/0053c64592247b1c6bc6bfe73ef393c2 to your computer and use it in GitHub Desktop.
SentrySpan.swift
// 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