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

Allow custom registration of Redis ElasticApmProfiler #1229

Merged
merged 1 commit into from
Mar 22, 2021

Conversation

glucaci
Copy link
Contributor

@glucaci glucaci commented Mar 18, 2021

In order to register the profiler for Microsoft.Extensions.Caching.StackExchangeRedis we need public access to ElasticApmProfiler because the IConnectionMultiplexer is encapsulated in the RedisCache implementation.

Bellow is an example for which I have also opened a PR in dotnet/aspnetcore#31018 to allow hooking up the ProfilerSession

public static class ServiceCollectionExtensions
{
    public static void RegisterElasticApmRedis(this IServiceCollection services)
    {
        services
            .AddSingleton<IDistributedCache>(sp =>
            {
                var profiler = new ElasticApmProfiler(sp.GetService<IApmAgent>);
                var options = new RedisCacheOptions()
                {
                    Configuration = "localhost",
                    ProfilingSession = profiler.GetProfilingSession
                };

                return new RedisCache(options);
            });
    }
}

@cla-checker-service
Copy link

cla-checker-service bot commented Mar 18, 2021

💚 CLA has been signed

@apmmachine
Copy link
Contributor

apmmachine commented Mar 18, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Started by user Russ Cam

  • Start Time: 2021-03-22T00:19:29.577+0000

  • Duration: 59 min 14 sec

  • Commit: b40a7e6

Test stats 🧪

Test Results
Failed 0
Passed 18759
Skipped 80
Total 18839

Trends 🧪

Image of Build Times

Image of Tests

@glucaci
Copy link
Contributor Author

glucaci commented Mar 18, 2021

I've signed the CLA, must be re-checked

Copy link
Contributor

@russcam russcam left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @glucaci 👍

@russcam russcam merged commit 95ad7d6 into elastic:master Mar 22, 2021
@glucaci glucaci deleted the redisCustomRegistration branch March 22, 2021 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants