-
Notifications
You must be signed in to change notification settings - Fork 332
Add Filter
option to StackExchangeRedisInstrumentationOptions
#2804
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
Conversation
...OpenTelemetry.Instrumentation.StackExchangeRedis/StackExchangeRedisInstrumentationOptions.cs
Outdated
Show resolved
Hide resolved
...y.Instrumentation.StackExchangeRedis/Implementation/RedisProfilerEntryToActivityConverter.cs
Outdated
Show resolved
Hide resolved
Hi @matt-hensley :) |
...OpenTelemetry.Instrumentation.StackExchangeRedis/StackExchangeRedisInstrumentationOptions.cs
Outdated
Show resolved
Hide resolved
...OpenTelemetry.Instrumentation.StackExchangeRedis/StackExchangeRedisInstrumentationOptions.cs
Outdated
Show resolved
Hide resolved
…angeRedisInstrumentationOptions.cs Co-authored-by: Martin Costello <martin@martincostello.com>
…angeRedisInstrumentationOptions.cs Co-authored-by: Martin Costello <martin@martincostello.com>
Could this be merged now that it's been approved? |
@aradalvand tests are failing could you please check. |
@rajkumar-rangaraj The failing tests all seem to be connection failures: Can you please tell me what I should do? I'm confused. |
@matt-hensley Do you any idea why tests fail here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FilterOption_FiltersOutSpecifiedCommands
issues commands, and even if all commands are filtered out the driver still tries to connect to an instance, making it more of an integration test. To work as expected it needs the [SkipUnlessEnvVarFoundTheory(RedisEndPointEnvVarName)]
attribute added and then the connection setup modified to respect that env var.
A filter specific test can be added to RedisProfilerEntryToActivityConverterTests that does not require a connection:
[Fact]
public void ProfilerCommandToActivity_UsesFilter()
{
var activity = new Activity("redis-profiler");
var profiledCommand = new TestProfiledCommand(DateTime.UtcNow);
var options = new StackExchangeRedisInstrumentationOptions
{
Filter = command => false,
};
var result = RedisProfilerEntryToActivityConverter.ProfilerCommandToActivity(activity, profiledCommand, options);
Assert.Null(result);
}
```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds a Filter
option to StackExchangeRedisInstrumentationOptions
enabling early filtering of profiled commands.
- Introduce a
Filter
property on the options class - Apply the filter in
ProfilerCommandToActivity
to skip unwanted commands - Update tests, changelog, and public API to include the new option
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/OpenTelemetry.Instrumentation.StackExchangeRedis/StackExchangeRedisInstrumentationOptions.cs | Add Filter property and XML documentation |
src/OpenTelemetry.Instrumentation.StackExchangeRedis/Implementation/RedisProfilerEntryToActivityConverter.cs | Invoke Filter callback and skip commands when it returns false or throws |
test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs | Add a test validating that GET commands are filtered out |
src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md | Document the new Filter option in unreleased section |
src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/PublicAPI.Unshipped.txt | Expose the Filter getter and setter in the public API |
Comments suppressed due to low confidence (2)
src/OpenTelemetry.Instrumentation.StackExchangeRedis/StackExchangeRedisInstrumentationOptions.cs:25
- The XML documentation for
Filter
is misleading; clarify that the predicate returns true to include (collect) events and false (or exceptions) to filter them out.
/// <summary>
test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs:389
- Add a test case to verify behavior when the filter callback throws an exception to ensure it correctly filters out the command.
public void FilterOption_FiltersOutSpecifiedCommands(string value)
...y.Instrumentation.StackExchangeRedis/Implementation/RedisProfilerEntryToActivityConverter.cs
Show resolved
Hide resolved
@rajkumar-rangaraj Could you please consider merging? Thanks. |
Thanks @aradalvand for your contribution! |
Fixes #2803
Changes
Filter
option (in line with conventions that most libraries in this repo follow) toStackExchangeRedisInstrumentationOptions
.Merge requirement checklist
CHANGELOG.md
files updated for non-trivial changes