Skip to content

Commit f68747f

Browse files
committed
Add server.port, db.stored_procedure.name; fix server.address in metrics
- Set server.port on spans when using a non-default port - Set db.stored_procedure.name for StoredProcedure command types - Fix server.address in MetricsConnectionAttributes to not concatenate the port (server.port is now a separate attribute) - Clean up leftover placeholder comments
1 parent 594a23b commit f68747f

2 files changed

Lines changed: 13 additions & 16 deletions

File tree

src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbConnection.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ public override string ConnectionString
196196
MetricsConnectionAttributes = [
197197
new("db.system.name", "firebirdsql"),
198198
new("db.namespace", _options.Database),
199-
new("server.address", $"{_options.DataSource}:{_options.Port}")
199+
new("server.address", _options.DataSource),
200+
new("server.port", _options.Port),
200201
];
201202
}
202203
}

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

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Data;
44
using System.Diagnostics;
55
using System.Reflection;
6+
using FirebirdSql.Data.Common;
67
using FirebirdSql.Data.FirebirdClient;
78
using FirebirdSql.Data.Logging;
89

@@ -16,7 +17,6 @@ internal static class FbActivitySource
1617

1718
internal static Activity CommandStart(FbCommand command)
1819
{
19-
// Reference: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/database/database-spans.md
2020
var dbName = command.Connection.Database;
2121

2222
string dbOperationName = null;
@@ -55,7 +55,6 @@ internal static Activity CommandStart(FbCommand command)
5555
activity.SetTag("db.collection.name", dbCollectionName);
5656
}
5757

58-
// db.namespace
5958
if (dbName != null)
6059
{
6160
activity.SetTag("db.namespace", dbName);
@@ -66,30 +65,27 @@ internal static Activity CommandStart(FbCommand command)
6665
activity.SetTag("db.operation.name", dbOperationName);
6766
}
6867

69-
// db.response.status_code
70-
71-
// error.type (handled by RecordException)
72-
73-
// server.port
74-
75-
// db.operation.batch.size
76-
77-
// db.query_summary
68+
if (command.CommandType == CommandType.StoredProcedure)
69+
{
70+
activity.SetTag("db.stored_procedure.name", command.CommandText);
71+
}
7872

7973
if (FbLogManager.IsQueryTextTracingEnabled)
8074
{
8175
activity.SetTag("db.query.text", command.CommandText);
8276
}
8377

84-
// network.peer.address
85-
86-
// network.peer.port
87-
8878
if (command.Connection.DataSource != null)
8979
{
9080
activity.SetTag("server.address", command.Connection.DataSource);
9181
}
9282

83+
var port = command.Connection.ConnectionOptions.Port;
84+
if (port != ConnectionString.DefaultValuePortNumber)
85+
{
86+
activity.SetTag("server.port", port);
87+
}
88+
9389
if (FbLogManager.IsParameterLoggingEnabled)
9490
{
9591
foreach (FbParameter p in command.Parameters)

0 commit comments

Comments
 (0)