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:
| Operation | Reported by |
|---|---|
| An HTTP call to another system | The HttpClient spans and http.client.request.duration, which Orchard Core collects |
| The duration of a background task run | orchardcore.background_task.duration and the Run background task span of Orchard Core |
| An ASP.NET Core request, a recipe, a tenant activation | Orchard Core and ASP.NET Core |
| A database command | YesSql and the database driver, when their names are in the settings |
| An AI call | CrestApps.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
| Item | Rule | Example |
|---|---|---|
| Meter and activity source | CloudSolutions.<Area> | CloudSolutions.Speech |
| Instrument | cloudsolutions.<area>.<thing>, with a UCUM unit | cloudsolutions.speech.transcript_task.duration (s) |
| Span | cloudsolutions.<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).
| Tag | Values |
|---|---|
outcome | ok, error, skipped, cancelled, timeout, unknown, and the values an instrument lists |
error.type | The full name of the exception type. Only with outcome=error. |
result | What became of one item, for example processed or failed |
reason | Why an operation ended as it did, from a fixed list |
task | The class name of a background task, or the name of a job or a deferred task |
area | The retry loop, from a fixed list |
orchardcore.tenant.name | The 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.BannedMetricTagKeyshas the shared list, andTelemetryCapturein 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:
| Instrument | Unit | Tags | Meaning |
|---|---|---|---|
crestapps.background_task.outcomes | {run} | task, outcome | The 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, result | The items the runs processed. See the table below for the results of each task. |
crestapps.background_task.last_success | s | task | The 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.utilization | 1 | task | The 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.
| Task | result values |
|---|---|
TranscriptionsBackgroundTask | queued, orphaned, failed |
SpeechTranscriptTaskBackgroundTask, SpeechTranscriptTaskRecoveryBackgroundTask | recovered. The attempts are in cloudsolutions.speech.transcript_task.duration. |
SpeechRecordingPartCleanupBackgroundTask | removed, failed |
RecordingEncryptionRecoveryBackgroundTask | resumed |
SpeechTranscriptRetroProcessRecoveryBackgroundTask | resumed 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. |
SpeechInsightsExportCleanupBackgroundTask | deleted |
QueueProcessorBackgroundTask | processed, failed, removed, no_processor (no processor can handle the queue of the element) |
InterviewDataCleanupBackgroundTask | deleted |
RecordingTrimmingBackgroundService | trimmed |
TableauSyncBackgroundTask, TableauCatchupBackgroundTask | One 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, ContentViewingIndexBackgroundTask | No 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:
| Task | outcome values |
|---|---|
UploadedRecordingsBackgroundTask | skipped_lease when another job has the uploads, skipped when no upload waits |
CallMinerBulkExportJobCreatorTask | skipped 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, TableauCatchupBackgroundTask | error 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. |
SpeechTranscriptRetroProcessRecoveryBackgroundTask | skipped 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.
| Instrument | Unit | Tags | Meaning |
|---|---|---|---|
crestapps.deferred_task.duration | s | task, outcome, error.type | The 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:
task | outcome values |
|---|---|
process_speech_transcription | ok, 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_recordings | ok, 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_export | ok (the file is ready), skipped (there is nothing to export), error (the job cannot make the file) |
run_speech_rule_evaluation | ok, error, skipped (the attempt is not found, or it is not in progress) |
run_speech_transcript_retro_process | ok, 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_pipeline | ok, 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_items | These jobs return no outcome: ok, or the outcome of the exception that left the job |
The deferred tasks:
task | outcome values |
|---|---|
index_speech_transcripts | ok, skipped (the scope has no transcript to index, or no Speech index profile exists) |
callminer_export_index | ok, 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_webhook | error when CallMiner does not validate the webhook. If CallMiner validates it, the values of callminer_export_index. |
process_callminer_export_file | ok, error (the task cannot download or read the file, or it cannot find the export job or the index of the file) |
sync_sendbird_users | ok, skipped (the Sendbird application is not installed), error (one or more users were not synchronized) |
Retries
| Instrument | Unit | Tags | Meaning |
|---|---|---|---|
crestapps.retry.attempts | {retry} | area, reason, attempt | The retries of the retry loops of the modules. attempt is 1 to 5. |
area | reason values | Where |
|---|---|---|
speech_ai | timeout, network, other | The AI calls of the transcript processing |
azure_speech | timeout, network, status_429, status_5xx, other | The Azure Speech batch client |
speech_retro | timeout, network, status_429, other | The AI calls of the retro processing. A rate limit is status_429. |
Speech (CloudSolutions.Speech)
| Instrument | Unit | Tags | Meaning |
|---|---|---|---|
cloudsolutions.speech.transcript_task.duration | s | outcome, reason, error.type | The 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.duration | s | stage, outcome | The 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} | result | The 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 attempt | Meaning |
|---|---|
transcript_not_found | The transcript is not in the store. |
no_metadata | The transcript has no Azure transcription. |
no_speech | The transcription has no recognized speech. |
content_filter | The content filter of the AI service rejected the transcript. |
missing_resource | The transcription no longer exists at the Azure Speech service. |
max_attempts | The 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)
| Instrument | Unit | Tags | Meaning |
|---|---|---|---|
cloudsolutions.speech_insights.ingestion.run.duration | s | source_type, outcome | The 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, result | The recordings the runs handled. result is ingested, skipped (not ready yet, or a duplicate) or failed. |
cloudsolutions.speech_insights.ingestion.recording.size | By | source_type | The size of each recording that the runs ingested. |
cloudsolutions.speech_insights.retro.transcripts | {transcript} | result | The 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, result | The 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} | reason | The 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} | result | The 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)
| Instrument | Unit | Tags | Meaning |
|---|---|---|---|
cloudsolutions.tableau.export.duration | s | mode, outcome | The 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} | result | The 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_pipelinejob report these runs. - A run that ends
errorhas noerror.type, because the executor catches the exception. The log has the exception.
Agent Trainer (CloudSolutions.AgentTrainer)
| Instrument | Unit | Tags | Meaning |
|---|---|---|---|
cloudsolutions.agent_trainer.turn.duration | s | outcome, error.type | The 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, assisted | The 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)
| Instrument | Unit | Tags | Meaning |
|---|---|---|---|
cloudsolutions.surveys.interviews.completed | {interview} | None | The interviews that were completed. |
cloudsolutions.surveys.change_queue.changes | {change} | result | The 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.
| Need | Helper |
|---|---|
| A meter or an activity source for an area | CloudSolutionsTelemetry.CreateMeter, CreateActivitySource |
| A histogram | CrestAppsOrchardCoreTelemetry.CreateDurationHistogram, CreateCountHistogram |
| A span, a duration and an outcome for one operation | TelemetryScope.Start in a using declaration, then Succeed(), SetOutcome(...) or Fail(exception) |
| A background task | this.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 request | MeasuredHttpBackgroundJob.ExecuteAfterEndOfRequestAsync(jobName, ...) |
| A job after the request that catches its own errors | The overloads of MeasuredHttpBackgroundJob.ExecuteAfterEndOfRequestAsync whose job returns its outcome (Task<string>) |
| A deferred task | MeasuredDeferredTask.Add(name, work). The work returns its outcome, and null means ok. |
| A retry loop | RetryTelemetry.RecordRetry(area, reason, attempt) |
| Work that a later process continues | TraceContextPropagation.Capture() when you queue it, TelemetryScope.StartLinked when you run it |
Rules:
- 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.
- Use one instrument for one fact. Do not add a counter beside a histogram that has the same tags.
- Record an outcome for each operation. A scope that is disposed without an outcome records
unknown. - A job or a deferred task that catches its own errors must return its outcome:
ok,error,skippedor another value from a fixed list. If it returns nothing, each run is recorded asok. - Count an item only when you know its result. An attempt is not a result.
- Put ids on the span with
SetSpanTag. Put only bounded values on the metric withAddMetricTag.TelemetryScopeadds theoutcometag and the tenant tag, so do not add them again. - Add each new instrument to this page: name, unit, tags and meaning. The names are a public contract for dashboards and alerts.
- Add a test with
TelemetryCapture(tests/CloudSolutions.Tests/TestUtilities). Assert the exact number of measurements and their tag values, and thatFindBannedTagKeys()is empty.