Adding Segments to an HKWorkout

I want to add segments into a running HKWorkout. My understanding is that I should use the addWorkoutEvents method in my HKWorkoutBuilder. Here is a sample of my code:

func saveSegment(forStep step: GymWorkoutEventStep) {
    let dateInterval = DateInterval(start: step.startDate ?? Date(), end: Date())
    let metadata = [
        HKMetadataKeyWasUserEntered: true
    ]
    let event = HKWorkoutEvent(type: .segment, dateInterval: dateInterval, metadata: metadata)
    builder?.addWorkoutEvents([event], completion: { success, error in
        print(success ? "Success saving segment" : error.debugDescription)
    })
}

I’m trying to implement the same feature that the native Apple Watch “Workout” app has by adding a segment when a user double taps the screen. My code seems to work as I see “Success saving segment” in the console. However, once the workout is finished, the Apple Fitness app doesn’t show these segments. What am I missing? Also, is there a way to add distance and pace to each segment using MetadataKey’s or is this not an option? Thanks for any help you can provide.