Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Otel v2 #3616

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Otel v2 #3616

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Core/Core/Api/Operations/Operations.Send.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -154,6 +155,7 @@ internal static async Task<string> SerializerSend(
CancellationToken cancellationToken = default
)
{
using var activity = SpeckleActivityFactory.Start();
string obj = serializer.Serialize(value);
Task[] transportAwaits = serializer.WriteTransports.Select(t => t.WriteComplete()).ToArray();

Expand Down
1 change: 1 addition & 0 deletions Core/Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<PackageReference Include="Serilog.Sinks.Seq" Version="5.2.2" />
<PackageReference Include="SerilogTimings" Version="3.0.1" />
<PackageReference Include="Speckle.Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Speckle.Sdk.Logging" Version="3.1.0-dev.110" />
<PackageReference Include="System.DoubleNumerics" Version="3.1.3" />
<PackageReference Include="System.Text.Json" Version="5.0.2" /> <!-- research has found this is the least offensive version -->
</ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions Core/Core/Logging/Setup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading;
using Speckle.Core.Credentials;
using Speckle.Core.Kits;
using Speckle.Sdk.Logging;

namespace Speckle.Core.Logging;

Expand Down Expand Up @@ -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))]
Expand Down
3 changes: 3 additions & 0 deletions Core/Core/Serialisation/BaseObjectDeserializerV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -52,6 +53,7 @@ public sealed class BaseObjectDeserializerV2
// /// <exception cref="TransportException"><see cref="ReadTransport"/> did not contain the required json objects (closures)</exception>
public Base Deserialize(string rootObjectJson)
{
using var activity = SpeckleActivityFactory.Start();
if (_isBusy)
{
throw new InvalidOperationException(
Expand Down Expand Up @@ -163,6 +165,7 @@ public Base Deserialize(string rootObjectJson)
/// <exception cref="SpeckleDeserializeException">Failed to deserialize <see cref="JObject"/> to the target type</exception>
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");
Expand Down
6 changes: 4 additions & 2 deletions Core/Core/Transports/SQLite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,7 +34,7 @@ public sealed class SQLiteTransport : IDisposable, ICloneable, ITransport, IBlob
/// Connects to an SQLite DB at {<paramref name="basePath"/>}/{<paramref name="applicationName"/>}/{<paramref name="scope"/>}.db
/// Will attempt to create db + directory structure as needed
/// </summary>
/// <param name="basePath">defaults to <see cref="SpecklePathProvider.UserApplicationDataPath"/> if <see langword="null"/></param>
/// <param name="basePath">defaults to <see cref="Helpers.SpecklePathProvider.UserApplicationDataPath"/> if <see langword="null"/></param>
/// <param name="applicationName">defaults to <c>"Speckle"</c> if <see langword="null"/></param>
/// <param name="scope">defaults to <c>"Data"</c> if <see langword="null"/></param>
/// <exception cref="SqliteException">Failed to initialize a connection to the db</exception>
Expand Down Expand Up @@ -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)";
Expand Down
2 changes: 2 additions & 0 deletions Core/Core/Transports/ServerUtils/ParallelServerAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -142,6 +143,7 @@ CbObjectDownloaded onObjectCallback

public async Task UploadObjects(string streamId, IReadOnlyList<(string, string)> objects)
{
using var activity = SpeckleActivityFactory.Start();
EnsureStarted();
List<Task<object?>> tasks = new();
IReadOnlyList<IReadOnlyList<(string, string)>> splitObjects;
Expand Down
4 changes: 4 additions & 0 deletions Core/Core/Transports/ServerUtils/ServerAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,10 @@ private async Task UploadObjectsImpl(string streamId, List<List<(string, string)
}
message.Content = multipart;
HttpResponseMessage response = await _client.SendAsync(message, CancellationToken).ConfigureAwait(false);
if (response.Headers.TryGetValues("cf-ray", out var rayValues))
{
SpeckleLog.Logger.Information("Received Speckle API response with CF Ray {rayId}", string.Join(";", rayValues));
}

response.EnsureSuccessStatusCode();

Expand Down