feat: ship agent-first mission control v0.2.57
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.Metrics;
|
||||
|
||||
namespace Nexus.Api.Observability;
|
||||
|
||||
/// <summary>
|
||||
/// Low-cardinality diagnostics for the Nexus control plane. Content, prompts,
|
||||
/// tool arguments, entity names, credentials and caller-provided identifiers
|
||||
/// must never be recorded here.
|
||||
/// </summary>
|
||||
public static class NexusTelemetry
|
||||
{
|
||||
public const string SourceName = "Nexus.Api";
|
||||
public static readonly ActivitySource ActivitySource = new(SourceName);
|
||||
public static readonly Meter Meter = new(SourceName);
|
||||
|
||||
public static readonly Histogram<double> BrowserDuration =
|
||||
Meter.CreateHistogram<double>("nexus.browser.duration", unit: "ms");
|
||||
public static readonly Histogram<double> BrowserScore =
|
||||
Meter.CreateHistogram<double>("nexus.browser.score", unit: "1");
|
||||
public static readonly Histogram<double> TaskBoardDuration =
|
||||
Meter.CreateHistogram<double>("nexus.task.board.duration", unit: "ms");
|
||||
public static readonly Histogram<long> TaskBoardPayload =
|
||||
Meter.CreateHistogram<long>("nexus.task.board.payload", unit: "By");
|
||||
public static readonly Counter<long> SseResyncs =
|
||||
Meter.CreateCounter<long>("nexus.sse.resyncs");
|
||||
public static readonly UpDownCounter<long> SseSubscribers =
|
||||
Meter.CreateUpDownCounter<long>("nexus.sse.subscribers");
|
||||
public static readonly Histogram<double> GatewayRpcDuration =
|
||||
Meter.CreateHistogram<double>("nexus.gateway.rpc.duration", unit: "ms");
|
||||
public static readonly UpDownCounter<long> OutboxBacklog =
|
||||
Meter.CreateUpDownCounter<long>("nexus.outbox.backlog");
|
||||
public static readonly Counter<long> OutboxPublished =
|
||||
Meter.CreateCounter<long>("nexus.outbox.published");
|
||||
public static readonly Histogram<double> AgentProvisionDuration =
|
||||
Meter.CreateHistogram<double>("nexus.agent.provision.duration", unit: "ms");
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Diagnostics;
|
||||
using OpenTelemetry;
|
||||
|
||||
namespace Nexus.Api.Observability;
|
||||
|
||||
/// <summary>
|
||||
/// Removes content-bearing attributes before an activity reaches an exporter.
|
||||
/// Standard HTTP exception recording is disabled separately so exception
|
||||
/// events cannot contain messages or stack traces.
|
||||
/// </summary>
|
||||
public sealed class NexusTelemetryRedactionProcessor : BaseProcessor<Activity>
|
||||
{
|
||||
private static readonly HashSet<string> RedactedTagNames = new(
|
||||
[
|
||||
"url.query",
|
||||
"url.full",
|
||||
"url.path",
|
||||
"http.url",
|
||||
"http.target",
|
||||
"exception.message",
|
||||
"exception.stacktrace",
|
||||
"db.statement",
|
||||
"db.query.text"
|
||||
],
|
||||
StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public override void OnEnd(Activity activity)
|
||||
{
|
||||
foreach (var tag in activity.TagObjects.ToArray())
|
||||
{
|
||||
if (RedactedTagNames.Contains(tag.Key))
|
||||
activity.SetTag(tag.Key, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user