Skip to content

Commit 26e926b

Browse files
mauroservientilailabougriaSzymonPobiega
authored
Update metrics related samples to NServiceBus 9.1 (#6777)
* Remove not needed using directive * Use a wild card in the source name to include all possible meters * Adjust the OTel AppInsights sample for 9.1 * Adjust the OTel Prometheus and Grafana sample for 9.1 * Mark as reviewed * update the screenshots * Add new metrics to the sample dashboard * Add the shim as a dedicated sample * fix links and add retries * remove shim from app insights sample * remove shim from grafana sample * readd shim to v9 * link to the shim from the docs * remove .net7 * Use new form of note * address code issues --------- Co-authored-by: Laila Bougria <[email protected]> Co-authored-by: SzymonPobiega <[email protected]>
1 parent 1beab25 commit 26e926b

40 files changed

+718
-452
lines changed

nservicebus/operations/opentelemetry_metrics_core_[8,9.1).partial.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,16 @@ snippet: opentelemetry-enablemeters
1313
- `nservicebus.messaging.fetches` - Total number of messages fetched from the queue by the endpoint
1414
- `nservicebus.messaging.failures` - Total number of messages processed unsuccessfully by the endpoint
1515

16-
See the [OpenTelemetry samples](/samples/open-telemetry/) for instructions on how to send metric information to different tools.
16+
See the [OpenTelemetry samples](/samples/open-telemetry/) for instructions on how to send metric information to different tools.
17+
18+
### Additional metrics
19+
20+
The NServiceBus.Metrics package provides additional metrics that are not yet exposed via OpenTelemetry.
21+
22+
These metrics include:
23+
- Critical time
24+
- Processing time
25+
- Handler time
26+
- Retries
27+
28+
To expose these metrics via OpenTelemetry, a shim can be used. The [OpenTelemetry shim sample](/samples/open-telemetry/metrics-shim/) demonstrates how to set up a shim that exposes NServiceBus.Metrics in an OpenTelemetry format and exports them to Azure Application Insights.

samples/open-telemetry/application-insights/Core_9/Endpoint/MetricsShim/Extensions.cs

Lines changed: 0 additions & 44 deletions
This file was deleted.

samples/open-telemetry/application-insights/Core_9/Endpoint/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
var traceProvider = Sdk.CreateTracerProviderBuilder()
2828
.SetResourceBuilder(resourceBuilder)
29-
.AddSource("NServiceBus.Core")
29+
.AddSource("NServiceBus.Core*")
3030
.AddAzureMonitorTraceExporter(o => o.ConnectionString = appInsightsConnectionString)
3131
.AddConsoleExporter()
3232
.Build();
@@ -37,7 +37,7 @@
3737

3838
var meterProvider = Sdk.CreateMeterProviderBuilder()
3939
.SetResourceBuilder(resourceBuilder)
40-
.AddMeter("NServiceBus.Core")
40+
.AddMeter("NServiceBus.Core*")
4141
.AddAzureMonitorMetricExporter(o => o.ConnectionString = appInsightsConnectionString)
4242
.AddConsoleExporter()
4343
.Build();
@@ -72,4 +72,4 @@
7272
await endpointInstance.Stop(cancellation.Token);
7373
traceProvider?.Dispose();
7474
meterProvider?.Dispose();
75-
}
75+
}
127 KB
Loading
206 KB
Loading
248 KB
Loading

samples/open-telemetry/application-insights/sample.md

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Monitoring NServiceBus endpoints with Application Insights
33
summary: How to configure NServiceBus to export OpenTelemetry traces and meters to Application Insights
4-
reviewed: 2024-01-17
4+
reviewed: 2024-07-26
55
component: Core
66
previewImage: trace-timeline.png
77
related:
@@ -58,19 +58,19 @@ To monitor the rate of messages being fetched from the queuing system, processed
5858

5959
To monitor [recoverability](/nservicebus/recoverability/) metrics use:
6060

61-
- `nservicebus.recoverability.immediate_retries`
62-
- `nservicebus.recoverability.delayed_retries`
63-
- `nservicebus.recoverability.retries`
64-
- `nservicebus.recoverability.sent_to_error`
61+
- `nservicebus.recoverability.immediate`
62+
- `nservicebus.recoverability.delayed`
63+
- `nservicebus.recoverability.error`
6564

6665
![Graph showing recoverability metrics in Application Insights](metrics-recoverability.png)
6766

68-
#### Critical time and processing time
67+
#### Handler time, critical time, and processing time
6968

70-
To monitor [critical time and processing time](/monitoring/metrics/definitions.md#metrics-captured) (in milliseconds) for successfully processed messages use:
69+
To monitor [handler time, processing time, and critical time](/monitoring/metrics/definitions.md#metrics-captured) (in seconds) for successfully processed messages use:
7170

72-
- `nservicebus.messaging.processingtime`
73-
- `nservicebus.messaging.criticaltime`
71+
- `nservicebus.messaging.handler_time`
72+
- `nservicebus.messaging.processing_time`
73+
- `nservicebus.messaging.critical_time`
7474

7575
![Graph showing processing time and critical time metrics in Application Insights](metrics-timing.png)
7676

@@ -92,11 +92,3 @@ The endpoint configures an OpenTelemetry meter provider that includes the `NServ
9292

9393
snippet: enable-meters
9494

95-
#### Critical time and processing time
96-
97-
[Critical time and processing time captured by the metrics package](/monitoring/metrics/definitions.md#metrics-captured) are not yet supported in OpenTelemetry's native format (using System.Diagnostics), so a shim is required to expose them as OpenTelemetry metrics.
98-
99-
snippet: metrics-shim
100-
101-
> [!NOTE]
102-
> The shim passes `QueueName` as a custom dimension which allows filtering the graphs in Application Insights. Multi-dimensional metrics are not enabled by default. Check [the Azure Monitor documentation](https://docs.microsoft.com/en-us/azure/azure-monitor/app/get-metric#enable-multi-dimensional-metrics) for instructions on how to enable this feature.
506 KB
Loading

samples/open-telemetry/customizing/Core_9/Sample/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static async Task Main()
1717

1818
var tracerProviderBuilder = Sdk.CreateTracerProviderBuilder()
1919
.SetResourceBuilder(resourceBuilder)
20-
.AddSource("NServiceBus.Core")
20+
.AddSource("NServiceBus.Core*")
2121
.AddSource(CustomActivitySources.Name)
2222
.AddProcessor(new NetHostProcessor())
2323
.AddConsoleExporter();

samples/open-telemetry/customizing/sample.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Customizing OpenTelemetry tracing
33
summary: Demonstrates how to add data to existing OpenTelemetry traces
4-
reviewed: 2022-07-15
4+
reviewed: 2024-07-26
55
component: Core
66
related:
77
- nservicebus/operations/opentelemetry

0 commit comments

Comments
 (0)