generated from arcus-azure/arcus.github.template
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature - move correlation access information to observability (#43)
* Feature - move correlation access information to observability * pr-sug: update correlation info enricher with accessor directly * pr-fix: update with correct target framework package references * temp commit * pr-sug: update with custom correlation info model * pr-sug: use custom correlation info to the enricher * pr-sug: use get/set property io throwing for test correlation info * pr-sug: more info about custom correlation accessing * pr-sug: update w/ merging master and docs * pr-sug: use custom enricher for custom correlation enrichment * Update docs/features/correlation.md Co-Authored-By: Tom Kerkhove <[email protected]> * pr-fix: use netcoreapp2.2 package references * pr-docs: update with PR comments * pr-sug: use updated correlation info enricher * pr-sug: use custom options to configure custom correlation info * pr-sug: use 'new' member modifier for hiding inherited default accessor * pr-sug: add xml docs for internal proxy implementation * pr-sug: use protected correlation info enricher * pr-fix: use 3.0.0 packages * pr-sug: use methods to get/set correlation info * pr-fix: update with correlation get/set as methods * Update telemetry-enrichment.md * pr-sug: update with more extensible correlation enrichment * pr-docs: update with custom correlation info options * pr-fix: use correct overriding * pr-docs: remove default instance value * pr-style: place generic restrictions on diff line Co-authored-by: Tom Kerkhove <[email protected]>
- Loading branch information
1 parent
84882f1
commit 77489ae
Showing
24 changed files
with
1,205 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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 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 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
44 changes: 44 additions & 0 deletions
44
src/Arcus.Observability.Correlation/CorrelationInfoAccessorProxy.cs
This file contains 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,44 @@ | ||
using GuardNet; | ||
|
||
namespace Arcus.Observability.Correlation | ||
{ | ||
/// <summary> | ||
/// Internal proxy implementation to register an <see cref="ICorrelationInfoAccessor{TCorrelationInfo}"/> as an <see cref="ICorrelationInfoAccessor"/>. | ||
/// </summary> | ||
/// <typeparam name="TCorrelationInfo">The custom <see cref="Correlation.CorrelationInfo"/> model.</typeparam> | ||
internal class CorrelationInfoAccessorProxy<TCorrelationInfo> : ICorrelationInfoAccessor | ||
where TCorrelationInfo : CorrelationInfo | ||
{ | ||
private readonly ICorrelationInfoAccessor<TCorrelationInfo> _correlationInfoAccessor; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="CorrelationInfoAccessorProxy{TCorrelationInfo}"/> class. | ||
/// </summary> | ||
internal CorrelationInfoAccessorProxy(ICorrelationInfoAccessor<TCorrelationInfo> correlationInfoAccessor) | ||
{ | ||
Guard.NotNull(correlationInfoAccessor, nameof(correlationInfoAccessor)); | ||
|
||
_correlationInfoAccessor = correlationInfoAccessor; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the current correlation information initialized in this context. | ||
/// </summary> | ||
public CorrelationInfo GetCorrelationInfo() | ||
{ | ||
return _correlationInfoAccessor.GetCorrelationInfo(); | ||
} | ||
|
||
/// <summary> | ||
/// Sets the current correlation information for this context. | ||
/// </summary> | ||
/// <param name="correlationInfo">The correlation model to set.</param> | ||
public void SetCorrelationInfo(CorrelationInfo correlationInfo) | ||
{ | ||
if (correlationInfo is TCorrelationInfo typedCorrelationInfo) | ||
{ | ||
_correlationInfoAccessor.SetCorrelationInfo(typedCorrelationInfo); | ||
} | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/Arcus.Observability.Correlation/CorrelationInfoOperationOptions.cs
This file contains 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,48 @@ | ||
using System; | ||
using GuardNet; | ||
|
||
namespace Arcus.Observability.Correlation | ||
{ | ||
/// <summary> | ||
/// Correlation options specific for the operation ID. | ||
/// </summary> | ||
public class CorrelationInfoOperationOptions | ||
{ | ||
private string _headerName = "RequestId"; | ||
private Func<string> _generateId = () => Guid.NewGuid().ToString(); | ||
|
||
/// <summary> | ||
/// Gets or sets whether to include the operation ID in the response. | ||
/// </summary> | ||
/// <remarks> | ||
/// A common use case is to disable tracing info in edge services, so that such details are not exposed to the outside world. | ||
/// </remarks> | ||
public bool IncludeInResponse { get; set; } = true; | ||
|
||
/// <summary> | ||
/// Gets or sets the header that will contain the response operation ID. | ||
/// </summary> | ||
public string HeaderName | ||
{ | ||
get => _headerName; | ||
set | ||
{ | ||
Guard.NotNullOrWhitespace(value, nameof(value), "Correlation operation header cannot be blank"); | ||
_headerName = value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the function to generate the operation ID when the <see cref="IncludeInResponse"/> is set to <c>true</c> (default: <c>true</c>). | ||
/// </summary> | ||
public Func<string> GenerateId | ||
{ | ||
get => _generateId; | ||
set | ||
{ | ||
Guard.NotNull(value, nameof(value), "Correlation function to generate an operation ID cannot be 'null'"); | ||
_generateId = value; | ||
} | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/Arcus.Observability.Correlation/CorrelationInfoOptions.cs
This file contains 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,18 @@ | ||
namespace Arcus.Observability.Correlation | ||
{ | ||
/// <summary> | ||
/// Options for handling correlation id on incoming requests. | ||
/// </summary> | ||
public class CorrelationInfoOptions | ||
{ | ||
/// <summary> | ||
/// Gets the correlation options specific for the transaction ID. | ||
/// </summary> | ||
public CorrelationInfoTransactionOptions Transaction { get; } = new CorrelationInfoTransactionOptions(); | ||
|
||
/// <summary> | ||
/// Gets the correlation options specific for the operation ID. | ||
/// </summary> | ||
public CorrelationInfoOperationOptions Operation { get; } = new CorrelationInfoOperationOptions(); | ||
} | ||
} |
Oops, something went wrong.