Skip to content

Commit 01fe660

Browse files
Kielekalanwest
andauthored
[Instrumentation.SqlClient] Metrics documentation (open-telemetry#2404)
Co-authored-by: Alan West <[email protected]>
1 parent ce419ab commit 01fe660

File tree

2 files changed

+45
-6
lines changed
  • src
    • OpenTelemetry.Instrumentation.AspNet
    • OpenTelemetry.Instrumentation.SqlClient

2 files changed

+45
-6
lines changed

src/OpenTelemetry.Instrumentation.AspNet/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public class WebApiApplication : HttpApplication
127127
#### List of metrics produced
128128

129129
The instrumentation is implemented based on [metrics semantic
130-
conventions](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/http-metrics.md#metric-httpserverduration).
130+
conventions](https://github.com/open-telemetry/semantic-conventions/blob/v1.29.0/docs/http/http-metrics.md#metric-httpserverrequestduration).
131131
Currently, the instrumentation supports the following metric.
132132

133133
| Name | Instrument Type | Unit | Description |

src/OpenTelemetry.Instrumentation.SqlClient/README.md

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ dotnet add package --prerelease OpenTelemetry.Instrumentation.SqlClient
4949

5050
SqlClient instrumentation must be enabled at application startup.
5151

52-
The following example demonstrates adding SqlClient instrumentation to a console
53-
application. This example also sets up the OpenTelemetry Console exporter, which
54-
requires adding the package
55-
[`OpenTelemetry.Exporter.Console`](../OpenTelemetry.Exporter.Console/README.md)
52+
#### Traces
53+
54+
The following example demonstrates adding SqlClient traces instrumentation
55+
to a console application. This example also sets up the OpenTelemetry Console
56+
exporter, which requires adding the package
57+
[`OpenTelemetry.Exporter.Console`](https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry.Exporter.Console/README.md)
5658
to the application.
5759

5860
```csharp
@@ -70,13 +72,50 @@ public class Program
7072
}
7173
```
7274

75+
#### Metrics
76+
77+
The following example demonstrates adding SqlClient metrics instrumentation
78+
to a console application. This example also sets up the OpenTelemetry Console
79+
exporter, which requires adding the package
80+
[`OpenTelemetry.Exporter.Console`](https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry.Exporter.Console/README.md)
81+
to the application.
82+
83+
```csharp
84+
using OpenTelemetry.Metrics;
85+
86+
public class Program
87+
{
88+
public static void Main(string[] args)
89+
{
90+
using var tracerProvider = Sdk.CreateMeterProviderBuilder()
91+
.AddSqlClientInstrumentation()
92+
.AddConsoleExporter()
93+
.Build();
94+
}
95+
}
96+
```
97+
98+
##### List of metrics produced
99+
100+
The instrumentation is implemented based on [metrics semantic
101+
conventions](https://github.com/open-telemetry/semantic-conventions/blob/v1.29.0/docs/database/database-metrics.md#database-operation).
102+
Currently, the instrumentation supports the following metric.
103+
104+
| Name | Instrument Type | Unit | Description |
105+
|-------|-----------------|------|-------------|
106+
| `db.client.operation.duration` | Histogram | `s` | Duration of database client operations. |
107+
108+
#### ASP.NET Core
109+
73110
For an ASP.NET Core application, adding instrumentation is typically done in the
74111
`ConfigureServices` of your `Startup` class. Refer to documentation for
75112
[OpenTelemetry.Instrumentation.AspNetCore](../OpenTelemetry.Instrumentation.AspNetCore/README.md).
76113

114+
#### ASP.NET
115+
77116
For an ASP.NET application, adding instrumentation is typically done in the
78117
`Global.asax.cs`. Refer to the documentation for
79-
[OpenTelemetry.Instrumentation.AspNet](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/main/src/OpenTelemetry.Instrumentation.AspNet/README.md).
118+
[OpenTelemetry.Instrumentation.AspNet](../OpenTelemetry.Instrumentation.AspNet/README.md).
80119

81120
## Advanced configuration
82121

0 commit comments

Comments
 (0)