Skip to content

Add deployment environments to events - #371

Open
ejsmith wants to merge 19 commits into
mainfrom
feature/event-environments
Open

ejsmith wants to merge 19 commits into
mainfrom
feature/event-environments

Conversation

@ejsmith

@ejsmith ejsmith commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Adds a first-class deployment environment (the root environment field) to every event. The server uses it for environment filtering, per-environment notifications and the project allow-list (Exceptionless #2570, #2711).

API

client.Configuration.SetEnvironment("production");             // client default
client.CreateLog("Deployed").SetEnvironment("staging").Submit(); // per event

Precedence (the first match wins)

# Source
1 Per event: EventBuilder.SetEnvironment
2 Code: Configuration.Environment / SetEnvironment, including the AddExceptionless(c => …) callback
3 Config: Exceptionless:Environment (IConfiguration or app setting), Exceptionless__Environment, [assembly: Exceptionless(Environment = …)], <exceptionless environment="…">
4 Host: IHostEnvironment.EnvironmentName
5 Process: ASPNETCORE_ENVIRONMENT, then DOTNET_ENVIRONMENT, then AZURE_FUNCTIONS_ENVIRONMENT

Integrations

Integration Source
ASP.NET Core / Generic Host / Worker Host name, via every AddExceptionless overload, UseExceptionless() (both builders and IApplicationBuilder) and ExceptionlessLifetimeService
Console / Lambda / Functions Process env vars, or config
NLog Target Environment layout, e.g. ${environment:DOTNET_ENVIRONMENT}
log4net <environment> on both appenders
MEL The client's environment
Legacy Web / WebApi / Mvc / WinForms / WPF Config section, app settings or attribute

Behavior

  • Validation: names are trimmed and must match the server regex ^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$. Casing is kept. An invalid or empty configured value leaves the event unspecified; it does not fall back.
  • Plugin order: the environment is applied by a priority-1 plugin, so exclusions, aggregate splitting and duplicate checking all see it.
  • Duplicates: the environment is part of the duplicate hash. Names that differ only by casing merge, matching the server.
  • Separate from diagnostics: data.@environment (machine diagnostics) is unchanged.

Notes

  • Upgrade order for self-hosting: upgrade the server first. Older servers store the root environment as custom data.
  • New default: a hosted app that doesn't configure an environment now reports its host name, usually Production.
  • Docs: README section, .agents skill references, and the AspNetCore, Console and Web samples.
  • Tests: detection order, the full precedence chain, attribute and env-var sources, the IHostBuilder, lifetime-service and IApplicationBuilder paths, NLog and log4net settings, casing in duplicate checking, plus the existing configuration, plugin and serializer coverage.
  • Related: the Serilog sink follow-up (draft PR, held until the client is released) and Exceptionless.JavaScript How exceptionless uses nlog.config #193.

Copilot AI lite review requested due to automatic review settings September 10, 2026 03:32
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T21:02:24.849825Z 64fecd4 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The DI registration change for externally provided ExceptionlessClient may alter disposal/ownership semantics in a potentially breaking way and should be clarified/adjusted before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR introduces first-class “deployment environment” support in the Exceptionless .NET client so events can be tagged (and deduplicated) by environment while keeping existing runtime/environment diagnostics separate.

Changes:

  • Add ExceptionlessConfiguration.Environment (default) and Event.Environment (per-event override) with consistent normalization/validation.
  • Add fluent helpers (SetEnvironment(...)) and support reading the environment from IConfiguration and environment variables.
  • Update hosting integration to fall back to IHostEnvironment.EnvironmentName, and extend tests to cover serialization, defaults, hosting, and duplicate detection behavior.
File summaries
File Description
test/Exceptionless.Tests/Serializer/Models/EventSerializerTests.cs Adds JSON round-trip coverage ensuring top-level environment is distinct from data.@environment.
test/Exceptionless.Tests/Plugins/910_DuplicateCheckerPluginTests.cs Verifies duplicate detection behavior is scoped to environment.
test/Exceptionless.Tests/Plugins/015_ConfigurationDefaultsPluginTests.cs Ensures default environment applies only when the event doesn’t override it.
test/Exceptionless.Tests/Platforms/HostingExtensionsTests.cs Validates hosting fallback to IHostEnvironment.EnvironmentName when not explicitly configured.
test/Exceptionless.TestHarness/Serializer/StorageSerializerTestBase.cs Includes environment in harness event creation for storage serialization coverage.
src/Platforms/Exceptionless.Extensions.Hosting/ExceptionlessExtensions.cs Applies hosting fallback for environment during DI registration/resolution.
src/Exceptionless/Utility/DeploymentEnvironment.cs Introduces centralized environment normalization/validation logic.
src/Exceptionless/Plugins/Default/015_ConfigurationDefaultsPlugin.cs Applies default configuration environment to events when unspecified.
src/Exceptionless/Models/Client/Event.cs Adds Event.Environment, includes it in equality/hash, and serializes it as top-level environment.
src/Exceptionless/Extensions/ExceptionlessConfigurationExtensions.cs Adds configuration helper and reads environment from config/env vars.
src/Exceptionless/Extensions/EventBuilderExtensions.cs Adds EventBuilder.SetEnvironment(...) for per-event overrides.
src/Exceptionless/Configuration/ExceptionlessConfiguration.cs Adds ExceptionlessConfiguration.Environment with normalization/validation.
README.md Documents environment configuration, overrides, normalization rules, and separation from runtime metadata.
Review details
  • Files reviewed: 14/14 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6f4f13670b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ejsmith

ejsmith commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2ac945eb94

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ejsmith

ejsmith commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5f875dcdd6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ejsmith

ejsmith commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fca9d0e0b3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ejsmith

ejsmith commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cb3f2150ef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ejsmith

ejsmith commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 609fe96b8d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ejsmith

ejsmith commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

@codex review

@ejsmith

ejsmith commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e984cd781

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Cover reading Exceptionless:Environment from IConfiguration and both DI
factory overloads, and document that a configured empty value stays
unspecified and that Startup re-reads environment variables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ejsmith

ejsmith commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@ejsmith

ejsmith commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: a315b7dd38

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Startup re-reads environment variables (and, on .NET Framework, the
configuration file), which replaced an environment set in code.
Configuration sources now apply only when code has not set one, and
later sources still replace earlier ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ejsmith

ejsmith commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 3785ce2b8a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

ejsmith and others added 6 commits November 2, 2026 18:01
Names are trimmed, then must match ^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$.
Anything else is unspecified and never rewritten.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New clients fall back to ASPNETCORE_ENVIRONMENT, DOTNET_ENVIRONMENT, then
AZURE_FUNCTIONS_ENVIRONMENT at the lowest precedence. The lifetime service
and ASP.NET Core UseExceptionless now apply IHostEnvironment, covering
IHostBuilder.UseExceptionless and services.AddExceptionless(client).
SetDefaultEnvironment(null) no longer clears a detected value.
Adds ExceptionlessAttribute.Environment, an NLog target Environment layout,
and an Environment setting on both log4net appenders. Tests cover the
full precedence chain, detection order and the Exceptionless__Environment
variable.
The server matches environments case-insensitively, so the client
duplicate checker now does too.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 64fecd4852

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants