Unleash

Dosaic.Plugins.Management.Unleash is a Dosaic plugin that integrates Unleasharrow-up-right feature flag management into ASP.NET Core applications. It bridges the Unleash client SDK with the Microsoft.FeatureManagement abstraction, enabling gradual rollouts, experimentation, and kill-switch controls without redeployment.

Installation

dotnet add package Dosaic.Plugins.Management.Unleash

Or as a <PackageReference> in your .csproj:

<PackageReference Include="Dosaic.Plugins.Management.Unleash" Version="" />

Dependencies:

Configuration

The plugin reads its settings from the unleash section of your application configuration, bound via [Configuration("unleash")].

unleash:
  appName: "my-app"
  apiUri: "http://localhost:4242/api/"
  apiToken: "default:development.your-api-token-here"
  instanceTag: "instance-1"
Property
Description

appName

Name of your application, reported to the Unleash server

apiUri

Full URI to your Unleash API, e.g. http://localhost:4242/api/

apiToken

API token created in the Unleash web UI

instanceTag

Unique tag to identify this running instance

Usage

Checking a feature flag in code

Inject IFeatureManager and call IsEnabledAsync with the toggle name as defined in Unleash:

Guarding a controller or action with [FeatureGate]

Apply [FeatureGate] at the controller or action level. When the toggle is disabled, the plugin returns a 404 Not Found response (via FeatureNotEnabledDisabledHandler).

MVC Razor views

Add the tag helper and use the <feature> tag to conditionally render view content:

Conditional middleware

Gate an entire middleware on a feature toggle:

Conditional MVC filters

Register an MVC action filter that is only active when a toggle is enabled:

Toggle types

FeatureToggleType provides constants for the standard Unleash toggle strategies:

Constant
Value

FeatureToggleType.Release

"release"

FeatureToggleType.Experiment

"experiment"

FeatureToggleType.Operational

"operational"

FeatureToggleType.KillSwitch

"killSwitch"

FeatureToggleType.Permission

"permission"

Features

  • Automatic Unleash context propagationUnleashMiddlware ([Middleware(50)]) builds an UnleashContext per request, populating UserId (from HttpContext.User.Identity.Name), AppName, CurrentTime, RemoteAddress, and (optionally) SessionId when session middleware is registered.

  • Microsoft.FeatureManagement integrationUnleashFeatureDefinitionProvider exposes all Unleash toggles as FeatureDefinition instances, and UnleashFilter ([FilterAlias("Unleash")]) evaluates them via the Unleash client, making IFeatureManager the single API for all feature checks.

  • Disabled feature handler — when a [FeatureGate]-protected endpoint is accessed but the flag is off, FeatureNotEnabledDisabledHandler raises a NotFoundDosaicException, resulting in a 404 response.

  • Health check — registers a readiness URL health check against {apiUri}/health under the name unleash.

  • OpenTelemetry metrics — emits four counters automatically:

    Metric
    Description

    dosaic_unleash_plugin_impressions_total

    Number of impression events (labelled by featureName, enabled)

    dosaic_unleash_plugin_errors_total

    Number of Unleash client error events

    dosaic_unleash_plugin_toggleUpdates_total

    Number of toggle cache refresh events

    dosaic_unleash_plugin_unleash_filter_calls_total

    Number of UnleashFilter evaluations (labelled by featureName, isEnabled)

  • Structured logging — impression events are logged at Debug, toggle updates at Information, and errors at Error level.

Last updated