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

Add OpenTelemetry event tracing to connections #3102

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
9ff77a8
Add a class to hold options pertaining to OpenTelemetry and update th…
SeanFarrow Mar 23, 2024
b823a91
Add a raw implmenetation of IConnectionLifetime allowing us to track …
SeanFarrow Mar 23, 2024
72e9668
Complete the implementation of the EventTracingConnectionLifetime cla…
SeanFarrow Mar 30, 2024
ba0515b
#3078 Providing a version for aggregating that is too high should agg…
erdtsieck Mar 21, 2024
5259eea
Fixed the combination of using an Include() + Select() where the sele…
jeremydmiller Apr 2, 2024
0306479
Adjusted the usage of metadata column data in patch expressions. Clos…
jeremydmiller Apr 2, 2024
421521c
Make strings constant where it makes sense.
SeanFarrow Apr 3, 2024
3cd6ae3
Added lock to prevent duplicate code generation
felixkmh Apr 2, 2024
6d69c8c
Added test for concurrent code generation
felixkmh Apr 2, 2024
d02ce6c
Extracted CreateDocumentProvider method
felixkmh Apr 2, 2024
1c094ea
Added test for concurrently appending DocumentProviders
felixkmh Apr 2, 2024
0c4bc19
Update vitepress and misc doc updates
Hawxy Apr 3, 2024
07132c7
Use StartActivity rather than CreateActivity and fix formatting.
SeanFarrow Apr 3, 2024
bcc0555
Super minor naming issue
jeremydmiller Apr 3, 2024
ac18d10
Refactor the code to add events when executing a command, batch or ba…
SeanFarrow Apr 3, 2024
1e903f9
Remove redundant conditional checks.
SeanFarrow Apr 3, 2024
52f29d1
Make the database activity nullable.
SeanFarrow Apr 3, 2024
4622a59
Unneeded parameter removal, some reformatting and use of more string …
SeanFarrow Apr 3, 2024
cc8d702
More string constants.
SeanFarrow Apr 3, 2024
9b96118
OpenTelemetryOptions updates.
SeanFarrow Apr 3, 2024
d64cebc
Remove unneeded constants and only use the EventTracingConnectionLife…
SeanFarrow Apr 3, 2024
bbbd9a0
Making the operation sorting only apply when there are document types…
jeremydmiller Apr 3, 2024
893f00c
Fix build errors.
SeanFarrow Apr 3, 2024
57b0229
Spiked in core basics of first class event subscriptions
jeremydmiller Apr 3, 2024
1ba5936
Ability to register a simple subscription and see it reflected in act…
jeremydmiller Apr 3, 2024
273ea64
First end to end usage of the new Subscription model
jeremydmiller Apr 3, 2024
b64cc84
Able to use event filters in subscriptions
jeremydmiller Apr 3, 2024
b22fcfe
Moved subscription tests to async daemon tests
jeremydmiller Apr 3, 2024
f8c43cc
Ability to use change listeners created by a subscription in the daemon
jeremydmiller Apr 3, 2024
b008ea4
Validating on subscription + projection name uniqueness
jeremydmiller Apr 3, 2024
68c00ee
SubscriptionWrapper to utilize just the ISubscription interface
jeremydmiller Apr 3, 2024
5c48379
ability to use service location in subscriptions
jeremydmiller Apr 3, 2024
08237ac
Fixed a unit test after an expected exception changed
jeremydmiller Apr 3, 2024
8678ec2
Changes spawned by the integration with Wolverine subscriptions
jeremydmiller Apr 5, 2024
59513c4
Changes to subscription signatures to make some things a little more …
jeremydmiller Apr 5, 2024
da08db7
New ShardRole logic on AsyncProjectionShard
jeremydmiller Apr 5, 2024
128f3c2
Can find the floor of a projection based on time
jeremydmiller Apr 5, 2024
48bdbce
Ability to rewind and replay a subscription.
jeremydmiller Apr 5, 2024
3c306ed
Fixing broken unit tests from change to agent construction
jeremydmiller Apr 5, 2024
0fd2e42
XML API comments for subscriptions. Closes GH-783
jeremydmiller Apr 5, 2024
51d548e
Bumping to 7.6
jeremydmiller Apr 5, 2024
0a009e2
Use the RecordException method in the OpenTelemetry.Api NuGet packages.
SeanFarrow Apr 6, 2024
b7a90cd
Remove unused constants and change the marten tenant id constant so i…
SeanFarrow Apr 7, 2024
a78b130
Use the ActivityTagsCollection for the tags parameter in all start ac…
SeanFarrow Apr 7, 2024
cd91d7b
Enable nullable annotations where required, make the StartActivity me…
SeanFarrow Apr 7, 2024
74b4852
Add defensive validations
Leh2 Apr 7, 2024
dce7026
Refactor type readiness check to use `_hasGenerated`
Leh2 Apr 9, 2024
307756f
Double lock on `_assembleLocker` has no effect
Leh2 Apr 9, 2024
2c8bf2a
Format
Leh2 Apr 9, 2024
36afb2a
Reuse `_assembleLocker`
Leh2 Apr 9, 2024
1f103e0
Revert "#3078 Providing a version for aggregating that is too high sh…
jeremydmiller Apr 10, 2024
e38245c
Ability to do scalar selects to DateTime. Closes GH-3117
jeremydmiller Apr 10, 2024
3f99b57
Changing an unnecessary unit test assertion
jeremydmiller Apr 10, 2024
6aed547
Hardening EventGraph.DisposeAsync() agianst the possibility that the …
jeremydmiller Apr 10, 2024
453894b
ability to use value + value expressions as values in Linq comparison…
jeremydmiller Apr 10, 2024
d0be21a
Add ability to get configured document schema names from IReadOnlySto…
elexisvenator Apr 10, 2024
e816009
Use shouldly
elexisvenator Apr 10, 2024
a21feef
Update doco
elexisvenator Apr 10, 2024
a46f1c9
Throwing a helpful Linq not supported exception on trying to query wi…
jeremydmiller Apr 10, 2024
4e1f28c
Added a convenience method for finding the table name for a document …
jeremydmiller Apr 10, 2024
389765c
Asynchronous version of configure marten to enable FeatureManagement …
jeremydmiller Apr 10, 2024
4b35ef0
Bumping to 7.7.0
jeremydmiller Apr 10, 2024
66acc07
Add tests for the Initialize method to ensure we only track events us…
SeanFarrow Apr 7, 2024
5dee594
Update the EventTracingConnectionLifetime class so it owns the OpenTe…
SeanFarrow Apr 15, 2024
aeb0e90
Added TenantId to IQuerySession signature. Closes GH-3141
jeremydmiller Apr 17, 2024
24e710a
Being able to specify where an event subscription starts
jeremydmiller Apr 10, 2024
b64b96c
Bumping to 7.8
jeremydmiller Apr 17, 2024
a6b5e22
Add tests.
SeanFarrow Apr 17, 2024
2119830
Add a class to hold options pertaining to OpenTelemetry and update th…
SeanFarrow Mar 23, 2024
9b7b8fd
Add a raw implmenetation of IConnectionLifetime allowing us to track …
SeanFarrow Mar 23, 2024
149da3d
Complete the implementation of the EventTracingConnectionLifetime cla…
SeanFarrow Mar 30, 2024
6da793a
Make strings constant where it makes sense.
SeanFarrow Apr 3, 2024
75dcee0
Use StartActivity rather than CreateActivity and fix formatting.
SeanFarrow Apr 3, 2024
835c6c7
Refactor the code to add events when executing a command, batch or ba…
SeanFarrow Apr 3, 2024
bcec43f
Remove redundant conditional checks.
SeanFarrow Apr 3, 2024
1b0ba4f
Make the database activity nullable.
SeanFarrow Apr 3, 2024
ab74f29
Unneeded parameter removal, some reformatting and use of more string …
SeanFarrow Apr 3, 2024
afb72d2
More string constants.
SeanFarrow Apr 3, 2024
ac9b131
OpenTelemetryOptions updates.
SeanFarrow Apr 3, 2024
75e4cfb
Remove unneeded constants and only use the EventTracingConnectionLife…
SeanFarrow Apr 3, 2024
abad98f
Fix build errors.
SeanFarrow Apr 3, 2024
6168adb
Use the RecordException method in the OpenTelemetry.Api NuGet packages.
SeanFarrow Apr 6, 2024
989ee3f
Remove unused constants and change the marten tenant id constant so i…
SeanFarrow Apr 7, 2024
f923278
Use the ActivityTagsCollection for the tags parameter in all start ac…
SeanFarrow Apr 7, 2024
5884ce9
Enable nullable annotations where required, make the StartActivity me…
SeanFarrow Apr 7, 2024
b81e588
Add tests for the Initialize method to ensure we only track events us…
SeanFarrow Apr 7, 2024
b150d00
Update the EventTracingConnectionLifetime class so it owns the OpenTe…
SeanFarrow Apr 15, 2024
c76e556
Add tests.
SeanFarrow Apr 17, 2024
2f67edb
Merge branch 'feature/sf/2909-open-telemetry' of https://github.com/S…
SeanFarrow Apr 18, 2024
05692ce
Tests for the EventTracingConnectionLifetim class.
SeanFarrow Apr 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docs-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- uses: actions/setup-node@v4
name: Setup node
with:
node-version: 18
node-version: 20
- run: npm install -g cspell
name: Install cSpell
- run: cspell --config ./docs/cSpell.json "docs/**/*.md"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:
config: Release
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
node_version: 18.x
node_version: 20.x

jobs:
build-and-test-code:
Expand All @@ -32,7 +32,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ env.node_version }}

Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<Version>7.5.0</Version>
<Version>7.8.0</Version>
<LangVersion>12.0</LangVersion>
<Authors>Jeremy D. Miller;Babu Annamalai;Oskar Dudycz;Joona-Pekka Kokko</Authors>
<PackageIconUrl>https://martendb.io/logo.png</PackageIconUrl>
Expand Down
15 changes: 9 additions & 6 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ const config: UserConfig<DefaultTheme.Config> = {
text: 'Configuration',
collapsed: false,
items: [
{ text: 'Bootstrap with HostBuilder', link: '/configuration/hostbuilder' },
{ text: 'Bootstrapping Marten', link: '/configuration/hostbuilder' },
{ text: 'Configuring Document Storage', link: '/configuration/storeoptions' },
{ text: 'Json Serialization', link: '/configuration/json' },
{ text: 'Resiliency Policies', link: '/configuration/retries' },
{ text: 'Pre-Building Generated Types', link: '/configuration/prebuilding' },
{ text: 'Command Line Tooling', link: '/configuration/cli' },
{ text: 'Development versus Production Usage', link: '/configuration/optimized_artifact_workflow' },
{ text: 'Optimized Development Workflow', link: '/configuration/optimized_artifact_workflow' },
{ text: 'Multi-Tenancy with Database per Tenant', link: '/configuration/multitenancy' },
{ text: 'Environment Checks', link: '/configuration/environment-checks' },
{ text: 'Custom IoC Integration', link: '/configuration/ioc' },
Expand All @@ -108,7 +108,7 @@ const config: UserConfig<DefaultTheme.Config> = {
{ text: 'Storing Documents', link: '/documents/storing' },
{ text: 'Deleting Documents', link: '/documents/deletes' },
{
text: 'Querying Documents', link: '/documents/querying/', collapsed: false, items: [
text: 'Querying Documents', link: '/documents/querying/', collapsed: true, items: [
{ text: 'Loading Documents by Id', link: '/documents/querying/byid' },
{ text: 'Querying Documents with Linq', link: '/documents/querying/linq/' },
{ text: 'Supported Linq Operators', link: '/documents/querying/linq/operators' },
Expand All @@ -130,7 +130,7 @@ const config: UserConfig<DefaultTheme.Config> = {
},

{
text: 'Indexing Documents', link: '/documents/indexing/', collapsed: false, items: [
text: 'Indexing Documents', link: '/documents/indexing/', collapsed: true, items: [
{ text: 'Calculated Indexes', link: '/documents/indexing/computed-indexes' },
{ text: 'Duplicated Fields', link: '/documents/indexing/duplicated-fields' },
{ text: 'Unique Indexes', link: '/documents/indexing/unique' },
Expand Down Expand Up @@ -165,7 +165,7 @@ const config: UserConfig<DefaultTheme.Config> = {
{ text: 'Metadata', link: '/events/metadata' },
{ text: 'Archiving Streams', link: '/events/archiving' },
{
text: 'Projections Overview', link: '/events/projections/', collapsed: false, items: [
text: 'Projections Overview', link: '/events/projections/', collapsed: true, items: [
{
text: 'Aggregate Projections', link: '/events/projections/aggregate-projections', items: [
{ text: 'Live Aggregations', link: '/events/projections/live-aggregates' },
Expand All @@ -181,8 +181,11 @@ const config: UserConfig<DefaultTheme.Config> = {
{ text: 'Rebuilding Projections', link: '/events/projections/rebuilding' },
{ text: 'Projections and IoC Services', link: '/events/projections/ioc' },
{ text: 'Async Daemon HealthChecks', link: '/events/projections/healthchecks' },]
},
{
text: 'Event Subscriptions',
link: '/events/subscriptions'
},

{
text: 'Event Versioning',
link: '/events/versioning'
Expand Down
87 changes: 72 additions & 15 deletions docs/configuration/hostbuilder.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
# Bootstrapping in .Net Applications
# Bootstrapping Marten

:::tip
The exact formula for bootstrapping .Net applications has changed quite a bit from early .Net Core to the latest `WebApplication` model in .Net 6.0 at the time this page was last updated. Regardless, the `IServiceCollection` abstraction for registering services in an IoC container has remained stable and everything in this page functions against that model.
:::

As briefly shown in the [getting started](/) page, Marten comes with extension methods for the .Net Core standard `IServiceCollection` to quickly add Marten services to any .Net application that is bootstrapped by either the [Generic IHostBuilder abstraction](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/generic-host) or the [ASP.Net Core IWebHostBuilder](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.hosting.iwebhostbuilder) or the [.Net 6 WebApplication](https://docs.microsoft.com/en-us/aspnet/core/migration/50-to-60?view=aspnetcore-6.0&tabs=visual-studio#new-hosting-model) hosting models.

Jumping right into a basic ASP&#46;NET Core application using the out of the box Web API template, you'd have a class called `Startup` that holds most of the configuration for your application including
the IoC service registrations for your application in the `Startup.ConfigureServices()` method. To add Marten to your application, use the `AddMarten()` method as shown below:
As briefly shown in the [getting started](/) page, Marten comes with the `AddMarten()` extension method for the .NET `IServiceCollection` to quickly add Marten to any ASP&#46;NET Core or Worker Service application:

<!-- snippet: sample_StartupConfigureServices -->
<a id='snippet-sample_startupconfigureservices'></a>
Expand All @@ -19,6 +12,9 @@ builder.Services.AddMarten(options =>
// Establish the connection string to your Marten database
options.Connection(builder.Configuration.GetConnectionString("Marten")!);

// Specify that we want to use STJ as our serializer
options.UseSystemTextJsonForSerialization();

// If we're running in development mode, let Marten just take care
// of all necessary schema building and patching behind the scenes
if (builder.Environment.IsDevelopment())
Expand All @@ -27,7 +23,7 @@ builder.Services.AddMarten(options =>
}
});
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/AspNetCoreWithMarten/Program.cs#L14-L29' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_startupconfigureservices' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/AspNetCoreWithMarten/Program.cs#L15-L33' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_startupconfigureservices' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

The `AddMarten()` method will add these service registrations to your application:
Expand All @@ -46,9 +42,10 @@ At runtime, when your application needs to resolve `IDocumentStore` for the firs

1. Resolve a `StoreOptions` object from the initial `AddMarten()` configuration
2. Apply all registered `IConfigureMarten` services to alter that `StoreOptions` object
3. Reads the `IHostEnvironment` for the application if it exists to try to determine the main application assembly and paths for generated code output
4. Attaches any `IInitialData` services that were registered in the IoC container to the `StoreOptions` object
5. *Finally*, Marten builds a new `DocumentStore` object using the now configured `StoreOptions` object
3. Apply all registered `IAsyncConfigureMarten` services to alter that `StoreOptions` object
4. Reads the `IHostEnvironment` for the application if it exists to try to determine the main application assembly and paths for generated code output
5. Attaches any `IInitialData` services that were registered in the IoC container to the `StoreOptions` object
6. *Finally*, Marten builds a new `DocumentStore` object using the now configured `StoreOptions` object

This model is comparable to the .Net `IOptions` model.

Expand Down Expand Up @@ -215,7 +212,7 @@ public interface IConfigureMarten
void Configure(IServiceProvider services, StoreOptions options);
}
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/Marten/MartenServiceCollectionExtensions.cs#L816-L827' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_iconfiguremarten' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/Marten/MartenServiceCollectionExtensions.cs#L894-L905' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_iconfiguremarten' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

You could alternatively implement a custom `IConfigureMarten` (or `IConfigureMarten<T> where T : IDocumentStore` if you're [working with multiple databases](#working-with-multiple-marten-databases)) class like so:
Expand Down Expand Up @@ -258,7 +255,67 @@ public static IServiceCollection AddUserModule2(this IServiceCollection services
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/CoreTests/BootstrappingExamples.cs#L36-L53' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_addusermodule2' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

## Using Lightweight Sessions
### Using IoC Services for Configuring Marten <Badge type="tip" text="7.7" />

There is also a newer mechanism called `IAsyncConfigureMarten` that was originally built to enable services
like the [Feature Management library from Microsoft](https://learn.microsoft.com/en-us/azure/azure-app-configuration/use-feature-flags-dotnet-core) to
be used to selectively configure Marten using potentially asynchronous methods and IoC resolved services.

That interface signature is:

<!-- snippet: sample_IAsyncConfigureMarten -->
<a id='snippet-sample_iasyncconfiguremarten'></a>
```cs
/// <summary>
/// Mechanism to register additional Marten configuration that is applied after AddMarten()
/// configuration, but before DocumentStore is initialized when you need to utilize some
/// kind of asynchronous services like Microsoft's FeatureManagement feature to configure Marten
/// </summary>
public interface IAsyncConfigureMarten
{
ValueTask Configure(StoreOptions options, CancellationToken cancellationToken);
}
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/Marten/MartenServiceCollectionExtensions.cs#L907-L919' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_iasyncconfiguremarten' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

As an example from the tests, here's a custom version that uses the Feature Management service:

<!-- snippet: sample_FeatureManagementUsingExtension -->
<a id='snippet-sample_featuremanagementusingextension'></a>
```cs
public class FeatureManagementUsingExtension: IAsyncConfigureMarten
{
private readonly IFeatureManager _manager;

public FeatureManagementUsingExtension(IFeatureManager manager)
{
_manager = manager;
}

public async ValueTask Configure(StoreOptions options, CancellationToken cancellationToken)
{
if (await _manager.IsEnabledAsync("Module1"))
{
options.Events.MapEventType<Module1Event>("module1:event");
}
}
}
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/CoreTests/configuring_marten_with_async_extensions.cs#L77-L97' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_featuremanagementusingextension' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

And lastly, these extensions can be registered directly against `IServiceCollection` like so:

<!-- snippet: sample_registering_async_config_marten -->
<a id='snippet-sample_registering_async_config_marten'></a>
```cs
services.ConfigureMartenWithServices<FeatureManagementUsingExtension>();
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/CoreTests/configuring_marten_with_async_extensions.cs#L34-L38' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_registering_async_config_marten' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

## Using Lightweight Sessions

::: tip
Most usages of Marten should default to the lightweight sessions for better performance
Expand Down
8 changes: 1 addition & 7 deletions docs/configuration/optimized_artifact_workflow.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
# Development versus Production Usage

:::tip
Marten V5.0 introduces the new `AddMarten().OptimizeArtifactWorkflow()` option
that helps users utilize Marten "best practices" for database and code generation
artifact creation.
:::
# Optimized Development Workflow

The original point of Marten was to have a persistence option that mostly got out of your way and
let developers just get things done without having to spend a lot of time fiddling with database
Expand Down
12 changes: 6 additions & 6 deletions docs/configuration/prebuilding.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Pre-Building Generated Types

Marten >= v4 extensively uses runtime code generation backed by [Roslyn runtime compilation](https://jeremydmiller.com/2018/06/04/compiling-code-at-runtime-with-lamar-part-1/) for dynamic code.
Marten uses runtime code generation backed by [Roslyn runtime compilation](https://jeremydmiller.com/2018/06/04/compiling-code-at-runtime-with-lamar-part-1/) for dynamic code.
This is both much more powerful than [source generators](https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview) in what it allows us to actually do, but can have
significant memory usage and “[cold start](https://en.wikipedia.org/wiki/Cold_start_(computing))” problems (seems to depend on exact configurations, so it’s not a given that you’ll have these issues).
Fear not though, Marten v4 introduced a facility to “generate ahead” the code to greatly optimize the "cold start" and memory usage in production scenarios.
Fear not though, Marten introduced a facility to “generate ahead” the code to greatly optimize the "cold start" and memory usage in production scenarios.

The code generation for document storage, event handling, event projections, and additional document stores can be done
with one of three modes as shown below:
Expand All @@ -21,17 +21,17 @@ using var store = DocumentStore.For(opts =>

// Marten will only use types that are compiled into
// the application assembly ahead of time. This is the
// V4 "pre-built" model
// "pre-built" model
opts.GeneratedCodeMode = TypeLoadMode.Static;

// New for V5. More explanation in the docs:)
// Explained Below :)
opts.GeneratedCodeMode = TypeLoadMode.Auto;
});
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/CoreTests/Examples/CodeGenerationOptions.cs#L16-L35' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_code_generation_modes' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

The *Auto* mode is new for Marten V5 to alleviate usability issues for folks who did not find the command line options or pre-registration
The *Auto* mode was added alleviate usability issues for folks who did not find the command line options or pre-registration
of document types to be practical. Using the `Marten.Testing.Documents.User` document from the Marten testing suite
as an example, let's start a new document store with the `Auto` mode:

Expand Down Expand Up @@ -80,7 +80,7 @@ into the actually deployed binaries for the system in production deployments. Of
you will need to delete the generated code.

:::tip
Just like ASP.Net MVC, Marten uses the `IHostEnvironment.ApplicationName` property to determine the main application assembly. If
Just like ASP.NET Core, Marten uses the `IHostEnvironment.ApplicationName` property to determine the main application assembly. If
that value is missing, Marten falls back to the `Assembly.GetEntryAssembly()` value.
:::

Expand Down
2 changes: 1 addition & 1 deletion docs/diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public interface IDocumentSessionListener
void DocumentAddedForStorage(object id, object document);
}
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/Marten/IDocumentSessionListener.cs#L8-L84' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_idocumentsessionlistener' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/Marten/IDocumentSessionListener.cs#L27-L103' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_idocumentsessionlistener' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

You can build and inject your own listeners by adding them to the `StoreOptions` object you use to configure a `DocumentStore`:
Expand Down
2 changes: 1 addition & 1 deletion docs/documents/aspnetcore.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
For a little more context, see the blog post [Efficient Web Services with Marten V4](https://jeremydmiller.com/2021/09/28/efficient-web-services-with-marten-v4/).
:::

In Marten V4, there is a small new addon that adds helpers for ASP.Net Core development, expressly
Marten has a small addon that adds helpers for ASP.Net Core development, expressly
the ability to very efficiently _stream_ the raw JSON of persisted documents straight to an HTTP response
without every having to waste time with deserialization/serialization or even reading the data into a JSON
string in memory.
Expand Down
Loading
Loading