Configures OpenTelemetry tracing, metrics, and logs for Orchard Core 4.0. Covers the OrchardCore.OpenTelemetry package, OTLP export, per-tenant tagging, and instrumenting YesSql, Npgsql, Elasticsearch, MailKit, and Azure SDK.
Ships in 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. Generate configuration and code that exports Orchard Core telemetry with OpenTelemetry over OTLP.
OrchardCore.OpenTelemetry (new in 4.0) is an application-level package, not a tenant feature: there is nothing to enable in a recipe or in the admin. It is configured once for the process, and the telemetry of every tenant is tagged with its name.AddOpenTelemetry() on the Orchard Core builder. It is not part of OrchardCore.Application.Cms.Targets; only the repository's OrchardCore.Cms.Web sample references it.AddOpenTelemetry() collects telemetry even when nothing exports it. When OTLP is the only exporter, guard the call with builder.Configuration.HasOtlpEndpoint().OrchardCore:OpenTelemetry:Otlp:Endpoint or in the standard OTEL_EXPORTER_OTLP_ENDPOINT value. The Otlp section takes precedence over the OTEL_* values.AddOpenTelemetry() twice is ignored, so exporters are never registered twice.ServiceDefaults), do not call AddOpenTelemetry() on the Orchard Core builder; add AddOrchardCoreInstrumentation() to the existing tracing, metrics and logging builders, before the exporters.YesSql, Npgsql, Elastic.Transport, MailKit.Net.SmtpClient, Azure.* and so on to Tracing:Sources / Metrics:Meters.Metrics:IncludeTenantName to false to limit the number of HTTP metric series. Spans and logs keep the tenant tag.Otlp:Endpoint that is not an absolute HTTP or HTTPS URI stops the application from starting.sealed, except view models.<PackageReference Include="OrchardCore.OpenTelemetry" Version="4.*" />
var builder = WebApplication.CreateBuilder(args);
builder.Host.UseNLogHost();
var orchardCore = builder.Services.AddOrchardCms();
// Only collect when something exports it, e.g. OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317.
if (builder.Configuration.HasOtlpEndpoint())
{
orchardCore.AddOpenTelemetry();
}
var app = builder.Build();
app.UseStaticFiles();
app.UseOrchardCore();
app.Run();
Add other instrumentations or exporters with the optional callback, which receives the OpenTelemetryBuilder:
builder.Services
.AddOrchardCms()
.AddOpenTelemetry(openTelemetry => openTelemetry
.WithTracing(tracing => tracing.AddSqlClientInstrumentation()));
AddOpenTelemetry() and AddOrchardCoreInstrumentation() live in the Microsoft.Extensions.DependencyInjection and OpenTelemetry namespaces; HasOtlpEndpoint() extends IConfiguration in Microsoft.Extensions.Configuration.
Options bind to OrchardCoreOpenTelemetryOptions from the application-level OrchardCore:OpenTelemetry section (not a tenant section):
{
"OrchardCore": {
"OpenTelemetry": {
"Enabled": true,
"ServiceName": "MyCms",
"ServiceInstanceId": "web-1",
"Tracing": {
"Enabled": true,
"SamplingRatio": 0.25,
"Sources": [ "MyCompany.MyModule", "YesSql" ],
"SlowShapeThreshold": "00:00:00.050"
},
"Metrics": {
"Enabled": true,
"IncludeTenantName": true,
"Meters": [ "MyCompany.MyModule", "YesSql" ]
},
"Logging": {
"Enabled": true
},
"Otlp": {
"Endpoint": "http://localhost:4317",
"Protocol": "Grpc"
}
}
}
}
| Setting | Default | Notes |
|---|---|---|
Enabled | true | Turns collection and export off. |
ServiceName | Application name | service.name resource attribute. |
ServiceInstanceId | Machine name + process id | service.instance.id, distinguishes web-farm nodes. |
Tracing:SamplingRatio | All sampled (or OTEL_TRACES_SAMPLER) | 0 to 1; a sampled parent always samples its children. |
Tracing:Sources | [] | Extra ActivitySource names; a trailing * matches a prefix. |
Tracing:SlowShapeThreshold | 00:00:00.050 | Shapes slower than this get a Render shape {type} span; 00:00:00 traces every shape. |
Metrics:IncludeTenantName | true | Tags http.server.request.duration with the tenant. |
Metrics:Meters | [] | Extra Meter names; a trailing * matches a prefix. |
Logging:Enabled | true | The levels of the Logging section still apply. |
Otlp:Endpoint | OTEL_EXPORTER_OTLP_ENDPOINT | http://host:4317 for gRPC, http://host:4318 for HTTP. |
Otlp:Protocol | OTEL_EXPORTER_OTLP_PROTOCOL, else Grpc | Grpc or HttpProtobuf. |
Standard values are also honored: OTEL_EXPORTER_OTLP_ENDPOINT, _PROTOCOL, _HEADERS, _TIMEOUT, _COMPRESSION (and their _TRACES_, _METRICS_, _LOGS_ variants, which win; a per-signal endpoint is used as is, and only signals with an endpoint are exported), OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE, OTEL_SDK_DISABLED, OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES (both win over the section), and the batch settings OTEL_BSP_* / OTEL_BLRP_* (environment variables only).
service.name, service.version, service.instance.id, host.name, process.pid, process.runtime.name, process.runtime.version, deployment.environment.name, orchardcore.version.OrchardCore activity source: Build tenant container, Build tenant pipeline, Activate tenant, Run background task {task} (root of its own trace), Execute recipe {recipe}, Execute recipe step {step}, and Render shape {type} for slow shapes (a child of the request). Failures set the Error status, error.type and an exception event.OrchardCore meter: orchardcore.tenants (gauge by orchardcore.tenant.state), orchardcore.tenants.loaded, orchardcore.tenant.container.duration, orchardcore.tenant.pipeline.duration, orchardcore.tenant.activation.duration, orchardcore.tenant.releases, orchardcore.background_task.duration, and orchardcore.shape.cache.lookups (hit/miss, with Dynamic Cache enabled).System.Net.Http and System.Runtime meters, and ILogger logs with scopes, next to NLog or Serilog.orchardcore.tenant.name.{
"OrchardCore": {
"OpenTelemetry": {
"Tracing": {
"Sources": [ "YesSql", "Npgsql", "Elastic.Transport", "MailKit.Net.SmtpClient", "Azure.*" ]
},
"Metrics": {
"Meters": [ "YesSql", "Npgsql" ]
}
}
}
}
db.client.operation.duration, and the yessql.session.commands / yessql.session.documents histograms (many commands per session reveals an N+1 pattern). Its telemetry is tagged with the tenant of the store.IncludeQueryTextInTelemetry (OrchardCore:YesSql:IncludeQueryTextInTelemetry). Npgsql spans always include it.YesSql and Npgsql meters counts each command twice; drop the driver instrument with a view:using OpenTelemetry.Metrics;
using YesSql;
builder.Services
.AddOrchardCms()
.AddOpenTelemetry(openTelemetry => openTelemetry
.WithMetrics(metrics => metrics.AddView(instrument =>
YesSqlTelemetry.IsDuplicateDriverInstrument(instrument) ? MetricStreamConfiguration.Drop : null)));
A library that emits nothing itself (for example the SQL Server client) needs an instrumentation package added through the AddOpenTelemetry() callback.
Add the OrchardCore.DisplayManagement source and meter (constants DisplayManagementDiagnostics.ActivitySourceName and MeterName) to get a nested Render shape {type} span for every shape, with orchardcore.shape.type and orchardcore.shape.binding (the template or shape method), plus orchardcore.display.shapes_rendered and the orchardcore.display.shape.duration histogram:
{
"OrchardCore": {
"OpenTelemetry": {
"Tracing": { "Sources": [ "OrchardCore.DisplayManagement", "YesSql" ] },
"Metrics": { "Meters": [ "OrchardCore.DisplayManagement" ] }
}
}
}
Find the slowest shape types in the histogram, open a slow request's Render shape spans, compare a shape's time with its children's, and read the nested YesSql spans to tell one slow query from many small ones. For a quick per-request view in development, see orchardcore-mini-profiler.
builder.Services.AddOpenTelemetry()
.WithTracing(tracing => tracing.AddOrchardCoreInstrumentation())
.WithMetrics(metrics => metrics.AddOrchardCoreInstrumentation())
.WithLogging(logging => logging.AddOrchardCoreInstrumentation());
Add the Orchard Core instrumentation before the exporters so telemetry is tagged with the tenant first.
OrchardCoreTelemetry (namespace OrchardCore.Telemetry, package OrchardCore.Abstractions) exposes the shared ActivitySource and Meter, which only depend on System.Diagnostics:
using OrchardCore.Telemetry;
public sealed class ProductImporter
{
public async Task ImportAsync()
{
using var activity = OrchardCoreTelemetry.ActivitySource.StartActivity("Import products");
try
{
await ImportProductsAsync();
}
catch (Exception ex)
{
// Sets the Error status, error.type and an exception event; accepts a null activity.
OrchardCoreTelemetry.RecordException(activity, ex);
throw;
}
}
private Task ImportProductsAsync() => Task.CompletedTask;
}
Attribute and instrument names are constants of OrchardCoreTelemetryConstants (for example OrchardCoreTelemetryConstants.Attributes.TenantName). A module can instead use its own ActivitySource or Meter and add its name to Tracing:Sources or Metrics:Meters. Without OpenTelemetry, watch the meter with dotnet-counters monitor --counters OrchardCore,System.Runtime (the orchardcore.tenants gauges are only observed once OpenTelemetry metrics are configured).
See references/opentelemetry-examples.md for local Aspire and Grafana setups and backend queries.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/orchardcore:orchardcore-opentelemetryfrom orchardcore
npx claudepluginhub crestapps/crestapps.agentskills --plugin orchardcore140 skills in this plugin
/orchardcore-adminGuidance for the Orchard Core admin panel, including admin controllers and routes, admin menu registration with AdminNavigationProvider, ocat editor forms grouped in cards, admin pages rendering Model.Editor, the UI text casing standard, TheAdmin layout and menu colors, admin branding, the Navbar shape, the Ctrl+K quick navigation palette and QuickNavigationSource, AdminSettings such as MenuBehavior, ShowBreadcrumb, DisplayQuickNavigation, DisplayTitlesInTopbar and ActionsLayout, the AdminDashboard shape, settings pages, and admin filters and zones. Use this skill when requests mention the Orchard Core admin panel, TheAdmin, admin controllers, admin menu registration, an icon on an admin menu item, the AdminSettings recipe step, quick navigation, navigation menu behavior, the admin URL prefix, UI text casing. Strong matches include OrchardCore.Admin, AdminSettings, AdminPermissions, AdminOptions, AdminAttribute, SiteDisplayDriver, IDisplayManager./orchardcore-admin-dashboardSkill for creating admin dashboard widgets in Orchard Core. Covers the DashboardWidget stereotype, DashboardPart position and sizing, the built-in HtmlDashboardWidget, ContentsMetadata and ContentsTags widget types, custom widget content types via recipe or migration, arranging widgets in Manage Dashboard mode, widget template customization, provisioning widgets with recipes, dashboard permissions, the DashboardBreadcrumbProvider Dashboard ancestor, and the AdminDashboardContent shape used when the feature is disabled. Use this skill when requests mention Orchard Core Admin Dashboard, Create and Configure Dashboard Widgets, Enabling Admin Dashboard, Widget Configuration Properties, dashboard widget recipes, Dashboard breadcrumb, or related implementation, setup, or troubleshooting work. Strong matches include OrchardCore.AdminDashboard, DashboardPart, DashboardBreadcrumbProvider, AccessAdminDashboard, ManageAdminDashboard.Other plugins' skills for the same job