Skip to content

Commit 7402540

Browse files
committed
Add FbTelemetry public class with ActivitySource and Meter names
Expose the telemetry source names as public constants so consumers can easily subscribe: builder.AddSource(FbTelemetry.ActivitySourceName) and builder.AddMeter(FbTelemetry.MeterName). Internal code updated to use the constants.
1 parent 395a907 commit 7402540

3 files changed

Lines changed: 44 additions & 2 deletions

File tree

src/FirebirdSql.Data.FirebirdClient/Metrics/FbMetricsStore.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Linq;
66
using System.Reflection;
77
using FirebirdSql.Data.FirebirdClient;
8+
using FirebirdSql.Data.Trace;
89

910
namespace FirebirdSql.Data.Metrics
1011
{
@@ -17,7 +18,7 @@ internal static class FbMetricsStore
1718

1819
static readonly string Version = typeof(FbMetricsStore).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "0.0.0";
1920

20-
internal static readonly Meter Source = new("FirebirdSql.Data", Version);
21+
internal static readonly Meter Source = new(FbTelemetry.MeterName, Version);
2122

2223
static readonly Histogram<double> OperationDuration;
2324
static readonly Histogram<double> ConnectionCreateTime;

src/FirebirdSql.Data.FirebirdClient/Trace/FbActivitySource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal static class FbActivitySource
1313
{
1414
static readonly string Version = typeof(FbActivitySource).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "0.0.0";
1515

16-
internal static readonly ActivitySource Source = new("FirebirdSql.Data", Version);
16+
internal static readonly ActivitySource Source = new(FbTelemetry.ActivitySourceName, Version);
1717

1818
internal static Activity CommandStart(FbCommand command)
1919
{
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* The contents of this file are subject to the Initial
3+
* Developer's Public License Version 1.0 (the "License");
4+
* you may not use this file except in compliance with the
5+
* License. You may obtain a copy of the License at
6+
* https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.
7+
*
8+
* Software distributed under the License is distributed on
9+
* an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
10+
* express or implied. See the License for the specific
11+
* language governing rights and limitations under the License.
12+
*
13+
* All Rights Reserved.
14+
*/
15+
16+
namespace FirebirdSql.Data.FirebirdClient;
17+
18+
/// <summary>
19+
/// Provides the names of the ActivitySource and Meter used by the Firebird ADO.NET provider
20+
/// for OpenTelemetry integration.
21+
/// </summary>
22+
/// <remarks>
23+
/// To subscribe to Firebird traces, use:
24+
/// <code>builder.AddSource(FbTelemetry.ActivitySourceName)</code>
25+
/// To subscribe to Firebird metrics, use:
26+
/// <code>builder.AddMeter(FbTelemetry.MeterName)</code>
27+
/// </remarks>
28+
public static class FbTelemetry
29+
{
30+
/// <summary>
31+
/// The name of the <see cref="System.Diagnostics.ActivitySource"/> used for distributed tracing.
32+
/// Use with <c>TracerProviderBuilder.AddSource()</c>.
33+
/// </summary>
34+
public const string ActivitySourceName = "FirebirdSql.Data";
35+
36+
/// <summary>
37+
/// The name of the <see cref="System.Diagnostics.Metrics.Meter"/> used for metrics.
38+
/// Use with <c>MeterProviderBuilder.AddMeter()</c>.
39+
/// </summary>
40+
public const string MeterName = "FirebirdSql.Data";
41+
}

0 commit comments

Comments
 (0)