Some checks failed
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Concelier Attestation Tests / attestation-tests (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled
Findings Ledger CI / build-test (push) Has been cancelled
Findings Ledger CI / migration-validation (push) Has been cancelled
Findings Ledger CI / generate-manifest (push) Has been cancelled
mock-dev-release / package-mock-release (push) Has been cancelled
- Added ConsoleExportClient for managing export requests and responses. - Introduced ConsoleExportRequest and ConsoleExportResponse models. - Implemented methods for creating and retrieving exports with appropriate headers. feat(crypto): Add Software SM2/SM3 Cryptography Provider - Implemented SmSoftCryptoProvider for software-only SM2/SM3 cryptography. - Added support for signing and verification using SM2 algorithm. - Included hashing functionality with SM3 algorithm. - Configured options for loading keys from files and environment gate checks. test(crypto): Add unit tests for SmSoftCryptoProvider - Created comprehensive tests for signing, verifying, and hashing functionalities. - Ensured correct behavior for key management and error handling. feat(api): Enhance Console Export Models - Expanded ConsoleExport models to include detailed status and event types. - Added support for various export formats and notification options. test(time): Implement TimeAnchorPolicyService tests - Developed tests for TimeAnchorPolicyService to validate time anchors. - Covered scenarios for anchor validation, drift calculation, and policy enforcement.
181 lines
6.9 KiB
C#
181 lines
6.9 KiB
C#
using System.Diagnostics;
|
|
|
|
namespace StellaOps.Policy.Registry.Telemetry;
|
|
|
|
/// <summary>
|
|
/// Activity source for Policy Registry tracing.
|
|
/// Provides distributed tracing capabilities for all registry operations.
|
|
/// </summary>
|
|
public static class PolicyRegistryActivitySource
|
|
{
|
|
public const string SourceName = "StellaOps.Policy.Registry";
|
|
|
|
public static readonly ActivitySource ActivitySource = new(SourceName, "1.0.0");
|
|
|
|
// Pack operations
|
|
public static Activity? StartCreatePack(string tenantId, string packName)
|
|
{
|
|
var activity = ActivitySource.StartActivity("policy_registry.pack.create", ActivityKind.Internal);
|
|
activity?.SetTag("tenant_id", tenantId);
|
|
activity?.SetTag("pack_name", packName);
|
|
return activity;
|
|
}
|
|
|
|
public static Activity? StartGetPack(string tenantId, Guid packId)
|
|
{
|
|
var activity = ActivitySource.StartActivity("policy_registry.pack.get", ActivityKind.Internal);
|
|
activity?.SetTag("tenant_id", tenantId);
|
|
activity?.SetTag("pack_id", packId.ToString());
|
|
return activity;
|
|
}
|
|
|
|
public static Activity? StartUpdatePack(string tenantId, Guid packId)
|
|
{
|
|
var activity = ActivitySource.StartActivity("policy_registry.pack.update", ActivityKind.Internal);
|
|
activity?.SetTag("tenant_id", tenantId);
|
|
activity?.SetTag("pack_id", packId.ToString());
|
|
return activity;
|
|
}
|
|
|
|
public static Activity? StartDeletePack(string tenantId, Guid packId)
|
|
{
|
|
var activity = ActivitySource.StartActivity("policy_registry.pack.delete", ActivityKind.Internal);
|
|
activity?.SetTag("tenant_id", tenantId);
|
|
activity?.SetTag("pack_id", packId.ToString());
|
|
return activity;
|
|
}
|
|
|
|
// Compilation operations
|
|
public static Activity? StartCompile(string tenantId, Guid packId)
|
|
{
|
|
var activity = ActivitySource.StartActivity("policy_registry.compile", ActivityKind.Internal);
|
|
activity?.SetTag("tenant_id", tenantId);
|
|
activity?.SetTag("pack_id", packId.ToString());
|
|
return activity;
|
|
}
|
|
|
|
public static Activity? StartValidateRule(string tenantId, string ruleId)
|
|
{
|
|
var activity = ActivitySource.StartActivity("policy_registry.rule.validate", ActivityKind.Internal);
|
|
activity?.SetTag("tenant_id", tenantId);
|
|
activity?.SetTag("rule_id", ruleId);
|
|
return activity;
|
|
}
|
|
|
|
// Simulation operations
|
|
public static Activity? StartSimulation(string tenantId, Guid packId)
|
|
{
|
|
var activity = ActivitySource.StartActivity("policy_registry.simulate", ActivityKind.Internal);
|
|
activity?.SetTag("tenant_id", tenantId);
|
|
activity?.SetTag("pack_id", packId.ToString());
|
|
return activity;
|
|
}
|
|
|
|
public static Activity? StartBatchSimulation(string tenantId, Guid packId, int inputCount)
|
|
{
|
|
var activity = ActivitySource.StartActivity("policy_registry.batch_simulate", ActivityKind.Internal);
|
|
activity?.SetTag("tenant_id", tenantId);
|
|
activity?.SetTag("pack_id", packId.ToString());
|
|
activity?.SetTag("input_count", inputCount);
|
|
return activity;
|
|
}
|
|
|
|
// Review operations
|
|
public static Activity? StartSubmitReview(string tenantId, Guid packId)
|
|
{
|
|
var activity = ActivitySource.StartActivity("policy_registry.review.submit", ActivityKind.Internal);
|
|
activity?.SetTag("tenant_id", tenantId);
|
|
activity?.SetTag("pack_id", packId.ToString());
|
|
return activity;
|
|
}
|
|
|
|
public static Activity? StartApproveReview(string tenantId, string reviewId)
|
|
{
|
|
var activity = ActivitySource.StartActivity("policy_registry.review.approve", ActivityKind.Internal);
|
|
activity?.SetTag("tenant_id", tenantId);
|
|
activity?.SetTag("review_id", reviewId);
|
|
return activity;
|
|
}
|
|
|
|
public static Activity? StartRejectReview(string tenantId, string reviewId)
|
|
{
|
|
var activity = ActivitySource.StartActivity("policy_registry.review.reject", ActivityKind.Internal);
|
|
activity?.SetTag("tenant_id", tenantId);
|
|
activity?.SetTag("review_id", reviewId);
|
|
return activity;
|
|
}
|
|
|
|
// Publish operations
|
|
public static Activity? StartPublish(string tenantId, Guid packId)
|
|
{
|
|
var activity = ActivitySource.StartActivity("policy_registry.publish", ActivityKind.Internal);
|
|
activity?.SetTag("tenant_id", tenantId);
|
|
activity?.SetTag("pack_id", packId.ToString());
|
|
return activity;
|
|
}
|
|
|
|
public static Activity? StartRevoke(string tenantId, Guid packId)
|
|
{
|
|
var activity = ActivitySource.StartActivity("policy_registry.revoke", ActivityKind.Internal);
|
|
activity?.SetTag("tenant_id", tenantId);
|
|
activity?.SetTag("pack_id", packId.ToString());
|
|
return activity;
|
|
}
|
|
|
|
public static Activity? StartVerifyAttestation(string tenantId, Guid packId)
|
|
{
|
|
var activity = ActivitySource.StartActivity("policy_registry.attestation.verify", ActivityKind.Internal);
|
|
activity?.SetTag("tenant_id", tenantId);
|
|
activity?.SetTag("pack_id", packId.ToString());
|
|
return activity;
|
|
}
|
|
|
|
// Promotion operations
|
|
public static Activity? StartPromotion(string tenantId, Guid packId, string targetEnvironment)
|
|
{
|
|
var activity = ActivitySource.StartActivity("policy_registry.promote", ActivityKind.Internal);
|
|
activity?.SetTag("tenant_id", tenantId);
|
|
activity?.SetTag("pack_id", packId.ToString());
|
|
activity?.SetTag("target_environment", targetEnvironment);
|
|
return activity;
|
|
}
|
|
|
|
public static Activity? StartRollback(string tenantId, string environment)
|
|
{
|
|
var activity = ActivitySource.StartActivity("policy_registry.rollback", ActivityKind.Internal);
|
|
activity?.SetTag("tenant_id", tenantId);
|
|
activity?.SetTag("environment", environment);
|
|
return activity;
|
|
}
|
|
|
|
public static Activity? StartValidatePromotion(string tenantId, Guid packId, string targetEnvironment)
|
|
{
|
|
var activity = ActivitySource.StartActivity("policy_registry.promotion.validate", ActivityKind.Internal);
|
|
activity?.SetTag("tenant_id", tenantId);
|
|
activity?.SetTag("pack_id", packId.ToString());
|
|
activity?.SetTag("target_environment", targetEnvironment);
|
|
return activity;
|
|
}
|
|
|
|
// Helper methods
|
|
public static void SetError(this Activity? activity, Exception ex)
|
|
{
|
|
if (activity is null) return;
|
|
|
|
activity.SetStatus(ActivityStatusCode.Error, ex.Message);
|
|
activity.SetTag("error.type", ex.GetType().FullName);
|
|
activity.SetTag("error.message", ex.Message);
|
|
}
|
|
|
|
public static void SetSuccess(this Activity? activity)
|
|
{
|
|
activity?.SetStatus(ActivityStatusCode.Ok);
|
|
}
|
|
|
|
public static void SetResult(this Activity? activity, string key, object? value)
|
|
{
|
|
if (activity is null || value is null) return;
|
|
activity.SetTag($"result.{key}", value.ToString());
|
|
}
|
|
}
|