Skip to content

Commit

Permalink
Add Enrich callback information to the documenation.
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierjohn committed Jun 5, 2024
1 parent b0e199a commit 67181df
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,27 @@ eg GET WeatherForecast/Action1

```

- Enrich SLI with `Enrich` callback. The callback receives a `MeasuredOperation` as context that can be used to set to `CustomerResourceId` or additional attributes.
An async version `EnrichAsync` is also available.

Example.

``` csharp

builder.Services.AddServiceLevelIndicator(options =>
{
options.LocationId = ServiceLevelIndicator.CreateLocationId(Cloud, Region);
})
.AddMvc()
.Enrich(context =>
{
var upn = context.HttpContext.User.Claims
.FirstOrDefault(c => c.Type == "upn")?.Value ?? "Unknown";
context.SetCustomerResourceId(upn);
});

```

- To override the default operation name add the attribute `[ServiceLevelIndicator]` and specify the operation name.

Example.
Expand Down

0 comments on commit 67181df

Please sign in to comment.