cl.bmlabs.polpaico.observability 1.0.0

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

Observability (NuGet)

Paquete NuGet para ASP.NET Core 8 que centraliza el arranque de:

  • Elastic APM (AddAllElasticApm)
  • Serilog con sink opcional a Elasticsearch
  • Enriquecimiento de logs (service, event, correlación APM)
  • Formateador JSON plano para el sink

Identificadores

  • PackageId: cl.bmlabs.polpaico.observability
  • AssemblyName: cl.bmlabs.polpaico.observability (genera cl.bmlabs.polpaico.observability.dll)

Requisitos

  • .NET 8
  • Proyecto ASP.NET Core (Web SDK)

Dónde va cada cosa

En este paquete

  • Código de arranque y enriquecimiento (ObservabilityBootstrap)

En la API consumidora

  • Valores no secretos (por ejemplo ElasticApm:Activo, ElasticApm:ServiceName, niveles de Serilog) en appsettings.json / appsettings.Development.json

Fuera del repositorio (recomendado)

  • Secretos y URLs sensibles (SecretToken, ApiKey, etc.) en variables de entorno del host, User Secrets, Key Vault o el pipeline CI/CD

El paquete no incluye credenciales: solo lee IConfiguration de la aplicación anfitriona.

Uso en Program.cs

using Cl.Bmlabs.Polpaico.Observability;

var builder = WebApplication.CreateBuilder(args);
ObservabilityBootstrap.Configure(builder);

// ... resto de servicios

var app = builder.Build();
app.UseSerilogRequestLogging();

Configuración esperada

Elastic APM

Si ElasticApm:Activo es exactamente true (sin distinguir mayúsculas/minúsculas), se habilita APM.

Campos típicos (según tu configuración):

  • ElasticApm:ServiceName (obligatorio cuando APM está activo)
  • ElasticApm:Environment (obligatorio cuando APM está activo)
  • ElasticApm:ServerUrl, ElasticApm:SecretToken, etc.

Logs hacia Elasticsearch (opcional)

  • ElasticLog:Host y ElasticLog:ApiKey

Si Host está vacío: APM + consola.

Si Host tiene valor: ApiKey es obligatoria.

Serilog (opcional)

Puedes definir la sección Serilog en la API para niveles mínimos y overrides.

Variables de entorno (ejemplo)

WebApplication.CreateBuilder ya combina JSON y variables de entorno. Las claves anidadas usan __.

ElasticApm__Activo=true
ElasticApm__ServiceName=mi-api
ElasticApm__Environment=Production
ElasticApm__ServerUrl=https://your-deployment.apm.cloud.es.io:443
ElasticApm__SecretToken=...
ElasticLog__Host=https://your-deployment.es.cloud.es.io:443
ElasticLog__ApiKey=...

Instalación en una API

dotnet add package cl.bmlabs.polpaico.observability

Las dependencias de Elastic y Serilog llegan por referencias transitivas del paquete.

Empaquetar y publicar

dotnet pack src/Observability/Observability.csproj -c Release -o ./artifacts
dotnet nuget push ./artifacts/cl.bmlabs.polpaico.observability.*.nupkg --api-key YOUR_NUGET_ORG_API_KEY --source https://api.nuget.org/v3/index.json

Antes de publicar, verifica en nuget.org que el PackageId no esté tomado. Si ya existe, cambia la versión y/o el id en el .csproj.

Product 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.

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
1.0.0 307 4/22/2026