Skip to main content

Observability

The CloudSolutions modules publish OpenTelemetry traces and metrics for their own work that runs for a long time. With them you can see what runs, how long it takes, how often it fails and what is late.

The host collects the telemetry and exports it over OTLP. See the OpenTelemetry section of the CloudSolutions.Web README for the endpoint and the other settings. Nothing is recorded, and almost nothing is spent, when no listener is attached.

What the modules measure​

The modules measure only their own operations: a background task, a job after a request, a deferred task, a retry loop, a transcript task, an ingestion run, a Tableau export run, a simulator turn. They do not measure what another component already reports:

OperationReported by
An HTTP call to another systemThe HttpClient spans and http.client.request.duration, which Orchard Core collects
The duration of a background task runorchardcore.background_task.duration and the Run background task span of Orchard Core
An ASP.NET Core request, a recipe, a tenant activationOrchard Core and ASP.NET Core
A database commandYesSql and the database driver, when their names are in the settings
An AI callCrestApps.Core (crestapps.core.*) and the AI clients (AICompletionService)

To collect one more library, such as an SDK or Polly, add its name to OrchardCore:OpenTelemetry:Tracing:Sources or OrchardCore:OpenTelemetry:Metrics:Meters. Do not add an instrument for it in a module.

Names​

ItemRuleExample
Meter and activity sourceCloudSolutions.<Area>CloudSolutions.Speech
Instrumentcloudsolutions.<area>.<thing>, with a UCUM unitcloudsolutions.speech.transcript_task.duration (s)
Spancloudsolutions.<area>.<operation>cloudsolutions.speech.transcript_task.process

The instruments of the background tasks, the jobs after a request, the deferred tasks and the retries come from the CrestApps.OrchardCore helpers. They are on the CrestApps.OrchardCore.Platform meter and their names start with crestapps., so one dashboard shows the CrestApps modules and the CloudSolutions modules together.

The host listens to CloudSolutions.* and CrestApps.*, so a new area needs no host change.

Shared tags​

The tag names and the outcome values are the constants of CrestAppsOrchardCoreTelemetry (CrestApps.OrchardCore).

TagValues
outcomeok, error, skipped, cancelled, timeout, unknown, and the values an instrument lists
error.typeThe full name of the exception type. Only with outcome=error.
resultWhat became of one item, for example processed or failed
reasonWhy an operation ended as it did, from a fixed list
taskThe class name of a background task, or the name of a job or a deferred task
areaThe retry loop, from a fixed list
orchardcore.tenant.nameThe tenant name. See Tenant tag.

Tag rules​

A metric tag must have a small, fixed set of values. A tag with many values makes a new time series for each value, and the collector becomes slow and expensive.

  • Never a metric tag: ids (recording, transcript, interview, survey, session, client, pipeline, queue element), phone numbers, email addresses, user and agent names, URLs and hosts, file names and paths, lock keys, SQL text, prompts and transcript text. CrestAppsOrchardCoreTelemetry.BannedMetricTagKeys has the shared list, and TelemetryCapture in the tests adds the CloudSolutions ids. The tests fail when a measurement uses one of these keys.
  • Spans and logs can carry ids. They must never carry phone numbers, prompts or transcript text.
  • A failed span records the type and the stack of the exception, but not the message, because a message can quote personal data. The message stays in the log.

Tenant tag​

Spans and logs always carry the tenant (orchardcore.tenant.name), through OrchardCore.OpenTelemetry.

The CrestApps and CloudSolutions metrics carry the same orchardcore.tenant.name tag. They follow the Orchard Core option, which is on by default. Set it to false to limit the number of series when the site has many tenants:

{
"OrchardCore": {
"OpenTelemetry": {
"Metrics": {
"IncludeTenantName": false
}
}
}
}

Platform (CrestApps.OrchardCore.Platform)​

Background tasks​

Orchard Core starts a span for each run of a background task and records orchardcore.background_task.duration. 15 background tasks of the modules add these metrics:

InstrumentUnitTagsMeaning
crestapps.background_task.outcomes{run}task, outcomeThe runs that did not end ok. outcome is error, skipped (nothing to do), skipped_lease (another worker has the work), cancelled, timeout or budget_exceeded. A run that ended ok is not counted here: orchardcore.background_task.duration has all the runs.
crestapps.background_task.items{item}task, resultThe items the runs processed. See the table below for the results of each task.
crestapps.background_task.last_successstaskThe Unix time of the last run that ended with ok or skipped. Make an alert when it is too far behind the current time.
crestapps.background_task.lock.utilization1taskThe duration of a run divided by the lock expiration of the task. A value near 1 or above means that a second node can start the same task. A task without a lock expiration does not record it.

A task that logs an error and continues reports outcome=error. Orchard Core sees such a run as a success.

Taskresult values
TranscriptionsBackgroundTaskqueued, orphaned, failed
SpeechTranscriptTaskBackgroundTask, SpeechTranscriptTaskRecoveryBackgroundTaskrecovered. The attempts are in cloudsolutions.speech.transcript_task.duration.
SpeechRecordingPartCleanupBackgroundTaskremoved, failed
RecordingEncryptionRecoveryBackgroundTaskresumed
SpeechTranscriptRetroProcessRecoveryBackgroundTaskresumed for the stalled run that the task starts again, failed for a run that the task cannot resume. The task does not wait for the run, so the items do not tell how the run ends.
SpeechInsightsExportCleanupBackgroundTaskdeleted
QueueProcessorBackgroundTaskprocessed, failed, removed, no_processor (no processor can handle the queue of the element)
InterviewDataCleanupBackgroundTaskdeleted
RecordingTrimmingBackgroundServicetrimmed
TableauSyncBackgroundTask, TableauCatchupBackgroundTaskOne item for each pipeline that the task ran: exported, failed, skipped (the circuit breaker is open, another job has the pipeline, or another job took it over) or cancelled (the host shut down during the run)
UploadedRecordingsBackgroundTask, CallMinerBulkExportJobCreatorTask, ContentViewingIndexBackgroundTaskNo items.

IngestionSourceProcessorBackgroundTask adds no metric. It only starts the ingestion of all the sources outside the background service and does not wait for it. The ingestion metrics below have the runs and the recordings.

The service of these tasks tells them how the run ended:

Taskoutcome values
UploadedRecordingsBackgroundTaskskipped_lease when another job has the uploads, skipped when no upload waits
CallMinerBulkExportJobCreatorTaskskipped when the integration is not configured, error when the webhook is not validated, CallMiner refused an export job or an exception stopped the run
TableauSyncBackgroundTask, TableauCatchupBackgroundTaskerror when one or more pipelines ended failed. The executor logs the error and keeps it to itself, so the task reports it. The Tableau metrics below have the export runs.
SpeechTranscriptRetroProcessRecoveryBackgroundTaskskipped when no run is stalled or when an active run must end first, error when the task cannot resume a run

Jobs after a request and deferred tasks​

A job runs after the response is sent, so it has no request to report its failure to. A deferred task runs when the scope that queued it ends. The two kinds record the same instrument.

InstrumentUnitTagsMeaning
crestapps.deferred_task.durationstask, outcome, error.typeThe duration of the jobs and the deferred tasks, by how they ended. The count of the histogram is the number of runs.

Each job and each deferred task has a crestapps.deferred.<task> span. The span starts a new trace and has a link to the request that queued the work. A deferred task that runs while that request is still active stays in the trace of the request.

A job or a deferred task that catches its own errors returns its outcome. If it does not, each run looks like a success. When an exception leaves the job or the task, the outcome is error, cancelled or timeout, and an error has the error.type. An error that the job or the task returns has no error.type: the log has the error. paused and stopped are the constants OutcomePaused and OutcomeStopped of MeasuredDeferredTask.

The jobs after a request:

taskoutcome values
process_speech_transcriptionok, skipped_lease (another worker has the lock of the transcription), skipped (the transcription has no known tenant, or the scope of the tenant is not available)
encrypt_speech_recordingsok, error, stopped (a user stopped the job, or a newer run replaced this run), cancelled (the application shut down during the run, and the recovery task resumes the job), skipped (the run does not own the job)
generate_large_speech_insights_exportok (the file is ready), skipped (there is nothing to export), error (the job cannot make the file)
run_speech_rule_evaluationok, error, skipped (the attempt is not found, or it is not in progress)
run_speech_transcript_retro_processok, error, paused, cancelled (the run was canceled, another job took it over, or the host shut down during the run), skipped (another job owns the run, or the run was already finished). Only a run that a request starts is measured. A run that the recovery task starts again is not a job after a request, and it has no job metric.
tableau_run_pipelineok, error, cancelled (the host shut down during the run), skipped (the pipeline no longer exists, another job has the pipeline, or another job took it over)
create_azure_webhook, ingest_uploaded_recordings, process_recordings, retry_selected_speech_processing_queue_items, retry_all_abandoned_speech_processing_queue_itemsThese jobs return no outcome: ok, or the outcome of the exception that left the job

The deferred tasks:

taskoutcome values
index_speech_transcriptsok, skipped (the scope has no transcript to index, or no Speech index profile exists)
callminer_export_indexok, skipped (the integration is not configured), error (the webhook is not validated, CallMiner refused an export job or an exception stopped the run)
validate_callminer_webhookerror when CallMiner does not validate the webhook. If CallMiner validates it, the values of callminer_export_index.
process_callminer_export_fileok, error (the task cannot download or read the file, or it cannot find the export job or the index of the file)
sync_sendbird_usersok, skipped (the Sendbird application is not installed), error (one or more users were not synchronized)

Retries​

InstrumentUnitTagsMeaning
crestapps.retry.attempts{retry}area, reason, attemptThe retries of the retry loops of the modules. attempt is 1 to 5.
areareason valuesWhere
speech_aitimeout, network, otherThe AI calls of the transcript processing
azure_speechtimeout, network, status_429, status_5xx, otherThe Azure Speech batch client
speech_retrotimeout, network, status_429, otherThe AI calls of the retro processing. A rate limit is status_429.

Speech (CloudSolutions.Speech)​

InstrumentUnitTagsMeaning
cloudsolutions.speech.transcript_task.durationsoutcome, reason, error.typeThe duration of one processing attempt of a transcript task. outcome is ok (completed), retry (failed, waits for the next attempt), abandoned (not tried again), skipped (another worker has the task, or its recording parts are not ready), error, cancelled or timeout. Only an abandoned attempt has a reason.
cloudsolutions.speech.transcript_task.stage.durationsstage, outcomeThe duration of one handler stage of a processing attempt. stage is transcript_embedding, transcript_tagging, indicator_extraction, playbook_evaluation, or other for a handler that has no stage name. outcome is ok, incomplete (the stage kept the work it completed, and it has work left for the next attempt) or error.
cloudsolutions.speech.recording_encryption.recordings{recording}resultThe recordings the recording encryption job checked. result is encrypted, already_encrypted, recovered (a previous attempt was interrupted, and the job completed it), not_found (no recording exists at the path), skipped_raw (a raw recording that waits for transcription stays plain), failed or other.
reason of an abandoned attemptMeaning
transcript_not_foundThe transcript is not in the store.
no_metadataThe transcript has no Azure transcription.
no_speechThe transcription has no recognized speech.
content_filterThe content filter of the AI service rejected the transcript.
missing_resourceThe transcription no longer exists at the Azure Speech service.
max_attemptsThe last attempt failed.

Each attempt has a cloudsolutions.speech.transcript_task.process span with the transcript id in cloudsolutions.speech.transcript.id. The AI calls and the calls to Azure Speech are below it.

Each measured stage has a cloudsolutions.speech.transcript_task.stage span with the stage tag. When a transcript task runs the stage, the span is below the span of the attempt. Only the stages of the transcription handlers are measured. The speaker identification is one AI call, and the redacted audio is an ffmpeg process and a file store call: the components that do that work report it. The download of the transcript, the start of the workflow and the removal of the Azure artifacts are not measured. A stage that is already completed does no work, so it records nothing.

Limit: a stage that stops with an exception records error without an error.type. This is also true when the exception is a cancellation. The log has the exception.

Speech Insights (CloudSolutions.SpeechInsights)​

InstrumentUnitTagsMeaning
cloudsolutions.speech_insights.ingestion.run.durationssource_type, outcomeThe duration of one ingestion run of a source. outcome is ok, or error when the run stopped, for example because the source cannot be reached.
cloudsolutions.speech_insights.ingestion.recordings{recording}source_type, resultThe recordings the runs handled. result is ingested, skipped (not ready yet, or a duplicate) or failed.
cloudsolutions.speech_insights.ingestion.recording.sizeBysource_typeThe size of each recording that the runs ingested.
cloudsolutions.speech_insights.retro.transcripts{transcript}resultThe transcripts the saved batches of the retro-processing runs handled. result is updated (the batch changed the transcript and saved it), failed (the batch could not evaluate the transcript, or a rule of the transcript got no usable AI answer, and the transcript was not in the failed records of the run before; such a transcript can also be counted as updated when the rules that were evaluated changed it), dropped (the transcript of a failed record no longer exists, so the heal attempt removed the record) or healed (the heal attempt evaluated the transcript of a failed record again, and it did not fail). A transcript that a run evaluated without a change is not counted.
cloudsolutions.speech_insights.rule_evaluation.transcripts{transcript}rule_type, resultThe transcripts the rule evaluations that succeeded evaluated. rule_type is tag or indicator. result is sampled for each transcript, and matched for each transcript that the rule matched. A matched transcript is in the two results.
cloudsolutions.speech_insights.redaction.fallbacks{fallback}reasonThe times the sensitive-data redaction used the local redaction because the model gave no valid answer. reason is unusable (the model rejected the request, or its answer cannot be read), timed_out, truncated (the answer was cut off) or other (the model answered each time, but the answers were not valid).
cloudsolutions.speech_insights.change_queue.changes{change}resultThe transcript changes for the data pipelines. result is queued (the changes were saved in the change queue) or lost (the scope ended before the changes were saved).

source_type is the type of the source, for example Ftp or Sftp. It is never the name or the id of the source.

A retro-processing batch is counted only after it is saved. When no data pipeline reads the transcript changes, no change is queued and no change is counted.

Limit: a rule evaluation counts its transcripts when the evaluation ends, before the job commits the attempt. If the commit fails, the transcripts stay counted.

Tableau (CloudSolutions.Tableau)​

InstrumentUnitTagsMeaning
cloudsolutions.tableau.export.durationsmode, outcomeThe duration of one export run of a pipeline. mode is initial (the run published the whole datasource) or incremental (the run sent only the pending changes). outcome is ok, error, cancelled (the host shut down during the run) or claim_lost (another job took over the pipeline during the run).
cloudsolutions.tableau.change_queue.changes{change}resultThe transcript changes for the Tableau synchronization. result is queued (the changes were saved as pending changes of the active pipelines) or lost (the scope ended before the changes were saved). One transcript is one change, also when more than one pipeline gets it.

Each export run has a cloudsolutions.tableau.export.run span with the pipeline id in cloudsolutions.tableau.pipeline.id.

An incremental run that finds a changed schema publishes the whole datasource again, so its mode is initial. When no pipeline is active, no change is queued and no change is counted.

Limits:

  • The duration starts when the run has the claim of the pipeline. A run that ends before it takes the claim records no duration: a run that is skipped (the circuit breaker is open, or another job has the pipeline) and a run that fails because Tableau Cloud is not configured. The items of the two Tableau background tasks and the outcome of the tableau_run_pipeline job report these runs.
  • A run that ends error has no error.type, because the executor catches the exception. The log has the exception.

Agent Trainer (CloudSolutions.AgentTrainer)​

InstrumentUnitTagsMeaning
cloudsolutions.agent_trainer.turn.durationsoutcome, error.typeThe duration of one turn of the simulator. A turn starts when the simulator has the message of the agent: the text, or the complete recording. It ends when the reply is sent and the transcript is saved. outcome is ok, or the outcome of the exception that stopped the turn: error, cancelled or timeout.
cloudsolutions.agent_trainer.sessions.completed{session}interaction_type, assistedThe simulator sessions that were completed. interaction_type is chat (the agent and the customer write messages) or audio (they speak), or unknown for a value that is not in the list. assisted is true when the session gave assistance to the agent, and false when it did not.

Each turn has a cloudsolutions.agent_trainer.turn span. An exception that the simulator shows to the agent as an error message also makes the turn fail.

Surveys (CloudSolutions.Surveys)​

InstrumentUnitTagsMeaning
cloudsolutions.surveys.interviews.completed{interview}NoneThe interviews that were completed.
cloudsolutions.surveys.change_queue.changes{change}resultThe interview changes for the data pipelines. result is queued (the changes were saved in the change queues) or lost (the scope ended before the changes were saved). One interview is one change.

When no data pipeline reads a survey version of the scope, no change is queued and no change is counted.

Limit: the change counter counts all the completed interviews that the scope changed or deleted. When a data pipeline reads only some of the survey versions of the scope, the interviews of the other survey versions are counted as queued too.

Add telemetry to a module​

The helpers are in the CrestApps.OrchardCore.Abstractions package, namespace CrestApps.OrchardCore.Diagnostics. CloudSolutions.Infrastructure (namespace CloudSolutions.Infrastructure.Diagnostics) adds only the names of our meters, the job helper and the deferred task helper. Use them before you write a new helper.

NeedHelper
A meter or an activity source for an areaCloudSolutionsTelemetry.CreateMeter, CreateActivitySource
A histogramCrestAppsOrchardCoreTelemetry.CreateDurationHistogram, CreateCountHistogram
A span, a duration and an outcome for one operationTelemetryScope.Start in a using declaration, then Succeed(), SetOutcome(...) or Fail(exception)
A background taskthis.RunAsync(run => ...) in DoWorkAsync. Report on run: AddItems, Skip, SkipForLease, ReportError. For an item that failed, call run.AddItems(1, "failed") and run.ReportError(ex).
A job after the requestMeasuredHttpBackgroundJob.ExecuteAfterEndOfRequestAsync(jobName, ...)
A job after the request that catches its own errorsThe overloads of MeasuredHttpBackgroundJob.ExecuteAfterEndOfRequestAsync whose job returns its outcome (Task<string>)
A deferred taskMeasuredDeferredTask.Add(name, work). The work returns its outcome, and null means ok.
A retry loopRetryTelemetry.RecordRetry(area, reason, attempt)
Work that a later process continuesTraceContextPropagation.Capture() when you queue it, TelemetryScope.StartLinked when you run it

Rules:

  1. Measure only our own operations. Do not put a span or a duration around one HTTP or SDK call, a database query, a lock, a migration, a recipe or a file store.
  2. Use one instrument for one fact. Do not add a counter beside a histogram that has the same tags.
  3. Record an outcome for each operation. A scope that is disposed without an outcome records unknown.
  4. A job or a deferred task that catches its own errors must return its outcome: ok, error, skipped or another value from a fixed list. If it returns nothing, each run is recorded as ok.
  5. Count an item only when you know its result. An attempt is not a result.
  6. Put ids on the span with SetSpanTag. Put only bounded values on the metric with AddMetricTag. TelemetryScope adds the outcome tag and the tenant tag, so do not add them again.
  7. Add each new instrument to this page: name, unit, tags and meaning. The names are a public contract for dashboards and alerts.
  8. Add a test with TelemetryCapture (tests/CloudSolutions.Tests/TestUtilities). Assert the exact number of measurements and their tag values, and that FindBannedTagKeys() is empty.