-
Notifications
You must be signed in to change notification settings - Fork 3
Convenience functions for spans and events #91
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Currently, the experience for instrumenting custom spans and events with the ADOT SDK on Swift is a little cubersome and code-heavy. It shouldn't be too much effort to ship convenience functions for instrumenting apps with custom telemetry.
For example, customers could have the following experience:
// Simple span
AwsOpenTelemetryAgent.span("load_user_profile") { span in
let user = database.getUser(userId: userId)
processUser(user)
}
// Span with attributes
AwsOpenTelemetryAgent.span("checkout", attributes: [
"cart.items": .int(3),
"cart.total": .double(49.99)
]) { span in
processCheckout()
}
// Async span with return value
let products = try await AwsOpenTelemetryAgent.span("fetch_products") { span in
let result = try await api.getProducts()
span.setAttribute(key: "count", value: result.count)
return result
}
// Simple event
AwsOpenTelemetryAgent.event("button_clicked")
// Event with details
AwsOpenTelemetryAgent.event(
"purchase_completed",
body: "User completed checkout",
attributes: [
"order.id": .string("12345"),
"order.total": .double(99.99)
]
)ADOT Android SDK has this already: https://github.com/aws-observability/aws-otel-android/blob/main/core/src/main/kotlin/software/amazon/opentelemetry/android/features/CustomSpanClient.kt
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request