Crucible.Common.ServiceDefaults 0.0.2

dotnet add package Crucible.Common.ServiceDefaults --version 0.0.2
                    
NuGet\Install-Package Crucible.Common.ServiceDefaults -Version 0.0.2
                    
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="Crucible.Common.ServiceDefaults" Version="0.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Crucible.Common.ServiceDefaults" Version="0.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Crucible.Common.ServiceDefaults" />
                    
Project file
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 Crucible.Common.ServiceDefaults --version 0.0.2
                    
#r "nuget: Crucible.Common.ServiceDefaults, 0.0.2"
                    
#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 Crucible.Common.ServiceDefaults@0.0.2
                    
#: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=Crucible.Common.ServiceDefaults&version=0.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Crucible.Common.ServiceDefaults&version=0.0.2
                    
Install as a Cake Tool

Crucible.Common.ServiceDefaults

Default service configuration for Crucible API apps. Right now, this is mostly just configuration for OpenTelemetry, but may involve more stuff as we get going.

Quick start

var builder = Host.CreateApplicationBuilder(args);

builder.AddServiceDefaults(openTelemetryOptions =>
{
    openTelemetryOptions.AddConsoleExporter = builder.Environment.IsDevelopment();
    openTelemetryOptions.CustomActivitySources = ["Player.Api"];
});

For Startup-style apps, call services.AddServiceDefaults(env, Configuration); during service registration.

Required environment variables

  • OTEL_EXPORTER_OTLP_ENDPOINT Endpoint for the OTLP collector that receives logs, metrics, and traces. Use an http:// or https:// URL such as http://otel-collector:4317. If this is omitted the SDK still wires instrumentation, but nothing is sent to an external collector unless an optional exporter is enabled.

Optional environment variables

The OpenTelemetry SDK honors additional standard variables (for example OTEL_RESOURCE_ATTRIBUTES, OTEL_EXPORTER_OTLP_HEADERS, OTEL_EXPORTER_OTLP_TIMEOUT), although this library does not set defaults for them. Configure these when you need to pass authentication headers, tweak timeouts, or add extra resource attributes.

Optional library settings

Pass an Action<OpenTelemetryOptions> when calling AddServiceDefaults (or the specific AddOpenTelemetryServiceDefaults overloads) to customize:

  • AddAlwaysOnTracingSampler – force sampling of every trace span.
  • AddConsoleExporter – write telemetry to console for local debugging.
  • AddPrometheusExporter – surface metrics through the built-in Prometheus endpoint.
  • CustomActivitySources – register additional activity sources to trace.
  • CustomMeters – register additional meters to collect metrics from.
  • IncludeDefaultActivitySources – toggle the built-in sources (Microsoft.AspNetCore, Microsoft.EntityFrameworkCore, System.Net.Http).
  • IncludeDefaultMeters – toggle the default meters described below.

What is enabled by default

  • Structured logging with OTLP or console exporters.
  • Metrics from the .NET runtime, the hosting stack, ASP.NET Core, HttpClient, Entity Framework Core, and process CPU/memory usage.
  • Traces for ASP.NET Core, HttpClient, and Entity Framework Core operations.

Adjust the options or supply additional instrumentation packages to tailor telemetry for your service.

Default metrics and meters

The metrics pipeline wires several OpenTelemetry instrumentations:

When IncludeDefaultMeters remains true, the provider also subscribes to these built-in meters:

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.

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
0.0.2 2,338 1/27/2026
0.0.1 387 11/3/2025