Guides collecting and extending OpenTelemetry traces, metrics, and logs for CrestApps Orchard Core modules. Covers enabling collection, shared helpers (TelemetryScope, BackgroundTaskTelemetry, MeasuredTaskRun), naming rules, and instrumenting custom modules.
Ships in crestapps-orchardcore. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You are an Orchard Core expert. Help the user collect and extend the OpenTelemetry telemetry of the CrestApps.OrchardCore modules.
The modules emit traces, metrics and logs through System.Diagnostics only: no OpenTelemetry package is referenced by a module, and nothing is recorded until a listener subscribes. Each area has its own meter and activity source named CrestApps.OrchardCore.<Area>. CrestApps.Core reports under CrestApps.Core and CrestApps.Core.* (see crestapps-core-observability), and Orchard Core under OrchardCore (see orchardcore-opentelemetry).
AddOpenTelemetry() and adds the CrestApps sources and meters.sealed modifier, except View Models.Install OrchardCore.OpenTelemetry (Orchard Core brings every OpenTelemetry package) in the web/startup project:
using CrestApps.Core;
using CrestApps.OrchardCore.Diagnostics;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
var builder = WebApplication.CreateBuilder(args);
// Follow Orchard Core's option for tagging metrics with the tenant (default true).
CrestAppsOrchardCoreTelemetry.IncludeTenantName =
builder.Configuration.GetValue("OrchardCore:OpenTelemetry:Metrics:IncludeTenantName", true);
// True when OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_{SIGNAL}_ENDPOINT
// or OrchardCore:OpenTelemetry:Otlp:Endpoint is set.
var exportTelemetry = builder.Configuration.HasOtlpEndpoint();
// 'X.*' does not match 'X', so both are listed.
string[] ownSources =
[
CrestAppsTelemetry.SourceName,
CrestAppsTelemetry.SourceName + ".*",
CrestAppsOrchardCoreTelemetry.SourceNameWildcard,
"AICompletionService",
];
builder.Services.AddOrchardCms(orchardCoreBuilder =>
{
if (exportTelemetry)
{
orchardCoreBuilder.AddOpenTelemetry(openTelemetry => openTelemetry
.WithTracing(tracing => tracing.AddSource(ownSources))
.WithMetrics(metrics => metrics.AddMeter(ownSources)));
}
});
A host configured through settings lists the same names:
{
"OrchardCore": {
"OpenTelemetry": {
"Tracing": { "Sources": [ "CrestApps.OrchardCore.*", "CrestApps.Core", "CrestApps.Core.*", "AICompletionService" ] },
"Metrics": { "Meters": [ "CrestApps.OrchardCore.*", "CrestApps.Core", "CrestApps.Core.*", "AICompletionService" ], "IncludeTenantName": true }
}
}
}
AICompletionService carries the AI clients' gen_ai.* spans and metrics only while Enable OpenTelemetry is on under Settings > Artificial Intelligence (General card).OrchardCore:OpenTelemetry:Tracing:Sources or Metrics:Meters.OTEL_EXPORTER_OTLP_ENDPOINT. Without it, run the standalone Aspire dashboard (mcr.microsoft.com/dotnet/aspire-dashboard, OTLP on 4317) and set OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 and OTEL_SERVICE_NAME.IncludeTenantName off to limit metric series on hosts with many tenants. Spans and logs carry the tenant either way.| Rule | Value |
|---|---|
| Meter and source | CrestApps.OrchardCore.<Area> (CrestAppsOrchardCoreTelemetry.CreateMeter(area), CreateActivitySource(area)) |
| Instrument names | crestapps.<area>.<thing>; spans crestapps.<area>.<operation> |
| Units | UCUM: s, By, {row}, {item}; durations in seconds |
outcome | ok, error, skipped, cancelled, timeout, blocked (plus bounded area values); unknown when the operation ended without saying |
| Failures | The count of a duration histogram with outcome=error, not a separate counter; error also carries error.type |
| Banned metric tags | CrestAppsOrchardCoreTelemetry.BannedMetricTagKeys (ids, phone numbers, users, URLs, hosts, lock keys, file names, SQL, free-text names) |
| Tenant | orchardcore.tenant.name on metrics when IncludeTenantName is on |
| Async hops | Work that crosses a queue, an outbox or the webhook inbox keeps the queuing request's traceparent and starts a span linked to it, not a child |
| Logs | [LoggerMessage] with event ids from CrestAppsEventIds (10000 and up; CrestApps.Core uses ids below 10000) |
Some counters recorded inside a unit of work (contact center queues and offers, messaging, inventory holds, orders, subscriptions) can count twice when a write conflict retries the work; treat them as approximate.
Meter and source CrestApps.OrchardCore.Platform:
| Instrument | What it measures |
|---|---|
crestapps.background_task.outcomes | Background task runs that did not end ok (error, skipped, skipped_lease, cancelled, timeout, budget_exceeded), including failures a task logged and swallowed |
crestapps.background_task.items | Items a run processed, by result |
crestapps.background_task.last_success | Unix time of the last run without an error; alert when it falls behind |
crestapps.background_task.lock.utilization | Run duration divided by the task's lock expiration; near 1 the lock can expire mid-run |
crestapps.deferred_task.duration | Deferred tasks queued with DeferredWork.Add (span crestapps.deferred.<name>) |
crestapps.retry.attempts | Retries of the solution's own retry loops (area, reason, attempt capped at 5) |
crestapps.background.pacer.gate_wait, .pause | Time bulk batches wait for, and hold, the shared pacing gate |
Orchard Core already records orchardcore.background_task.duration and a span for every background task run.
using System.Diagnostics;
using System.Diagnostics.Metrics;
using CrestApps.OrchardCore.Diagnostics;
public static class InvoiceSyncTelemetry
{
public static readonly Meter Meter = CrestAppsOrchardCoreTelemetry.CreateMeter("InvoiceSync");
public static readonly ActivitySource Source = CrestAppsOrchardCoreTelemetry.CreateActivitySource("InvoiceSync");
public static readonly Histogram<double> SyncDuration = CrestAppsOrchardCoreTelemetry.CreateDurationHistogram(
Meter,
"crestapps.invoicesync.sync.duration",
"One synchronization of invoices with the ERP.");
}
public sealed class InvoiceSyncService
{
public async Task SyncAsync(string batchId, string provider, CancellationToken cancellationToken)
{
using var telemetry = TelemetryScope.Start(
InvoiceSyncTelemetry.Source,
"crestapps.invoicesync.sync",
InvoiceSyncTelemetry.SyncDuration,
new TagList { { CrestAppsOrchardCoreTelemetry.ProviderTag, provider } });
// Ids are span tags only.
telemetry.SetSpanTag("crestapps.invoicesync.batch.id", batchId);
try
{
// ... the work ...
telemetry.Succeed();
}
catch (Exception ex)
{
// Sets outcome error/cancelled/timeout, adds error.type, records the exception type on the span.
telemetry.Fail(ex);
throw;
}
}
}
TelemetryScope records the duration with outcome and the tenant tag when disposed. AddMetricTag adds a bounded tag to both the metric and the span, SetSpanTag to the span only, SetOutcome sets a bounded area value, Fail(reason) fails without an exception. TelemetryScope.StartLinked(source, name, duration, traceParent) starts a span linked to queued work.
Background tasks and deferred work:
public sealed class InvoiceSyncBackgroundTask : IBackgroundTask
{
public Task DoWorkAsync(IServiceProvider serviceProvider, CancellationToken cancellationToken)
=> this.RunAsync(run => SyncDueAsync(serviceProvider, run, cancellationToken));
private static async Task SyncDueAsync(IServiceProvider serviceProvider, MeasuredTaskRun run, CancellationToken cancellationToken)
{
var processed = 0;
// ... the work ...
if (processed == 0)
{
run.Skip();
return;
}
run.AddItems(processed);
}
}
this.RunAsync(...) (BackgroundTaskTelemetry) feeds the platform background task instruments and reads the lock expiration from the task's [BackgroundTask] attribute. Call run.ReportError(ex) for an error you catch and swallow so the run is not counted as healthy; run.SkipForLease() when another node holds the work; run.BudgetExceeded() when the run stopped at its time or item budget.DeferredWork.Add("invoice_sync", async scope => { ... }) replaces ShellScope.AddDeferredTask when the deferred work should be measured and linked to the request.TraceContextPropagation.Capture() returns the current traceparent to store with queued work; TraceContextPropagation.StartLinkedActivity(source, name, traceParent) starts the span that handles it later.RetryTelemetry.RecordRetry(area, reason, attempt) counts one retry of your own loop.ExternalCallTelemetry.GetStatusClass(statusCode) turns an HTTP status into a bounded status_class.See Meters by area for the meter of every module and its main instruments. Module skills with a monitoring section (Contact Center, Telephony, Report Builder, Data Connectors, Webhooks) give the details in context.
| Symptom | Check |
|---|---|
| No CrestApps spans or metrics | HasOtlpEndpoint() is false (no OTLP endpoint set), or CrestApps.OrchardCore.* is missing from the sources and meters |
No gen_ai.* telemetry | AICompletionService not added, or Enable OpenTelemetry is off in the AI settings |
crestapps.core.ai.usage.* empty | The AI Usage Analytics feature is off; only gen_ai.client.token.usage is available without it |
| Too many metric series | Turn off OrchardCore:OpenTelemetry:Metrics:IncludeTenantName; check a custom instrument does not tag ids |
| Old dashboards empty | Renamed instruments: report metrics use outcome instead of crestapps.report.outcome and no longer carry report, query or data set ids; contactcenter.outbox.* and asterisk.realtime.* became crestapps.contactcenter.outbox.* and crestapps.asterisk.realtime.* |
| Queued work shows as a separate trace | Expected: outbox, inbox and import work start linked spans; follow the span link |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/crestapps-orchardcore:orchardcore-observabilityfrom crestapps-orchardcore
npx claudepluginhub crestapps/crestapps.agentskills --plugin crestapps-orchardcore137 skills in this plugin
/orchardcore-accountsSkill for the CrestApps Orchard Core Accounts module (CrestApps.OrchardCore.Accounts) with its Account Members, Account Team, Account E-mail Domains and Account Locations features. Covers the Account type and AccountPart, the account picker and search, IAccountChildTypeRule, account page sections (AccountPageTabs, AddPageSection, Notes), members and IAccountMemberService, account invitations, the account owner and team picked from staff, e-mail domains, locations with a billing location, the account's billing profile and party members, the Accounts recipe and deployment steps, and the admin menu. Use this skill when requests mention accounts, the businesses or households records belong to, an account page tab, members, invitations, owners, domains or locations. Strong matches include AccountPart, AccountPageTabs, IAccountMemberService, IAccountInvitationService, AccountInvitation, AccountTeamPart, AccountEmailDomainsPart, IAccountEmailDomains, AccountLocationsPart and ManageAccountMembers./orchardcore-accounts-b2bSkill for the CrestApps Orchard Core Accounts B2B module (CrestApps.OrchardCore.Accounts.B2B), business selling on an Account content item. Covers B2BAccountPart and B2BAccount, buyers as account members and ship-to addresses as account locations, terms (deposit, net days, credit limit) through the account-terms tender billed to the account, the account's billing profile, purchase order numbers, quotes, price lists through IBuyerPriceProvider, order limits, approvals and budgets, OCI punchout, the account/business page and API, the PriceLists recipe and deployment steps, the B2BAccounts report source, and the move from the removed Companies module. Use this skill when requests mention B2B, wholesale or business buyers, net terms, purchase orders, price lists, order approvals or punchout. Strong matches include B2BAccountPart, B2BAccount, AccountTerms, AccountTermsTenderProvider, B2BAccountBillingProfileSource, IB2BAccountStore, PriceList, B2BPriceProvider, B2BApprovalService and ManageB2BAccounts.Other plugins' skills for the same job