Skip to main content

arolariu.Backend.Domain.Invoices

arolariu.Backend.Domain.Invoices

arolariu.Backend.Domain.Invoices Namespace

Classes

InvoiceMetrics Class

Defines custom OTel metric instruments for the Invoices bounded context using the RED method (Rate, Errors, Duration) to enable SLA/QoS computation.

public static class InvoiceMetrics

Inheritance System.Object 🡒 InvoiceMetrics

Remarks

All instruments use outcome-tagged dimensions so SLI can be computed as: success_rate = sum(counter{outcome=success}) / sum(counter{outcome=*})

Instrument naming follows OTel semantic conventions:

  • invoices.operations — Invoice/merchant CRUD rate with outcome + operation tags
  • invoices.operations.duration — CRUD latency distribution
  • invoices.analysis — AI analysis rate with outcome tag
  • invoices.analysis.duration — Analysis latency distribution
  • invoices.analysis.content_filter.triggered — AI content filter events
  • invoices.cosmosdb.request_charge — Cosmos DB RU cost distribution

Fields

InvoiceMetrics.Analyses Field

Counts invoice analysis operations with outcome dimension. Tags: outcome (success, failure), optionally failure.reason.

public static readonly Counter<long> Analyses;

Field Value

System.Diagnostics.Metrics.Counter<System.Int64>

InvoiceMetrics.AnalysisDuration Field

Duration of invoice analysis operations in milliseconds. Tags: outcome.

public static readonly Histogram<double> AnalysisDuration;

Field Value

System.Diagnostics.Metrics.Histogram<System.Double>

InvoiceMetrics.ContentFilterTriggered Field

Total number of AI content filter triggers during analysis.

public static readonly Counter<long> ContentFilterTriggered;

Field Value

System.Diagnostics.Metrics.Counter<System.Int64>

InvoiceMetrics.CosmosDbRequestCharge Field

Distribution of Cosmos DB request unit (RU) consumption per operation. Tags: db.operation, db.cosmosdb.container.

public static readonly Histogram<double> CosmosDbRequestCharge;

Field Value

System.Diagnostics.Metrics.Histogram<System.Double>

InvoiceMetrics.OperationDuration Field

Duration of invoice and merchant operations in milliseconds. Tags: operation (create, read, update, delete, soft_delete, analyze), entity (invoice, merchant), outcome (success, failure), optionally failure.reason.

public static readonly Histogram<double> OperationDuration;

Field Value

System.Diagnostics.Metrics.Histogram<System.Double>

InvoiceMetrics.Operations Field

Counts invoice and merchant operations with outcome and operation-type dimensions. Tags: operation (create, read, update, delete, soft_delete, analyze), entity (invoice, merchant), outcome (success, failure), optionally failure.reason.

public static readonly Counter<long> Operations;

Field Value

System.Diagnostics.Metrics.Counter<System.Int64>

Methods

InvoiceMetrics.RecordAnalysis(string, double, string) Method

Records a completed analysis with outcome and duration.

public static void RecordAnalysis(string outcome, double durationMs, string? failureReason=null);

Parameters

outcome System.String

The outcome (success, failure).

durationMs System.Double

Duration in milliseconds.

failureReason System.String

Optional failure reason (validation, dependency, service).

InvoiceMetrics.RecordCosmosDbCharge(double, string, string) Method

Records a Cosmos DB request charge with standard dimensional tags.

public static void RecordCosmosDbCharge(double requestCharge, string operation, string container);

Parameters

requestCharge System.Double

operation System.String

container System.String

InvoiceMetrics.RecordOperation(string, string, string, Nullable<double>, string) Method

Records a completed operation with outcome and optional duration.

public static void RecordOperation(string operation, string entity, string outcome, System.Nullable<double> durationMs=null, string? failureReason=null);

Parameters

operation System.String

The operation type (create, read, update, delete, soft_delete, analyze).

entity System.String

The entity type (invoice, merchant).

outcome System.String

The outcome (success, failure).

durationMs System.Nullable<System.Double>

Optional duration in milliseconds. When provided, also records a histogram observation.

failureReason System.String

Optional failure reason tag (validation, dependency, service).

Log Class

Auto-generated class for logging different events in the invoice domain.

public static class Log

Inheritance System.Object 🡒 Log

Methods

Log.LogAllergenHallucinationSkipped(this ILogger, string) Method

Logs when a hallucinated allergen text is skipped during parsing.

public static void LogAllergenHallucinationSkipped(this Microsoft.Extensions.Logging.ILogger logger, string allergenName);

Parameters

logger Microsoft.Extensions.Logging.ILogger

allergenName System.String

Log.LogAllergenUnrecognizedSkipped(this ILogger, string, string) Method

Logs when an unrecognized allergen is skipped (not in EU 14 whitelist).

public static void LogAllergenUnrecognizedSkipped(this Microsoft.Extensions.Logging.ILogger logger, string allergenName, string productName);

Parameters

logger Microsoft.Extensions.Logging.ILogger

allergenName System.String

productName System.String

Log.LogContentFilterTriggered(this ILogger, string) Method

Logs when Azure OpenAI content filter triggers.

public static void LogContentFilterTriggered(this Microsoft.Extensions.Logging.ILogger logger, string methodName);

Parameters

logger Microsoft.Extensions.Logging.ILogger

methodName System.String

Log.LogContentFilterTriggeredWithContext(this ILogger, string, string) Method

Logs when Azure OpenAI content filter triggers with context.

public static void LogContentFilterTriggeredWithContext(this Microsoft.Extensions.Logging.ILogger logger, string methodName, string context);

Parameters

logger Microsoft.Extensions.Logging.ILogger

methodName System.String

context System.String

Log.LogGptAnalysisStarted(this ILogger, string) Method

Logs the start of GPT analysis workflow.

public static void LogGptAnalysisStarted(this Microsoft.Extensions.Logging.ILogger logger, string modelName);

Parameters

logger Microsoft.Extensions.Logging.ILogger

modelName System.String

Log.LogGptMethodFailed(this ILogger, string, string) Method

Logs when a GPT method fails with an exception.

public static void LogGptMethodFailed(this Microsoft.Extensions.Logging.ILogger logger, string methodName, string errorMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

methodName System.String

errorMessage System.String

Log.LogGptMethodFailedWithContext(this ILogger, string, string, string) Method

Logs when a GPT method fails with context-specific information.

public static void LogGptMethodFailedWithContext(this Microsoft.Extensions.Logging.ILogger logger, string methodName, string context, string errorMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

methodName System.String

context System.String

errorMessage System.String

Log.LogInvoiceAnalysisDependencyException(this ILogger, string) Method

Auto-generated method for logging the invoice analysis dependency exception.

public static void LogInvoiceAnalysisDependencyException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogInvoiceAnalysisDependencyValidationException(this ILogger, string) Method

Auto-generated method for logging the invoice analysis dependency validation exception.

public static void LogInvoiceAnalysisDependencyValidationException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogInvoiceAnalysisNoAnalysisHasBeenPerformed(this ILogger, Guid) Method

Auto-generated method for logging that no analysis has been performed on the invoice.

public static void LogInvoiceAnalysisNoAnalysisHasBeenPerformed(this Microsoft.Extensions.Logging.ILogger logger, System.Guid invoiceId);

Parameters

logger Microsoft.Extensions.Logging.ILogger

invoiceId System.Guid

Log.LogInvoiceAnalysisServiceException(this ILogger, string) Method

Auto-generated method for logging the invoice analysis service exception.

public static void LogInvoiceAnalysisServiceException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogInvoiceAnalysisValidationException(this ILogger, string) Method

Auto-generated method for logging the invoice analysis validation exception.

public static void LogInvoiceAnalysisValidationException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogInvoiceOrchestrationDependencyException(this ILogger, string) Method

Auto-generated method for logging the invoice orchestration dependency exception.

public static void LogInvoiceOrchestrationDependencyException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogInvoiceOrchestrationDependencyValidationException(this ILogger, string) Method

Auto-generated method for logging the invoice orchestration dependency validation exception.

public static void LogInvoiceOrchestrationDependencyValidationException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogInvoiceOrchestrationServiceException(this ILogger, string) Method

Auto-generated method for logging the invoice orchestration service exception.

public static void LogInvoiceOrchestrationServiceException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogInvoiceOrchestrationValidationException(this ILogger, string) Method

Auto-generated method for logging the invoice orchestration validation exception.

public static void LogInvoiceOrchestrationValidationException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogInvoiceProcessingDependencyException(this ILogger, string) Method

Auto-generated method for logging the invoice processing dependency exception.

public static void LogInvoiceProcessingDependencyException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogInvoiceProcessingDependencyValidationException(this ILogger, string) Method

Auto-generated method for logging the invoice processing dependency validation exception.

public static void LogInvoiceProcessingDependencyValidationException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogInvoiceProcessingServiceException(this ILogger, string) Method

Auto-generated method for logging the invoice processing service exception.

public static void LogInvoiceProcessingServiceException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogInvoiceProcessingValidationException(this ILogger, string) Method

Auto-generated method for logging the invoice processing validation exception.

public static void LogInvoiceProcessingValidationException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogInvoiceStorageDependencyException(this ILogger, string) Method

Auto-generated method for logging the invoice storage dependency exception.

public static void LogInvoiceStorageDependencyException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogInvoiceStorageDependencyValidationException(this ILogger, string) Method

Auto-generated method for logging the invoice storage dependency validation exception.

public static void LogInvoiceStorageDependencyValidationException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogInvoiceStorageServiceException(this ILogger, string) Method

Auto-generated method for logging the invoice storage service exception.

public static void LogInvoiceStorageServiceException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogInvoiceStorageValidationException(this ILogger, string) Method

Auto-generated method for logging the invoice storage validation exception.

public static void LogInvoiceStorageValidationException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogMerchantOrchestrationDependencyException(this ILogger, string) Method

Auto-generated method for logging the merchant orchestration dependency exception.

public static void LogMerchantOrchestrationDependencyException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogMerchantOrchestrationDependencyValidationException(this ILogger, string) Method

Auto-generated method for logging the merchant orchestration dependency validation exception.

public static void LogMerchantOrchestrationDependencyValidationException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogMerchantOrchestrationServiceException(this ILogger, string) Method

Auto-generated method for logging the merchant orchestration service exception.

public static void LogMerchantOrchestrationServiceException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogMerchantOrchestrationValidationException(this ILogger, string) Method

Auto-generated method for logging the merchant orchestration validation exception.

public static void LogMerchantOrchestrationValidationException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogMerchantStorageServiceDependencyException(this ILogger, string) Method

Auto-generated method for logging the merchant storage dependency exception.

public static void LogMerchantStorageServiceDependencyException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogMerchantStorageServiceDependencyValidationException(this ILogger, string) Method

Auto-generated method for logging the merchant storage dependency validation exception.

public static void LogMerchantStorageServiceDependencyValidationException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogMerchantStorageServiceException(this ILogger, string) Method

Auto-generated method for logging the merchant storage service exception.

public static void LogMerchantStorageServiceException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogMerchantStorageServiceValidationException(this ILogger, string) Method

Auto-generated method for logging the merchant storage validation exception.

public static void LogMerchantStorageServiceValidationException(this Microsoft.Extensions.Logging.ILogger logger, string exceptionMessage);

Parameters

logger Microsoft.Extensions.Logging.ILogger

exceptionMessage System.String

Log.LogUserIdentifierNotSetWarning(this ILogger) Method

Auto-generated method for logging the user identifier not set warning.

public static void LogUserIdentifierNotSetWarning(this Microsoft.Extensions.Logging.ILogger logger);

Parameters

logger Microsoft.Extensions.Logging.ILogger

// was this page useful?