-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default logging behaviour when using InstanceName is unintuitive #1547
Comments
I am not sure whether this is a bur or feature. Let me explain the behavior/thinking about the instance name. Instance name is meant as an additional dimension in case there are multiple pipeline instances with the same name. It's advanced feature in case composite pipeline keys are used. For example: Polly/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs Line 79 in 305ac23
The reason
These two would always be the same as opposed to:
In the latter example we at least know that no instance was specified automatically. Besides nothing prevents anyone from doing: new ServiceCollection().AddResiliencePipeline("my-key", builder =>
{
builder.InstanceName = "my-instance-name";
builder.AddConcurrencyLimiter(100);
}); In the case above the telemetry is:
|
I'll re-check what I was doing, but this came up because (if I remember correctly) I saw that despite setting the instance name in the configuration method, the instance name was missing in the logs. |
Yep, the values are missing from the logged values unless the formatter is set. Not set:
Set:
|
Can you point me to piece that sets the |
It doesn't in the PR, I just changed it locally to add |
I tried to replicate the problem in #1555 but it works ok. |
I've pushed a change to martincostello/polly-sandbox#1 to set |
Managed to replicate this, this problem only occurs with reloadable pipelines. Will fix tomorrow. |
If a user chooses to set a
InstanceName
on a strategy/pipeline, its value is never passed through to telemetry and is always null.This is because by default the
InstanceNameFormatter
is null, so any value is always formatted to benull
:Polly/src/Polly.Core/Registry/ResiliencePipelineRegistryOptions.cs
Lines 38 to 49 in 445c582
To get the desired behaviour, instead the user has to explicitly configure the internally-registered-by-default
ResiliencePipelineRegistryOptions<TKey>
type to provide a formatter for each type they generate a registry for:This behaviour is not intuitive (I had to work it out by debugging through the Polly sources from my app).
It would be much easier for users to instead just apply a default formatter to the instance the same as we do for
BuilderNameFormatter
:Polly/src/Polly.Core/Registry/ResiliencePipelineRegistryOptions.cs
Lines 51 to 63 in 445c582
We could always pre-allocate the default formatter delegates as a private static field if allocations are a concern.
The text was updated successfully, but these errors were encountered: