Repository navigation
Add event environments and filtering #2570
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
Merged
+2,109
−67
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
c337d52
Add event environments and filtering
ejsmith ac99281
Keep migration seed fixture current with registered migrations
ejsmith 05efc27
Scope environment choices to the active saved view time range
ejsmith abe2060
Update browser tests for the machine and runtime tab label
ejsmith dd1470b
Support environment on GET event submissions
ejsmith cc1cfc1
Preserve supplied environment casing
ejsmith cf55b42
Merge main into event environments
ejsmith 438c801
Preserve legacy environment custom data
ejsmith decc608
Merge latest main into feature/event-environments
ejsmith 9f33344
Merge latest main into feature/event-environments
ejsmith 6213938
Preserve legacy environment strings during event ingestion
ejsmith bd760b7
Retain submitted environment key casing during ingestion
ejsmith 591d22c
Avoid duplicate environment data in GET submissions and retries
ejsmith 3bd5cec
Merge branch 'main' into feature/event-environments
ejsmith d0e053f
Merge latest main into feature/event-environments
ejsmith a50f93b
Store valid root environments only as the deployment environment
ejsmith fc32e90
Retain explicit null root environments as custom data
ejsmith 61a0b9e
Fix environment-scoped user counts, cross-environment session closing…
ejsmith 35caa7b
Merge remote-tracking branch 'origin/main' into t3code/merge-main-rev…
ejsmith 9059546
Keep heartbeats across session pages and scope environment discovery …
ejsmith 17e987a
Ignore negated project groups and keep heartbeats when session paging…
ejsmith 81c2365
Only narrow environment discovery to projects that certainly limit a …
ejsmith 50eb848
Parse raw searches to find the projects that scope environment discovery
ejsmith c4c200b
Intersect project scopes combined by AND when scoping environment dis…
ejsmith 39a8093
Treat project terms other than exact IDs as unscoped in environment d…
ejsmith 96ade49
Keep session heartbeats written while the inactive session job runs
ejsmith 0f72037
Use Arrange, Act, and Assert sections in the environment tests
ejsmith 15dea4a
Keep the first heartbeat value read across session pages
ejsmith f15ee8d
Stop forwarding API requests before the API-origin e2e test ends
ejsmith 9191986
Merge remote-tracking branch 'origin/main' into t3code/merge-main-rev…
ejsmith 3ce6501
Let an environment in a saved view link override the saved filter
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
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,73 @@ | ||
| --- | ||
| title: "Environments" | ||
| --- | ||
|
|
||
| # Environments | ||
|
|
||
| Use an environment to distinguish production, staging, development, or a custom deployment within one project. Each event can carry one optional top-level `environment` string. The same error still belongs to one stack, with one shared status and fixed version. | ||
|
|
||
| ## Configure your client | ||
|
|
||
| Set a default during application startup. In the .NET client: | ||
|
|
||
| ```csharp | ||
| client.Configuration.SetEnvironment("production"); | ||
| client.CreateLog("Deployment complete").SetEnvironment("staging").Submit(); | ||
| ``` | ||
|
|
||
| You can also set `Exceptionless:Environment` in .NET configuration, or the `Exceptionless__Environment` environment variable. The hosting integration uses `IHostEnvironment.EnvironmentName` when no explicit environment is configured. A per-event value overrides the default. | ||
|
|
||
| In the JavaScript client: | ||
|
|
||
| ```javascript | ||
| await Exceptionless.startup((config) => { | ||
| config.apiKey = "API_KEY_HERE"; | ||
| config.environment = "production"; | ||
| }); | ||
|
|
||
| await Exceptionless.createLog("Deployment complete") | ||
| .setEnvironment("staging") | ||
| .submit(); | ||
| ``` | ||
|
|
||
| For direct API submissions: | ||
|
|
||
| ```json | ||
| { | ||
| "type": "log", | ||
| "message": "Deployment complete", | ||
| "environment": "production" | ||
| } | ||
| ``` | ||
|
|
||
| Names are trimmed, with a maximum of 64 characters. Events preserve the supplied casing: `" Production "` is stored and returned as `"Production"`. Filtering is case-insensitive, and aggregation keys are normalized to lowercase, so `Production` and `production` share one environment bucket. Custom names such as `qa-west` are supported. Empty, oversized, control-character, and non-string values are treated as unspecified. Historical events and older clients without this field remain unspecified; they are never assumed to be production. | ||
|
|
||
| ## Filter your data | ||
|
|
||
| Choose **Manage filters → Environment** on Events, Stacks, Sessions, or Stream. Select one or more names, or **Unspecified** for events without an environment. Clear the selection to include all environments. The picker discovers names for the selected projects and time range; you can also enter a name that has no current events. | ||
|
|
||
| Environment selections persist in URLs and saved views. Events, sessions, and stream tables have an optional Environment column. Event details show Environment in the overview when the event has one; **Machine & runtime** contains the existing `data.@environment` diagnostics. | ||
|
|
||
| Environment searches and aggregations are available on every plan: | ||
|
|
||
| | Search | Meaning | | ||
| | --- | --- | | ||
| | `environment:production` | Production events | | ||
| | `(environment:production OR environment:staging)` | Either deployment | | ||
| | `_missing_:environment` | Historical or unspecified events | | ||
| | `_exists_:environment` | Events with an environment | | ||
| | `environment:"qa west"` | A custom name containing spaces | | ||
|
|
||
| Stack dashboard counts and charts use events matching the filter. Stack status remains shared, so changing status while viewing production also changes the same stack seen in staging. Automatic session detection separates the same user's activity by environment. Session heartbeats do not include an environment, so a heartbeat keeps the user's open sessions active in every environment. | ||
|
|
||
| Notifications and the **New** view are not environment-aware yet. A stack is new once, when its first event arrives from any environment. An error first seen in development triggers the new error notification then, and is not reported as new again when it reaches production; the **New** view also dates it from that first occurrence. Critical error and regression notifications are sent for events from every environment. | ||
|
|
||
| ## Fixing stacks across deployments | ||
|
|
||
| Use [fixed in version](/docs/versioning/) when environments run different releases. For example, if a stack is fixed in `2.4.0`, occurrences from production running `2.3.0` do not represent a regression just because staging already has the fix. Continue sending the application version with events. Plain **Fixed**, without a version, retains its existing behavior across all environments. | ||
|
|
||
| ## Rollout | ||
|
|
||
| Deploy the server before adopting SDK versions that expose the new setting. The server adds mappings to existing event indices without rewriting historical events. Self-hosted installs should let the migration job finish before the new API and job instances process events: events written to an existing index before the mapping is added keep their environment but cannot be filtered or aggregated by it. Clients that do not send an environment continue to work. `data.@environment` and custom `data.environment` values retain their existing meanings. | ||
|
|
||
| Before this release, the server stored an unrecognized root `environment` property as custom data in `data.environment`. A valid root `environment` string is now stored only as the event's environment, trimmed, so read it from `environment` instead of `data.environment`. Any other root value, such as null, an object, a number, a blank string, or an oversized name, is still stored as `data.environment`. If `data.environment` already exists, that value uses the next available key (`environment1`, `environment2`, and so on). |
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
36 changes: 36 additions & 0 deletions
36
src/Exceptionless.Core/Migrations/010_AddEventEnvironment.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,36 @@ | ||
| using Exceptionless.Core.Extensions; | ||
| using Exceptionless.Core.Models; | ||
| using Exceptionless.Core.Repositories.Configuration; | ||
| using Foundatio.Repositories.Elasticsearch.Extensions; | ||
| using Foundatio.Repositories.Migrations; | ||
| using Microsoft.Extensions.Logging; | ||
|
|
||
| namespace Exceptionless.Core.Migrations; | ||
|
|
||
| public sealed class AddEventEnvironment : MigrationBase | ||
|
ejsmith marked this conversation as resolved.
|
||
| { | ||
| private readonly ExceptionlessElasticConfiguration _configuration; | ||
|
|
||
| public AddEventEnvironment(ExceptionlessElasticConfiguration configuration, ILoggerFactory loggerFactory) : base(loggerFactory) | ||
| { | ||
| _configuration = configuration; | ||
| MigrationType = MigrationType.VersionedAndResumable; | ||
| Version = 10; | ||
| } | ||
|
|
||
| public override async Task RunAsync(MigrationContext context) | ||
| { | ||
| var response = await _configuration.Client.Indices.PutMappingAsync<PersistentEvent>(mapping => mapping | ||
| .Indices($"{_configuration.Events.Name}-v*-*") | ||
| .AllowNoIndices(true) | ||
| .IgnoreUnavailable(true) | ||
| .Properties(properties => properties.Text(ev => ev.Environment, | ||
| text => text.Analyzer(EventIndex.LOWER_KEYWORD_ANALYZER) | ||
| .Fields(fields => fields.Keyword("keyword", keyword => keyword.Normalizer("lowercase"))))), context.CancellationToken); | ||
| _logger.LogRequest(response); | ||
| if (!response.IsValidResponse) | ||
| { | ||
| throw new InvalidOperationException("Unable to add the event environment mapping: " + response.DebugInformation); | ||
| } | ||
| } | ||
| } | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.