Skip to content

Commit

Permalink
use own instrumentation name
Browse files Browse the repository at this point in the history
  • Loading branch information
arriIsHere committed Nov 20, 2024
1 parent 6967340 commit ef672fe
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
21 changes: 15 additions & 6 deletions Sources/Honeycomb/UIKit/NavigationInstrumentation.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
#if canImport(UIKit)
import Foundation
import OpenTelemetryApi
import UIKit
import Foundation
import OpenTelemetryApi
import UIKit

public func installUINavigationInstrumentation() {
UIViewController.swizzle()
}
private let honeycombUIKitInstrumentationName = "@honeycombio/instrumentation-uikit"

internal func getUIKitViewTracer() -> Tracer {
return OpenTelemetry.instance.tracerProvider.get(
instrumentationName: honeycombUIKitInstrumentationName,
instrumentationVersion: honeycombLibraryVersion
)
}

public func installUINavigationInstrumentation() {
UIViewController.swizzle()
}
#endif
4 changes: 2 additions & 2 deletions Sources/Honeycomb/UIKit/UIViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

// Internal classes from SwiftUI will likely begin with an underscore
if !className.hasPrefix("_") {
let span = getViewTracer().spanBuilder(spanName: "viewDidAppear").startSpan()
let span = getUIKitViewTracer().spanBuilder(spanName: "viewDidAppear").startSpan()
if self.title != nil {
span.setAttribute(key: "title", value: self.title!)
}
Expand All @@ -27,7 +27,7 @@

// Internal classes from SwiftUI will likely begin with an underscore
if !className.hasPrefix("_") {
let span = getViewTracer().spanBuilder(spanName: "viewDidDisappear").startSpan()
let span = getUIKitViewTracer().spanBuilder(spanName: "viewDidDisappear").startSpan()
if self.title != nil {
span.setAttribute(key: "title", value: self.title!)
}
Expand Down
4 changes: 2 additions & 2 deletions smoke-tests/smoke-e2e.bats
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ mk_diag_attr() {
}

@test "UIViewController attributes are correct" {
result=$(attributes_from_span_named "@honeycombio/instrumentation-view" viewDidAppear | \
result=$(attributes_from_span_named "@honeycombio/instrumentation-uikit" viewDidAppear | \
jq "select (.key == \"className\")" | \
jq "select (.value.stringValue == \"UIViewController\").value.stringValue")
assert_equal "$result" '"UIViewController"'

result=$(attributes_from_span_named "@honeycombio/instrumentation-view" viewDidDisappear | \
result=$(attributes_from_span_named "@honeycombio/instrumentation-uikit" viewDidDisappear | \
jq "select (.key == \"className\")" | \
jq "select (.value.stringValue == \"UIViewController\").value.stringValue")
assert_equal "$result" '"UIViewController"'
Expand Down

0 comments on commit ef672fe

Please sign in to comment.