diff --git a/src/Speckle.Sdk.Dependencies/ISdkActivityFactory.cs b/src/Speckle.Sdk.Dependencies/ISdkActivityFactory.cs index ce69c387..927d0f70 100644 --- a/src/Speckle.Sdk.Dependencies/ISdkActivityFactory.cs +++ b/src/Speckle.Sdk.Dependencies/ISdkActivityFactory.cs @@ -1,17 +1,20 @@ using System.Runtime.CompilerServices; +using Speckle.Connectors.Logging; namespace Speckle.Sdk.Logging; public interface ISdkActivityFactory : IDisposable { - /// - /// - /// - ISdkActivity? Start(string? name = default, [CallerMemberName] string source = ""); + ISdkActivity? Start( + string? name = null, + SdkActivityKind kind = SdkActivityKind.Internal, + [CallerMemberName] string source = "" + ); + ISdkActivity? StartRemote( - string traceId, - string parentSpanId, - string? name = default, + string traceContext, + SdkActivityKind kind, + string? name = null, [CallerMemberName] string source = "" ); } diff --git a/src/Speckle.Sdk.Dependencies/SpeckleActivityKind.cs b/src/Speckle.Sdk.Dependencies/SpeckleActivityKind.cs new file mode 100644 index 00000000..8ca93543 --- /dev/null +++ b/src/Speckle.Sdk.Dependencies/SpeckleActivityKind.cs @@ -0,0 +1,30 @@ +namespace Speckle.Connectors.Logging; + +public enum SdkActivityKind +{ + /// + /// Default value. + /// Indicates that the Activity represents an internal operation within an application, as opposed to an operations with remote parents or children. + /// + Internal = 0, + + /// + /// Server activity represents request incoming from external component. + /// + Server = 1, + + /// + /// Client activity represents outgoing request to the external component. + /// + Client = 2, + + /// + /// Producer activity represents output provided to external components. + /// + Producer = 3, + + /// + /// Consumer activity represents output received from an external component. + /// + Consumer = 4, +} diff --git a/src/Speckle.Sdk/Logging/NullActivityFactory.cs b/src/Speckle.Sdk/Logging/NullActivityFactory.cs index e761a9bd..039f91b8 100644 --- a/src/Speckle.Sdk/Logging/NullActivityFactory.cs +++ b/src/Speckle.Sdk/Logging/NullActivityFactory.cs @@ -1,11 +1,12 @@ -namespace Speckle.Sdk.Logging; +using Speckle.Connectors.Logging; + +namespace Speckle.Sdk.Logging; public sealed class NullActivityFactory : ISdkActivityFactory { public void Dispose() { } - public ISdkActivity? Start(string? name = default, string source = "") => null; + public ISdkActivity? Start(string? name, SdkActivityKind kind, string source) => null; - public ISdkActivity? StartRemote(string traceId, string parentSpanId, string? name = default, string source = "") => - null; + public ISdkActivity? StartRemote(string traceContext, SdkActivityKind kind, string? name, string source) => null; } diff --git a/tests/Speckle.Sdk.Serialization.Tests/ServerObjectManagerTests.cs b/tests/Speckle.Sdk.Serialization.Tests/ServerObjectManagerTests.cs index c81e734e..90455343 100644 --- a/tests/Speckle.Sdk.Serialization.Tests/ServerObjectManagerTests.cs +++ b/tests/Speckle.Sdk.Serialization.Tests/ServerObjectManagerTests.cs @@ -52,7 +52,7 @@ public class ServerObjectManagerTests : MoqTest http.Setup(x => x.CreateHttpClient(It.IsAny(), timeout, token)).Returns(httpClient); var activityFactory = Create(); - activityFactory.Setup(x => x.Start(null, "DownloadObjects")).Returns((ISdkActivity?)null); + activityFactory.Setup(x => x.Start(null, default, "DownloadObjects")).Returns((ISdkActivity?)null); var serverObjectManager = new ServerObjectManager( http.Object, @@ -91,7 +91,7 @@ public class ServerObjectManagerTests : MoqTest http.Setup(x => x.CreateHttpClient(It.IsAny(), timeout, token)).Returns(httpClient); var activityFactory = Create(); - activityFactory.Setup(x => x.Start(null, "DownloadSingleObject")).Returns((ISdkActivity?)null); + activityFactory.Setup(x => x.Start(null, default, "DownloadSingleObject")).Returns((ISdkActivity?)null); var serverObjectManager = new ServerObjectManager( http.Object, @@ -132,7 +132,7 @@ public class ServerObjectManagerTests : MoqTest http.Setup(x => x.CreateHttpClient(It.IsAny(), timeout, token)).Returns(httpClient); var activityFactory = Create(); - activityFactory.Setup(x => x.Start(null, "HasObjects")).Returns((ISdkActivity?)null); + activityFactory.Setup(x => x.Start(null, default, "HasObjects")).Returns((ISdkActivity?)null); var serverObjectManager = new ServerObjectManager( http.Object, @@ -171,7 +171,7 @@ public class ServerObjectManagerTests : MoqTest http.Setup(x => x.CreateHttpClient(It.IsAny(), timeout, token)).Returns(httpClient); var activityFactory = Create(); - activityFactory.Setup(x => x.Start(null, "UploadObjects")).Returns((ISdkActivity?)null); + activityFactory.Setup(x => x.Start(null, default, "UploadObjects")).Returns((ISdkActivity?)null); var serverObjectManager = new ServerObjectManager( http.Object, diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/WorkspaceResourceTests.TestGetProjects.verified.json b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/WorkspaceResourceTests.TestGetProjects.verified.json deleted file mode 100644 index 781efcaf..00000000 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/WorkspaceResourceTests.TestGetProjects.verified.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Type": "AggregateException", - "InnerException": { - "Data": {}, - "Message": "FORBIDDEN: Your auth token does not have the required scope: workspace:read.", - "Type": "SpeckleGraphQLForbiddenException" - } -} diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/WorkspaceResourceTests.TestGetWorkspace.verified.json b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/WorkspaceResourceTests.TestGetWorkspace.verified.json deleted file mode 100644 index 781efcaf..00000000 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/WorkspaceResourceTests.TestGetWorkspace.verified.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Type": "AggregateException", - "InnerException": { - "Data": {}, - "Message": "FORBIDDEN: Your auth token does not have the required scope: workspace:read.", - "Type": "SpeckleGraphQLForbiddenException" - } -} diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/WorkspaceResourceTests.cs b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/WorkspaceResourceTests.cs index 8b73b43d..d597472d 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/WorkspaceResourceTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/WorkspaceResourceTests.cs @@ -25,13 +25,15 @@ public class WorkspaceResourceTests public async Task TestGetWorkspace() { var ex = await Assert.ThrowsAsync(async () => _ = await Sut.Get("non-existent-id")); - await Verify(ex); + Assert.Single(ex.InnerExceptions); + Assert.All(ex.InnerExceptions, item => Assert.IsType(item)); } [Fact] public async Task TestGetProjects() { var ex = await Assert.ThrowsAsync(async () => _ = await Sut.GetProjects("non-existent-id")); - await Verify(ex); + Assert.Single(ex.InnerExceptions); + Assert.All(ex.InnerExceptions, item => Assert.IsType(item)); } }