From c0e356c2475815867c329d1fe8d176f9fba0aa40 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Mon, 19 Aug 2024 15:52:18 +0100 Subject: [PATCH 1/2] otel v2 --- Core/Core/Api/Operations/Operations.Send.cs | 2 ++ Core/Core/Core.csproj | 1 + Core/Core/Logging/Setup.cs | 2 ++ Core/Core/Serialisation/BaseObjectDeserializerV2.cs | 3 +++ Core/Core/Transports/SQLite.cs | 6 ++++-- Core/Core/Transports/ServerUtils/ParallelServerAPI.cs | 2 ++ 6 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Core/Core/Api/Operations/Operations.Send.cs b/Core/Core/Api/Operations/Operations.Send.cs index da01128a02..6e02aeb0c0 100644 --- a/Core/Core/Api/Operations/Operations.Send.cs +++ b/Core/Core/Api/Operations/Operations.Send.cs @@ -11,6 +11,7 @@ using Speckle.Core.Serialisation; using Speckle.Core.Transports; using Speckle.Newtonsoft.Json.Linq; +using SpeckleActivityFactory = Speckle.Sdk.Logging.SpeckleActivityFactory; namespace Speckle.Core.Api; @@ -154,6 +155,7 @@ internal static async Task SerializerSend( CancellationToken cancellationToken = default ) { + using var activity = SpeckleActivityFactory.Start(); string obj = serializer.Serialize(value); Task[] transportAwaits = serializer.WriteTransports.Select(t => t.WriteComplete()).ToArray(); diff --git a/Core/Core/Core.csproj b/Core/Core/Core.csproj index fac2359928..9eb1ab8514 100644 --- a/Core/Core/Core.csproj +++ b/Core/Core/Core.csproj @@ -56,6 +56,7 @@ + diff --git a/Core/Core/Logging/Setup.cs b/Core/Core/Logging/Setup.cs index 3c40989651..16924fce53 100644 --- a/Core/Core/Logging/Setup.cs +++ b/Core/Core/Logging/Setup.cs @@ -5,6 +5,7 @@ using System.Threading; using Speckle.Core.Credentials; using Speckle.Core.Kits; +using Speckle.Sdk.Logging; namespace Speckle.Core.Logging; @@ -80,6 +81,7 @@ public static void Init( Analytics.AddConnectorToProfile(account.GetHashedEmail(), hostApplication); Analytics.IdentifyProfile(account.GetHashedEmail(), hostApplication); } + LogBuilder.Initialize("Otel-Testing", versionedHostApplication, "revit", null, new SpeckleTracing(true)); } [Obsolete("Use " + nameof(Mutex))] diff --git a/Core/Core/Serialisation/BaseObjectDeserializerV2.cs b/Core/Core/Serialisation/BaseObjectDeserializerV2.cs index 908a4b1f99..c77dfa0e8d 100644 --- a/Core/Core/Serialisation/BaseObjectDeserializerV2.cs +++ b/Core/Core/Serialisation/BaseObjectDeserializerV2.cs @@ -11,6 +11,7 @@ using Speckle.Core.Transports; using Speckle.Newtonsoft.Json; using Speckle.Newtonsoft.Json.Linq; +using SpeckleActivityFactory = Speckle.Sdk.Logging.SpeckleActivityFactory; namespace Speckle.Core.Serialisation; @@ -52,6 +53,7 @@ public sealed class BaseObjectDeserializerV2 // /// did not contain the required json objects (closures) public Base Deserialize(string rootObjectJson) { + using var activity = SpeckleActivityFactory.Start(); if (_isBusy) { throw new InvalidOperationException( @@ -163,6 +165,7 @@ public Base Deserialize(string rootObjectJson) /// Failed to deserialize to the target type public object? DeserializeTransportObject(string objectJson) { + using var activity = SpeckleActivityFactory.Start(); if (objectJson is null) { throw new ArgumentNullException(nameof(objectJson), $"Cannot deserialize {nameof(objectJson)}, value was null"); diff --git a/Core/Core/Transports/SQLite.cs b/Core/Core/Transports/SQLite.cs index 5b3f4f9b72..d4e8a8e65f 100644 --- a/Core/Core/Transports/SQLite.cs +++ b/Core/Core/Transports/SQLite.cs @@ -9,9 +9,10 @@ using System.Threading.Tasks; using System.Timers; using Microsoft.Data.Sqlite; -using Speckle.Core.Helpers; using Speckle.Core.Logging; using Speckle.Core.Models; +using Speckle.Sdk.Logging; +using SpecklePathProvider = Speckle.Core.Helpers.SpecklePathProvider; using Timer = System.Timers.Timer; namespace Speckle.Core.Transports; @@ -33,7 +34,7 @@ public sealed class SQLiteTransport : IDisposable, ICloneable, ITransport, IBlob /// Connects to an SQLite DB at {}/{}/{}.db /// Will attempt to create db + directory structure as needed /// - /// defaults to if + /// defaults to if /// defaults to "Speckle" if /// defaults to "Data" if /// Failed to initialize a connection to the db @@ -318,6 +319,7 @@ private void ConsumeQueue() using (var c = new SqliteConnection(_connectionString)) { + using var activity = SpeckleActivityFactory.Start("Consume"); c.Open(); using var t = c.BeginTransaction(); const string COMMAND_TEXT = "INSERT OR IGNORE INTO objects(hash, content) VALUES(@hash, @content)"; diff --git a/Core/Core/Transports/ServerUtils/ParallelServerAPI.cs b/Core/Core/Transports/ServerUtils/ParallelServerAPI.cs index 0bad69cde2..d1b19dc5d6 100644 --- a/Core/Core/Transports/ServerUtils/ParallelServerAPI.cs +++ b/Core/Core/Transports/ServerUtils/ParallelServerAPI.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Speckle.Core.Logging; using Speckle.Core.Serialisation.SerializationUtilities; +using Speckle.Sdk.Logging; namespace Speckle.Core.Transports.ServerUtils; @@ -142,6 +143,7 @@ CbObjectDownloaded onObjectCallback public async Task UploadObjects(string streamId, IReadOnlyList<(string, string)> objects) { + using var activity = SpeckleActivityFactory.Start(); EnsureStarted(); List> tasks = new(); IReadOnlyList> splitObjects; From dc1532e469aef9c083958303881fa67e53f131cc Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Mon, 19 Aug 2024 16:18:18 +0100 Subject: [PATCH 2/2] log ray output --- Core/Core/Transports/ServerUtils/ServerAPI.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Core/Core/Transports/ServerUtils/ServerAPI.cs b/Core/Core/Transports/ServerUtils/ServerAPI.cs index 09912368cf..43bd380edb 100644 --- a/Core/Core/Transports/ServerUtils/ServerAPI.cs +++ b/Core/Core/Transports/ServerUtils/ServerAPI.cs @@ -417,6 +417,10 @@ private async Task UploadObjectsImpl(string streamId, List