URLSession Task Publisher / TaskDelegate / Metrics

Using the Combine URLSessionTask Publisher, is there a way to still access a reference to the URLSessionTask to set a delegate?

What I'm trying to do is collect network metrics by handling the delegate calls of URLSession did finish collecting metrics.
Answered by DTS Engineer in 662341022

However, the question is still sort of valid for things like setting
the taskDescription.

I don’t think so. However, I’m not sure of the utility of this. In most cases you use taskDescription to map from the task to some other state you’re tracking, and the closures you hang off the publisher chain can just capture that state directly.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Nevermind. Forgot the delegate's set through URLSession itself.
However, the question is still sort of valid for things like setting the taskDescription.
Accepted Answer

However, the question is still sort of valid for things like setting
the taskDescription.

I don’t think so. However, I’m not sure of the utility of this. In most cases you use taskDescription to map from the task to some other state you’re tracking, and the closures you hang off the publisher chain can just capture that state directly.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
I normally use the taskDescription as like a human-friendly description of the task for debug logs/console and the taskIdentifier more of a unique id for mapping and identifying. But I think you are right, since it's the only task property that is altered after init I can think of. It's not worth allowing setting it at the expense of complicating things which are otherwise very nicely done in Combine.
URLSession Task Publisher / TaskDelegate / Metrics
 
 
Q