DotNetBuildingBlocks.Observation
1.0.1
The owner has unlisted this package.
This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package DotNetBuildingBlocks.Observation --version 1.0.1
NuGet\Install-Package DotNetBuildingBlocks.Observation -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DotNetBuildingBlocks.Observation" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DotNetBuildingBlocks.Observation" Version="1.0.1" />
<PackageReference Include="DotNetBuildingBlocks.Observation" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DotNetBuildingBlocks.Observation --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DotNetBuildingBlocks.Observation, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DotNetBuildingBlocks.Observation@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DotNetBuildingBlocks.Observation&version=1.0.1
#tool nuget:?package=DotNetBuildingBlocks.Observation&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DotNetBuildingBlocks.Observation
DotNetBuildingBlocks.Observation is a thin composition package for the diagnostics building blocks.
It gives you one clean registration point for:
- logging
- tracing
- metrics
This package does not replace the lower-level packages. It sits above them and helps you apply shared service identity and consistent naming.
What this package provides
AddDotNetBuildingBlocksObservation(...)- shared
ObservationOptions - shared service identity mapping
- consistent defaults for tracing and metrics names
- optional enable/disable flags for logging, tracing, and metrics
What this package does not provide
This package intentionally does not configure:
- OpenTelemetry SDK
- OTLP / Jaeger / Zipkin / Prometheus exporters
- Serilog
- ASP.NET Core middleware
- dashboards
- sinks
- vendor-specific integrations
Installation
dotnet add package DotNetBuildingBlocks.Observation
Basic usage
using DotNetBuildingBlocks.Observation.DependencyInjection;
var services = new ServiceCollection();
services.AddDotNetBuildingBlocksObservation(options =>
{
options.ServiceName = "Samples.OrderProcessor";
options.ServiceVersion = "1.0.0";
});
Shared naming behavior
services.AddDotNetBuildingBlocksObservation(options =>
{
options.ServiceName = "Orders.Service";
});
Defaults:
ActivitySourceName = ServiceNameMeterName = ServiceName
Override when needed:
services.AddDotNetBuildingBlocksObservation(options =>
{
options.ServiceName = "Orders.Service";
options.ActivitySourceName = "Orders.Tracing";
options.MeterName = "Orders.Metrics";
});
Selective registration
services.AddDotNetBuildingBlocksObservation(options =>
{
options.ServiceName = "Orders.Service";
options.ConfigureLogging = true;
options.ConfigureTracing = true;
options.ConfigureMetrics = false;
});
Example with lower-level packages
public sealed class OrderProcessor
{
private readonly ILogger<OrderProcessor> _logger;
private readonly IActivitySourceAccessor _activitySourceAccessor;
private readonly IMeterAccessor _meterAccessor;
private readonly Counter<long> _requests;
private readonly Histogram<double> _duration;
public OrderProcessor(
ILogger<OrderProcessor> logger,
IActivitySourceAccessor activitySourceAccessor,
IMeterAccessor meterAccessor)
{
_logger = logger;
_activitySourceAccessor = activitySourceAccessor;
_meterAccessor = meterAccessor;
_requests = _meterAccessor.CreateCounter<long>("orders.processed");
_duration = _meterAccessor.CreateHistogram<double>("orders.duration", unit: "ms");
}
public async Task ProcessAsync(Guid orderId, CancellationToken cancellationToken = default)
{
using var scope = _logger.BeginScope(new Dictionary<string, object?>
{
["OperationName"] = "ProcessOrder",
["OrderId"] = orderId
});
using var activity = _activitySourceAccessor.StartInternalActivity("ProcessOrder");
var startedAt = Stopwatch.GetTimestamp();
_requests.Add(1);
try
{
await Task.Delay(50, cancellationToken);
_duration.Record(Stopwatch.GetElapsedTime(startedAt).TotalMilliseconds);
}
catch
{
_duration.Record(Stopwatch.GetElapsedTime(startedAt).TotalMilliseconds);
throw;
}
}
}
When to use this package
Use this package when you want:
- one diagnostics registration entry point
- shared service identity across diagnostics packages
- a simpler onboarding experience for new services
- consistent diagnostics naming across your applications
Use the lower-level packages directly when you need more control over one specific area.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- DotNetBuildingBlocks.Logging (>= 1.0.0)
- DotNetBuildingBlocks.Metrics (>= 1.0.0)
- DotNetBuildingBlocks.Tracing (>= 1.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Options (>= 10.0.5)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|