Repository navigation
Manage environments and environment notifications per project #2711
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
Open
ejsmith
wants to merge
10
commits into
main
Choose a base branch
from
feature/environment-management
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+5,655
−104
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
38228a8
Manage environments and environment notifications per project
ejsmith 5feccfa
Harden environment notifications after review
ejsmith 0a4018f
Confirm risky environment settings and let users fix observed casing
ejsmith 03eaf9d
Close remaining races and gaps in pending notification handling
ejsmith d2fece8
Mark every copy of a regressed stack in a batch
ejsmith 90edbc0
Share the regression claim between immediate and deferred notifications
ejsmith db5e71b
Simplify the environments page
ejsmith 8911758
Keep Cancel from adding an environment
ejsmith 6264e61
Treat environment names as identifiers
ejsmith 7e11288
Use a valid environment name in the filter retention e2e test
ejsmith File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/Exceptionless.Core/Extensions/ProjectEnvironmentExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| using Exceptionless.Core.Models; | ||
|
|
||
| namespace Exceptionless.Core.Extensions; | ||
|
|
||
| /// <summary> | ||
| /// The single place that decides how a project treats an event's environment. Matching is always case-insensitive. | ||
| /// A project with no listed environments and default settings discards nothing and notifies for everything. | ||
| /// </summary> | ||
| public static class ProjectEnvironmentExtensions | ||
| { | ||
| public static ProjectEnvironment? FindEnvironment(this Project project, string? environment) | ||
| { | ||
| if (String.IsNullOrEmpty(environment) || project.Environments is not { Count: > 0 }) | ||
| return null; | ||
|
|
||
| foreach (var listed in project.Environments) | ||
| { | ||
| if (ProjectEnvironment.NamesMatch(listed.Name, environment)) | ||
| return listed; | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Returns the listed casing for a listed environment, otherwise the name as it was given. | ||
| /// </summary> | ||
| public static string? GetEnvironmentDisplayName(this Project project, string? environment) | ||
| { | ||
| return project.FindEnvironment(environment)?.Name ?? environment; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Events without an environment are only discarded when unlisted environments are discarded as well. | ||
| /// </summary> | ||
| public static bool ShouldDiscardEnvironment(this Project project, string? environment) | ||
| { | ||
| if (!project.DiscardUnlistedEnvironments) | ||
| return false; | ||
|
|
||
| if (String.IsNullOrEmpty(environment)) | ||
| return project.DiscardEventsWithoutEnvironment; | ||
|
|
||
| return project.FindEnvironment(environment) is null; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Listed environments use their own setting. Unlisted environments and events without an environment use the project setting. | ||
| /// </summary> | ||
| public static bool ShouldNotifyForEnvironment(this Project project, string? environment) | ||
| { | ||
| return project.FindEnvironment(environment)?.Notify ?? project.NotifyOtherEnvironments; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| namespace Exceptionless.Core.Models; | ||
|
|
||
| /// <summary> | ||
| /// An environment name that recently had events discarded because it is not listed on the project. | ||
| /// </summary> | ||
| public record DiscardedEnvironment | ||
| { | ||
| /// <summary> | ||
| /// The lowercased key for the environment, or null for events that had no environment. | ||
| /// </summary> | ||
| public string? Key { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// The first-seen casing of the name, or null for events that had no environment. | ||
| /// </summary> | ||
| public string? Name { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// The number of events discarded within the retention window. | ||
| /// </summary> | ||
| public long Count { get; init; } | ||
|
|
||
| public DateTime LastSeenUtc { get; init; } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// The names that recently had events discarded, plus how many events came from names that could not be listed individually. | ||
| /// </summary> | ||
| public record DiscardedEnvironmentSummary | ||
| { | ||
| public IReadOnlyCollection<DiscardedEnvironment> Environments { get; init; } = []; | ||
|
|
||
| /// <summary> | ||
| /// Events within the retention window from names beyond the per-project limit. | ||
| /// </summary> | ||
| public long OtherEvents { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// How many different names those events came from, up to a limit. | ||
| /// </summary> | ||
| public int OtherNames { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// True when there were more other names than are counted. | ||
| /// </summary> | ||
| public bool OtherNamesCapped { get; init; } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| namespace Exceptionless.Core.Models; | ||
|
|
||
| /// <summary> | ||
| /// A notification that waits for the first occurrence in a notifying environment. | ||
| /// </summary> | ||
| public enum PendingStackNotification | ||
| { | ||
| New, | ||
| Regression | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
BLOCKER: For existing events with previously valid names such as
Staging West,prod/eu, orprodução, this stricter normalization also runs during deserialization, not just when adding managed environments.EventEnvironmentConverter.Readuses this method and now moves those stored values into custom data instead of populatingEnvironment, so fetching historical events changes their public API representation and makes their environment disappear from event details. Preserve the previous read contract for persisted events, even if newly listed names must follow stricter rules, and cover a historical-record round trip.AGENTS.md reference: AGENTS.md:L74-L75
Useful? React with 👍 / 👎.