You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Impossible to set Activity.IdFormat when using ActivitySource #43853
Because the ActivitySource doesn't expose the IdFormat in any way it's impossible to set the value before the new activity is started. The format is inferred from the global setting or the parent if it exists but if there is no parent and the global setting is hierarchical it's impossible to start a W3C root activity.
Regression?
Regression from the previous pattern, it was possible to set Activity.IdFormat using Activity.SetIdFormat before calling DiagnosticSource.StartActivity
In 6.0 we already added an overload for ActivitySource.StartActivity. The proposal here is just adding the idFormat as optional parameter to that overload.
Thanks @pakrym! Not pushing back but curious to get your thoughts, at what point do you envision the library should own the choice of id format? For example a distributed system has a request come in to a particular process that has a hierarchial id, framework creates an Activity when the message is received, optional additional Activities in the user's code, some more Activities in the library code, and then eventually the id gets serialized on the wire of an outbound request. At some point a change in id format would need to happen. My intuition would be to do it as late as possible, ideally as the last Activity before the format hits the wire. In that model we would look more at overriding the HttpClient behavior rather than eagerly doing format conversions as soon as the library creates its first Activity.
In terms of workarounds overall these are the only ones I could think of:
set the global default id format - libraries probably don't want that responsibility
use the Activity constructor with DiagnosticListener as I assume you are already doing
use ActivitySource most places, but funnel everything through a path that creates at least one Activity with the old constructor, allowing the format to be coerced if needed before it gets to the wire
Customize or override HttpClient's DiagnosticHandler to take more control of the id that gets written on the wire.
As for the best forward looking solution, I'd be tempted to change the default id format from Hierarchical -> W3C for .NET Framework apps too. Apps wouldn't get the new behavior unless they updated to a new major version of DiagnosticSource.dll (for example v6) which implies these are apps in at least semi-active development as opposed to stable apps that are just trying to pick up security fixes. Hopefully our experience changing the default for the netcoreapp TFM would give us some warning signs if this is more dangerous than I expect. Thoughts?
Not pushing back but curious to get your thoughts, at what point do you envision the library should own the choice of id format?
To be honest, I don't think I care about Azure SDK having a choice of IdFormat it seems more like an issue of a bad default and not being able to override it.
My intuition would be to do it as late as possible, ideally as the last Activity before the format hits the wire. In that model we would look more at overriding the HttpClient behavior rather than eagerly doing format conversions as soon as the library creates its first Activity.
In practice, you need Ids earlier than that. For example to add links to the activity.
As for the best forward looking solution, I'd be tempted to change the default id format from Hierarchical -> W3C for .NET Framework apps too
I think changing the default for all ActivitySource consumers to W3C would be the best solution. Can we patch it in 5.0.1?
Activity
pakrym commentedon Oct 26, 2020
cc @cijothomas @reyang
noahfalk commentedon Oct 27, 2020
Thanks @pakrym! Not pushing back but curious to get your thoughts, at what point do you envision the library should own the choice of id format? For example a distributed system has a request come in to a particular process that has a hierarchial id, framework creates an Activity when the message is received, optional additional Activities in the user's code, some more Activities in the library code, and then eventually the id gets serialized on the wire of an outbound request. At some point a change in id format would need to happen. My intuition would be to do it as late as possible, ideally as the last Activity before the format hits the wire. In that model we would look more at overriding the HttpClient behavior rather than eagerly doing format conversions as soon as the library creates its first Activity.
In terms of workarounds overall these are the only ones I could think of:
As for the best forward looking solution, I'd be tempted to change the default id format from Hierarchical -> W3C for .NET Framework apps too. Apps wouldn't get the new behavior unless they updated to a new major version of DiagnosticSource.dll (for example v6) which implies these are apps in at least semi-active development as opposed to stable apps that are just trying to pick up security fixes. Hopefully our experience changing the default for the netcoreapp TFM would give us some warning signs if this is more dangerous than I expect. Thoughts?
pakrym commentedon Oct 27, 2020
Not pushing back but curious to get your thoughts, at what point do you envision the library should own the choice of id format?
To be honest, I don't think I care about Azure SDK having a choice of
IdFormatit seems more like an issue of a bad default and not being able to override it.In practice, you need Ids earlier than that. For example to add links to the activity.
I think changing the default for all ActivitySource consumers to W3C would be the best solution. Can we patch it in 5.0.1?
tarekgh commentedon Oct 27, 2020
This will be a breaking change which we try to avoid in the servicing releases.
terrajobst commentedon Feb 16, 2021
Video
CreateActivitytarekgh commentedon Feb 16, 2021
Just to clarify: the requested functionality is covered by the proposal #42784.
pakrym commentedon Feb 17, 2021
@noahfalk had concerns with the approach of changing
IdKindafter running sampler callbacks. We should reconsider adding the parameter.tarekgh commentedon Feb 18, 2021
After discussion we'll address this issue with the final approved proposal #42784 (comment).