Skip to content

Commit 1293fb3

Browse files
Enable SqlClient metrics
Metrics become opt-in in 1.10.0-beta.1 and changed name.
1 parent 0fcf1d6 commit 1293fb3

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

docker/docker-compose-aspnetcore/oats.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ expected:
1414
contains:
1515
- 'Application started'
1616
metrics:
17-
# Investigate why this fails
18-
#- promql: db_client_operation_duration{}
19-
# value: '>= 0'
17+
- promql: db_client_operation_duration_seconds_count{}
18+
value: '>= 0'
2019
- promql: http_client_request_duration_seconds_count{}
2120
value: '>= 0'
2221
- promql: http_client_request_duration_seconds_count{http_request_method="GET", http_response_status_code="200"}

src/Grafana.OpenTelemetry.Base/Instrumentations/SqlClientInitializer.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// SPDX-License-Identifier: Apache-2.0
44
//
55

6+
using OpenTelemetry.Metrics;
67
using OpenTelemetry.Trace;
78

89
namespace Grafana.OpenTelemetry
@@ -11,6 +12,11 @@ internal class SqlClientInitializer : InstrumentationInitializer
1112
{
1213
public override Instrumentation Id { get; } = Instrumentation.SqlClient;
1314

15+
protected override void InitializeMetrics(MeterProviderBuilder builder)
16+
{
17+
builder.AddSqlClientInstrumentation();
18+
}
19+
1420
protected override void InitializeTracing(TracerProviderBuilder builder)
1521
{
1622
builder.AddSqlClientInstrumentation();

0 commit comments

Comments
 (0)