Skip to content
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

Resilience telemetry API #1138

Merged
merged 1 commit into from
Apr 17, 2023
Merged

Resilience telemetry API #1138

merged 1 commit into from
Apr 17, 2023

Conversation

martintmk
Copy link
Contributor

@martintmk martintmk commented Apr 17, 2023

The issue or feature being addressed

Closes #1112

Details on the issue fix or feature implementation

This PR enables the real telemetry for Polly.Core by calling the EnableTelemetry extension.

API Usage:

var options = new ResilienceStrategyTelemetryOptions
{
    LoggerFactory = NullLoggerFactory.Instance
};

// configure custom enrichers
options.Enrichers.Add(context =>
{
    context.Tags.Add(new KeyValuePair<string, object?>("my-custom-dimension", "some-value"));
});
        
// enable telemetry
var builder = new ResilienceStrategyBuilder().EnableTelemetry(options);

The telemetry is automatically enabled for resilience strategies added using IServiceCollection.

Confirm the following

  • I started this PR by branching from the head of the default branch
  • I have targeted the PR to merge into the default branch
  • I have included unit tests for the issue/feature
  • I have successfully run a local build

@martintmk martintmk added the v8 Issues related to the new version 8 of the Polly library. label Apr 17, 2023
@martintmk martintmk added this to the v8.0.0 milestone Apr 17, 2023
Comment on lines +102 to +106
foreach (var pair in context.Tags)
{
tags.Add(pair.Key, pair.Value);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
foreach (var pair in context.Tags)
{
tags.Add(pair.Key, pair.Value);
}
if (context.Tags.Count > 0)
{
foreach (var pair in context.Tags)
{
tags.Add(pair.Key, pair.Value);
}
}

@martintmk martintmk force-pushed the mtomka/resiliencetelemetry branch from 979084b to b0d5a03 Compare April 17, 2023 15:02
@martintmk martintmk enabled auto-merge (squash) April 17, 2023 15:07
@martintmk martintmk merged commit a3b57f9 into main Apr 17, 2023
@martintmk martintmk deleted the mtomka/resiliencetelemetry branch April 17, 2023 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v8 Issues related to the new version 8 of the Polly library.
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Implement telemetry in Polly.Extensions
2 participants