EZ.Redact.Lgpd.OpenTelemetry
2.1.0
dotnet add package EZ.Redact.Lgpd.OpenTelemetry --version 2.1.0
NuGet\Install-Package EZ.Redact.Lgpd.OpenTelemetry -Version 2.1.0
<PackageReference Include="EZ.Redact.Lgpd.OpenTelemetry" Version="2.1.0" />
<PackageVersion Include="EZ.Redact.Lgpd.OpenTelemetry" Version="2.1.0" />
<PackageReference Include="EZ.Redact.Lgpd.OpenTelemetry" />
paket add EZ.Redact.Lgpd.OpenTelemetry --version 2.1.0
#r "nuget: EZ.Redact.Lgpd.OpenTelemetry, 2.1.0"
#:package EZ.Redact.Lgpd.OpenTelemetry@2.1.0
#addin nuget:?package=EZ.Redact.Lgpd.OpenTelemetry&version=2.1.0
#tool nuget:?package=EZ.Redact.Lgpd.OpenTelemetry&version=2.1.0
EZ.Redact.Lgpd.OpenTelemetry
EZ.Redact.Lgpd.OpenTelemetry é uma extensão do ecossistema EZ.Redact.Lgpd que aplica redação de dados sensíveis (LGPD) em traces do OpenTelemetry. Ela redige tags e baggage de spans automaticamente antes da exportação, além de fornecer uma API fluente para criar eventos com dados mascarados.
Instalação
dotnet add package EZ.Redact.Lgpd.OpenTelemetry
Registre os serviços no DI com AddLGPDRedaction() e configure a redação OpenTelemetry:
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddLGPDRedaction();
builder.Logging.EnableRedaction(options => options.ApplyDiscriminator = false);
Exemplo rápido
using EZ.Redact.Lgpd.OpenTelemetry;
using EZ.Redact.Lgpd.OpenTelemetry.Processors;
using OpenTelemetry.Trace;
builder.Services.AddLGPDRedaction()
.AddOpenTelemetryRedaction(options =>
{
options.RedactTags("user.cpf", "user.email", "customer.document");
options.RedactBaggage("user.cpf", "user.email");
});
builder.Services.AddOpenTelemetry()
.WithTracing(tracing => tracing
.AddAspNetCoreInstrumentation()
.AddProcessor(sp => sp.GetRequiredService<LgpdRedactionProcessor>()));
Tags e baggage cujos nomes estiverem na blacklist são redigidos automaticamente ao final do span:
| Entrada | Resultado |
|---|---|
123.456.789-00 |
123*******00 |
joao.silva@example.com |
joa***********com |
Eventos redigidos
Crie eventos com dados sensíveis usando a API fluente:
activity.CreateRedactedEvent(
"Cliente {cpf} realizou saque de {valor} na conta {conta}",
redactService)
.WithRedacted("cpf", DadoPessoal.CPF, "123.456.789-00")
.WithRaw("valor", "R$ 1.500,00")
.WithRedacted("conta", DadoPessoal.ContaBancaria, "12345-6")
.Add();
Saída do evento redigido:
Cliente ***.***.***-** realizou saque de R$ 1.500,00 na conta *****-*
API do builder
| Método | Descrição |
|---|---|
WithRedacted(key, tipo, value) |
Redige o valor usando ILGPDRedactService antes de armazenar |
WithRaw(key, value) |
Armazena o valor sem alteração |
Add() |
Substitui os placeholders {key} no template e chama activity.AddEvent() |
Configuração
LgpdOpenTelemetryOptions
| Método | Descrição |
|---|---|
RedactTags(params string[] tags) |
Adiciona nomes de tags que devem ser redigidas ao final do span |
RedactBaggage(params string[] keys) |
Adiciona nomes de baggage que devem ser redigidas ao final do span |
builder.Services.AddLGPDRedaction()
.AddOpenTelemetryRedaction(options =>
{
options.RedactTags("user.cpf", "user.email", "user.nome", "customer.document");
options.RedactBaggage("user.cpf", "user.email");
});
Comportamento
LgpdRedactionProcessor
O LgpdRedactionProcessor implementa BaseProcessor<Activity> do OpenTelemetry e:
- No método
OnEndintercepta cada span antes da exportação - Verifica se a redação está habilitada — respeita o controle configurado no Core (via
ILGPDRedactService) - Para cada tag cujo nome estiver na blacklist, substitui o valor pela redação genérica
- Para cada baggage cujo nome estiver na blacklist, substitui o valor pela redação genérica
Redação genérica
Preserva 3 caracteres no início e 3 no final do valor, substituindo o meio por asteriscos:
"123.456.789-00" → "123*******00"
"joao@example.com" → "joa*******com"
"curto" → "curto" (inalterado — < 6 caracteres)
Projetos Relacionados
| Projeto | Descrição |
|---|---|
| EZ.Redact.Lgpd.Core | Biblioteca central de redação de dados sensíveis LGPD |
| EZ.Redact.Lgpd.EntityFramework | Redação em consultas Entity Framework |
| EZ.Redact.Lgpd.Json | Redação em serialização JSON |
| EZ.Redact.Lgpd.MongoDb | Redação em consultas MongoDB |
| EZ.Redact.Lgpd.Xml | Redação em serialização XML |
Licença
Distribuído sob a licença MIT.
| 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 is compatible. 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 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. |
-
net10.0
- EZ.Redact.Lgpd.Core (>= 2.1.0)
- OpenTelemetry (>= 1.15.3)
-
net8.0
- EZ.Redact.Lgpd.Core (>= 2.1.0)
- OpenTelemetry (>= 1.15.3)
-
net9.0
- EZ.Redact.Lgpd.Core (>= 2.1.0)
- OpenTelemetry (>= 1.15.3)
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 |
|---|---|---|
| 2.1.0 | 134 | 5/29/2026 |