diff --git a/packages/http-client-csharp/emitter/src/options.ts b/packages/http-client-csharp/emitter/src/options.ts index 42196440cac..8296b796755 100644 --- a/packages/http-client-csharp/emitter/src/options.ts +++ b/packages/http-client-csharp/emitter/src/options.ts @@ -24,6 +24,7 @@ export interface CSharpEmitterOptions { "sdk-context-options"?: CreateSdkContextOptions; "generate-protocol-methods"?: boolean; "generate-convenience-methods"?: boolean; + "generate-method-instrumentation"?: boolean; "package-name"?: string; license?: { name: string; @@ -61,6 +62,12 @@ export const CSharpEmitterOptionsSchema: JSONSchemaType = description: "Set to `false` to skip generation of convenience methods. The default value is `true`.", }, + "generate-method-instrumentation": { + type: "boolean", + nullable: true, + description: + "Set to `false` to disable generation of ActivitySource-based distributed tracing instrumentation in client methods. The default value is `true`.", + }, "unreferenced-types-handling": { type: "string", enum: ["removeOrInternalize", "internalize", "keepAll"], @@ -156,6 +163,7 @@ export const defaultOptions = { "save-inputs": false, "generate-protocol-methods": true, "generate-convenience-methods": true, + "generate-method-instrumentation": true, "package-name": undefined, debug: undefined, logLevel: LoggerLevel.INFO, diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ClientProvider.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ClientProvider.cs index 606a888af4c..9c0e5cdb15e 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ClientProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ClientProvider.cs @@ -4,6 +4,7 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using System.Threading; @@ -59,6 +60,7 @@ private record ApiVersionFields(FieldProvider Field, PropertyProvider? Correspon private Dictionary? _methodCache; private Dictionary MethodCache => _methodCache ??= []; private TypeProvider? _backCompatProvider; + private FieldProvider? _activitySourceField; /// /// Gets the effective type provider to use for backward compatibility checks. @@ -366,6 +368,22 @@ private IReadOnlyList GetClientParameters() public PropertyProvider PipelineProperty { get; } public FieldProvider EndpointField { get; } + /// + /// Gets the ActivitySource field used for distributed tracing instrumentation. + /// Returns null if method instrumentation is disabled. + /// + internal FieldProvider? ActivitySourceField => ScmCodeModelGenerator.Instance.Configuration.GenerateMethodInstrumentation + ? _activitySourceField ??= BuildActivitySourceField() + : null; + + private FieldProvider BuildActivitySourceField() + => new FieldProvider( + FieldModifiers.Private | FieldModifiers.Static | FieldModifiers.ReadOnly, + typeof(ActivitySource), + "_activitySource", + this, + initializationValue: New.Instance(typeof(ActivitySource), Literal(ScmCodeModelGenerator.Instance.Configuration.PackageName))); + public IReadOnlyList SubClients => _subClients.Value; protected override string BuildRelativeFilePath() => Path.Combine("src", "Generated", $"{Name}.cs"); @@ -376,6 +394,12 @@ protected override FieldProvider[] BuildFields() { List fields = [EndpointField]; + // Add ActivitySource field for distributed tracing instrumentation (only for root clients) + if (ActivitySourceField != null) + { + fields.Add(ActivitySourceField); + } + if (_apiKeyAuthFields != null) { fields.Add(_apiKeyAuthFields.AuthField); diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/CollectionResultDefinition.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/CollectionResultDefinition.cs index d704c3eec74..5ff2dd79808 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/CollectionResultDefinition.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/CollectionResultDefinition.cs @@ -5,6 +5,7 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using System.Threading.Tasks; @@ -27,6 +28,9 @@ public class CollectionResultDefinition : TypeProvider protected bool IsAsync { get; } protected ClientProvider Client { get; } protected FieldProvider ClientField { get; } + protected FieldProvider? ActivitySourceField { get; } + private string? _executePageRequestMethodName; + private string ExecutePageRequestMethodName => _executePageRequestMethodName ??= IsAsync ? "ExecutePageRequestAsync" : "ExecutePageRequest"; protected InputOperation Operation { get; } protected InputPagingServiceMetadata Paging { get; } @@ -73,6 +77,16 @@ public CollectionResultDefinition(ClientProvider client, InputPagingServiceMetho Client.Type, "_client", this); + + if (Client.ActivitySourceField != null) + { + ActivitySourceField = new FieldProvider( + FieldModifiers.Private | FieldModifiers.ReadOnly, + new CSharpType(typeof(ActivitySource), isNullable: true), + "_activitySource", + this); + } + Operation = serviceMethod.Operation; Paging = serviceMethod.PagingMetadata; IsAsync = isAsync; @@ -187,7 +201,10 @@ protected override string BuildName() protected override TypeSignatureModifiers BuildDeclarationModifiers() => TypeSignatureModifiers.Internal | TypeSignatureModifiers.Partial | TypeSignatureModifiers.Class; - protected override FieldProvider[] BuildFields() => [ClientField, .. RequestFields]; + protected override FieldProvider[] BuildFields() + => ActivitySourceField != null + ? [ClientField, ActivitySourceField, .. RequestFields] + : [ClientField, .. RequestFields]; protected override CSharpType[] BuildImplements() => (_modelType: ItemModelType, IsAsync) switch @@ -204,6 +221,18 @@ protected override ConstructorProvider[] BuildConstructors() "client", $"The {Client.Type.Name} client used to send requests.", Client.Type); + var parameters = new List { clientParameter }; + parameters.AddRange(CreateRequestParameters); + ParameterProvider? activitySourceParameter = null; + if (ActivitySourceField != null) + { + activitySourceParameter = new ParameterProvider( + "activitySource", + $"The activity source for distributed tracing.", + new CSharpType(typeof(ActivitySource), isNullable: true), + defaultValue: Null); + parameters.Add(activitySourceParameter); + } return [ new ConstructorProvider( @@ -211,11 +240,8 @@ protected override ConstructorProvider[] BuildConstructors() Type, $"Initializes a new instance of {Name}, which is used to iterate over the pages of a collection.", MethodSignatureModifiers.Public, - [ - clientParameter, - .. CreateRequestParameters - ]), - BuildConstructorBody(clientParameter), + parameters), + BuildConstructorBody(clientParameter, activitySourceParameter), this) ]; } @@ -230,7 +256,7 @@ protected ValueExpression BuildGetPropertyExpression(IReadOnlyList segme return ResponseModel.GetPropertyExpression(responseModel, segments); } - private MethodBodyStatement[] BuildConstructorBody(ParameterProvider clientParameter) + private MethodBodyStatement[] BuildConstructorBody(ParameterProvider clientParameter, ParameterProvider? activitySourceParameter) { var statements = new List(CreateRequestParameters.Count + 1); @@ -242,6 +268,12 @@ private MethodBodyStatement[] BuildConstructorBody(ParameterProvider clientParam var field = RequestFields[parameterNumber]; statements.Add(field.Assign(parameter).Terminate()); } + + if (ActivitySourceField != null && activitySourceParameter != null) + { + statements.Add(ActivitySourceField.Assign(activitySourceParameter).Terminate()); + } + return statements.ToArray(); } @@ -284,6 +316,11 @@ protected override MethodProvider[] BuildMethods() this) }; + if (ActivitySourceField != null) + { + methods.Add(BuildExecutePageRequestMethod()); + } + if (ItemModelType != null) { methods.Add(new MethodProvider( @@ -304,6 +341,45 @@ protected override MethodProvider[] BuildMethods() return methods.ToArray(); } + private MethodProvider BuildExecutePageRequestMethod() + { + var messageParam = new ParameterProvider("message", $"The pipeline message.", new CSharpType(typeof(PipelineMessage))); + string activityName = $"{Client.Name}.{Operation.Name.ToIdentifierName()}"; + CSharpType returnType = IsAsync + ? new CSharpType(typeof(Task<>), typeof(ClientResult)) + : new CSharpType(typeof(ClientResult)); + MethodSignatureModifiers modifiers = IsAsync + ? MethodSignatureModifiers.Private | MethodSignatureModifiers.Async + : MethodSignatureModifiers.Private; + + // using Activity? activity = _activitySource?.StartActivity("...", ActivityKind.Client); + var activityDecl = UsingDeclare( + "activity", + new CSharpType(typeof(Activity), isNullable: true), + ActivitySourceField!.AsValueExpression.NullConditional().Invoke( + nameof(ActivitySource.StartActivity), + [Literal(activityName), FrameworkEnumValue(ActivityKind.Client)]), + out var activityVar); + + // try { return ...; } catch (Exception ex) { activity?.SetStatus(ActivityStatusCode.Error, ex.Message); throw; } + var pipelineResponse = ScmCodeModelGenerator.Instance.TypeFactory.ClientResponseApi.ToExpression().FromResponse( + ClientField.Property("Pipeline").ToApi().ProcessMessage( + messageParam.ToApi(), + RequestOptionsField.AsValueExpression.ToApi(), + IsAsync)).ToApi(); + var exDecl = new DeclarationExpression(typeof(Exception), "ex", out var exVar); + var catchBlock = new CatchExpression(exDecl, + activityVar.NullConditional().Invoke(nameof(Activity.SetStatus), + [FrameworkEnumValue(ActivityStatusCode.Error), exVar.Property(nameof(Exception.Message))]).Terminate(), + Throw()); + + MethodBodyStatement[] body = [activityDecl, new TryCatchFinallyStatement(new TryExpression(Return(pipelineResponse)), catchBlock)]; + return new MethodProvider( + new MethodSignature(ExecutePageRequestMethodName, null, modifiers, returnType, null, [messageParam]), + body, + this); + } + private MethodBodyStatement[] BuildGetValuesFromPages() { var items = GetPropertyExpression(Paging.ItemPropertySegments, PageParameter.AsVariable()); @@ -380,6 +456,19 @@ private MethodBodyStatement[] BuildGetContinuationToken() } } + private ClientResponseApi InvokePageRequest(ScopedApi message) + { + if (ActivitySourceField != null) + { + return This.Invoke(ExecutePageRequestMethodName, [message], IsAsync).ToApi(); + } + return ScmCodeModelGenerator.Instance.TypeFactory.ClientResponseApi.ToExpression().FromResponse( + ClientField.Property("Pipeline").ToApi().ProcessMessage( + message.ToApi(), + RequestOptionsField.AsValueExpression.ToApi(), + IsAsync)).ToApi(); + } + private MethodBodyStatement[] BuildGetRawPagesForNextLink() { var nextPageVariable = new VariableExpression(typeof(Uri), "nextPageUri"); @@ -399,11 +488,7 @@ private MethodBodyStatement[] BuildGetRawPagesForNextLink() { Declare( "result", - ScmCodeModelGenerator.Instance.TypeFactory.ClientResponseApi.ToExpression().FromResponse( - ClientField.Property("Pipeline").ToApi().ProcessMessage( - message.ToApi(), - RequestOptionsField.AsValueExpression.ToApi(), - IsAsync)).ToApi(), + InvokePageRequest(message), out ClientResponseApi result), // Yield return result @@ -438,11 +523,7 @@ private MethodBodyStatement[] BuildGetRawPagesForContinuationToken() { Declare( "result", - ScmCodeModelGenerator.Instance.TypeFactory.ClientResponseApi.ToExpression().FromResponse( - ClientField.Property("Pipeline").ToApi().ProcessMessage( - message.ToApi(), - RequestOptionsField.AsValueExpression.ToApi(), - IsAsync)).ToApi(), + InvokePageRequest(message), out ClientResponseApi result), // Yield return result @@ -464,16 +545,12 @@ private MethodBodyStatement[] BuildGetRawPagesForSingle() "message", InvokeCreateInitialRequest(), out ScopedApi m); - var pipelineResponse = ScmCodeModelGenerator.Instance.TypeFactory.ClientResponseApi.ToExpression().FromResponse( - ClientField.Property("Pipeline").ToApi().ProcessMessage( - m.ToApi(), - RequestOptionsField.AsValueExpression.ToApi(), - IsAsync)).ToApi(); + var pageRequestResult = InvokePageRequest(m); return [ pipelineMessageDeclaration, // Yield return result - YieldReturn(pipelineResponse), + YieldReturn(pageRequestResult), ]; } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ScmMethodProviderCollection.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ScmMethodProviderCollection.cs index 6879f6c7b7f..1db3ff55207 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ScmMethodProviderCollection.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ScmMethodProviderCollection.cs @@ -5,6 +5,7 @@ using System.ClientModel.Primitives; using System.Collections; using System.Collections.Generic; +using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; @@ -128,7 +129,10 @@ private ScmMethodProvider BuildConvenienceMethod(MethodProvider protocolMethod, if (_pagingServiceMethod != null) { collection = ScmCodeModelGenerator.Instance.TypeFactory.ClientResponseApi.CreateClientCollectionResultDefinition(Client, _pagingServiceMethod, responseBodyType, isAsync); - methodBody = [.. GetPagingMethodBody(collection, ConvenienceMethodParameters, true)]; + // Pass the ActivitySource to the collection so each page request can start its own activity. + // No activity is started here - tracing is per-page in the collection's ExecutePageRequest helper. + ValueExpression? activitySourceExpr = Client.ActivitySourceField?.AsValueExpression; + methodBody = [.. GetPagingMethodBody(collection, ConvenienceMethodParameters, true, activitySourceExpr)]; } else if (responseBodyType is null) { @@ -165,6 +169,25 @@ .. GetStackVariablesForReturnValueConversion(result, responseBodyType, isAsync, ]; } + // Prepend activity instrumentation statement if enabled (non-paging methods only; + // paging methods start a new activity per page request in ExecutePageRequest/ExecutePageRequestAsync) + if (Client.ActivitySourceField != null && _pagingServiceMethod == null) + { + var activityStatement = UsingDeclare( + "activity", + new CSharpType(typeof(Activity), isNullable: true), + Client.ActivitySourceField.Invoke( + nameof(ActivitySource.StartActivity), + [Literal($"{Client.Name}.{ServiceMethod.Name}"), FrameworkEnumValue(ActivityKind.Client)]), + out var activityVar); + var exceptionDeclaration = new DeclarationExpression(typeof(Exception), "ex", out var exVar); + var catchBlock = new CatchExpression(exceptionDeclaration, + activityVar.NullConditional().Invoke(nameof(Activity.SetStatus), + [FrameworkEnumValue(ActivityStatusCode.Error), exVar.Property(nameof(Exception.Message))]).Terminate(), + Throw()); + methodBody = [activityStatement, new TryCatchFinallyStatement(new TryExpression(methodBody), catchBlock)]; + } + var convenienceMethod = new ScmMethodProvider(methodSignature, methodBody, EnclosingType, ScmMethodKind.Convenience, collectionDefinition: collection, serviceMethod: ServiceMethod); if (convenienceMethod.XmlDocs != null) @@ -999,20 +1022,19 @@ private ParameterProvider ProcessOptionalParameters( private IEnumerable GetPagingMethodBody( TypeProvider collection, IReadOnlyList parameters, - bool isConvenience) + bool isConvenience, + ValueExpression? activityVar = null) { if (isConvenience) { - return - [ - .. GetStackVariablesForProtocolParamConversion(ConvenienceMethodParameters, out var declarations), - Return(New.Instance( - collection.Type, - [ - This, - .. GetProtocolMethodArguments(declarations) - ])) - ]; + var stackStatements = GetStackVariablesForProtocolParamConversion(ConvenienceMethodParameters, out var declarations).ToArray(); + var constructorArgs = new List { This }; + constructorArgs.AddRange(GetProtocolMethodArguments(declarations)); + if (activityVar != null) + { + constructorArgs.Add(activityVar); + } + return [.. stackStatements, Return(New.Instance(collection.Type, [.. constructorArgs]))]; } return Return(New.Instance( diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ScmMethodProviderCollectionTests.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ScmMethodProviderCollectionTests.cs index b54ece36bd0..d93d53ff423 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ScmMethodProviderCollectionTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ScmMethodProviderCollectionTests.cs @@ -1996,5 +1996,183 @@ public void ConvenienceMethod_JsonListBody_DoesNotUseXmlFromEnumerable() Assert.IsFalse(methodBody.Contains("rootNameHint")); Assert.IsFalse(methodBody.Contains("childNameHint")); } + + [Test] + public void TracingIsAddedToConvenienceMethod() + { + var inputOperation = InputFactory.Operation("TestOperation"); + var inputServiceMethod = InputFactory.BasicServiceMethod("TestOperation", inputOperation); + var inputClient = InputFactory.Client("TestClient", methods: [inputServiceMethod]); + + MockHelpers.LoadMockGenerator(clients: () => [inputClient], enableMethodInstrumentation: true); + + var client = ScmCodeModelGenerator.Instance.TypeFactory.CreateClient(inputClient); + Assert.IsNotNull(client); + + // Root client has ActivitySourceField + Assert.IsNotNull(client!.ActivitySourceField); + + var methodCollection = new ScmMethodProviderCollection(inputServiceMethod, client); + var convenienceMethod = methodCollection.FirstOrDefault( + m => !m.Signature.Parameters.Any(p => p.Name == "options") && m.Signature.Name == "TestOperation"); + Assert.IsNotNull(convenienceMethod); + + var methodBody = convenienceMethod!.BodyStatements!.ToDisplayString(); + // Verify activity is started with the correct name + StringAssert.Contains("_activitySource.StartActivity(\"TestClient.TestOperation\"", methodBody); + // Verify it uses `using` so it's disposed when the method returns + StringAssert.Contains("using global::System.Diagnostics.Activity activity", methodBody); + // Verify exception tracking: catch block sets error status before rethrowing + StringAssert.Contains("catch", methodBody); + StringAssert.Contains("SetStatus", methodBody); + StringAssert.Contains("ActivityStatusCode.Error", methodBody); + } + + [Test] + public void TracingIsNotAddedToConvenienceMethodWhenDisabled() + { + var inputOperation = InputFactory.Operation("TestOperation"); + var inputServiceMethod = InputFactory.BasicServiceMethod("TestOperation", inputOperation); + var inputClient = InputFactory.Client("TestClient", methods: [inputServiceMethod]); + + MockHelpers.LoadMockGenerator(clients: () => [inputClient]); + + var client = ScmCodeModelGenerator.Instance.TypeFactory.CreateClient(inputClient); + Assert.IsNotNull(client); + Assert.IsNull(client!.ActivitySourceField); + + var methodCollection = new ScmMethodProviderCollection(inputServiceMethod, client); + var convenienceMethod = methodCollection.FirstOrDefault( + m => !m.Signature.Parameters.Any(p => p.Name == "options") && m.Signature.Name == "TestOperation"); + Assert.IsNotNull(convenienceMethod); + + var methodBody = convenienceMethod!.BodyStatements!.ToDisplayString(); + StringAssert.DoesNotContain("StartActivity", methodBody); + } + + [Test] + public void TracingIsAddedToSubClientConvenienceMethod() + { + var inputOperation = InputFactory.Operation("SubOperation"); + var inputServiceMethod = InputFactory.BasicServiceMethod("SubOperation", inputOperation); + var parentClient = InputFactory.Client("ParentClient"); + var subClient = InputFactory.Client("SubClient", methods: [inputServiceMethod], parent: parentClient); + + MockHelpers.LoadMockGenerator(clients: () => [parentClient, subClient], enableMethodInstrumentation: true); + + var subClientProvider = ScmCodeModelGenerator.Instance.TypeFactory.CreateClient(subClient); + Assert.IsNotNull(subClientProvider); + + // Sub-client also has ActivitySourceField when instrumentation is enabled + Assert.IsNotNull(subClientProvider!.ActivitySourceField); + + var methodCollection = new ScmMethodProviderCollection(inputServiceMethod, subClientProvider); + var convenienceMethod = methodCollection.FirstOrDefault( + m => !m.Signature.Parameters.Any(p => p.Name == "options") && m.Signature.Name == "SubOperation"); + Assert.IsNotNull(convenienceMethod); + + var methodBody = convenienceMethod!.BodyStatements!.ToDisplayString(); + // Sub-client methods get the activity with sub-client name + StringAssert.Contains("_activitySource.StartActivity(\"SubClient.SubOperation\"", methodBody); + StringAssert.Contains("using global::System.Diagnostics.Activity activity", methodBody); + } + + [Test] + public void TracingIsAddedToPagingConvenienceMethod() + { + var pagingMetadata = InputFactory.PagingMetadata(["items"], null, null); + var inputModel = InputFactory.Model("cat", properties: + [ + InputFactory.Property("color", InputPrimitiveType.String, isRequired: true), + ]); + + var response = InputFactory.OperationResponse( + [200], + InputFactory.Model( + "page", + properties: [InputFactory.Property("cats", InputFactory.Array(inputModel))])); + var operation = InputFactory.Operation("GetCats", responses: [response]); + var inputServiceMethod = InputFactory.PagingServiceMethod("GetCats", operation, pagingMetadata: pagingMetadata); + var inputClient = InputFactory.Client("TestClient", methods: [inputServiceMethod]); + + MockHelpers.LoadMockGenerator(inputModels: () => [inputModel], clients: () => [inputClient], enableMethodInstrumentation: true); + + var client = ScmCodeModelGenerator.Instance.TypeFactory.CreateClient(inputClient); + Assert.IsNotNull(client); + + var methodCollection = new ScmMethodProviderCollection(inputServiceMethod, client!); + var convenienceMethod = methodCollection.FirstOrDefault( + m => !m.Signature.Parameters.Any(p => p.Name == "options") && m.Signature.Name == "GetCats"); + Assert.IsNotNull(convenienceMethod); + + var methodBody = convenienceMethod!.BodyStatements!.ToDisplayString(); + // Paging methods: ActivitySource is passed to the collection, no activity started here. + // Each page request starts its own activity inside ExecutePageRequest in the collection. + StringAssert.DoesNotContain("StartActivity", methodBody); + StringAssert.DoesNotContain("Activity activity", methodBody); + // The _activitySource field should be passed to the collection constructor + StringAssert.Contains("_activitySource", methodBody); + } + + [Test] + public void TracingInPagingCollectionStartsActivityPerPage() + { + var pagingMetadata = InputFactory.PagingMetadata(["items"], null, null); + var inputModel = InputFactory.Model("cat", properties: + [ + InputFactory.Property("color", InputPrimitiveType.String, isRequired: true), + ]); + + var response = InputFactory.OperationResponse( + [200], + InputFactory.Model( + "page", + properties: [InputFactory.Property("cats", InputFactory.Array(inputModel))])); + var operation = InputFactory.Operation("GetCats", responses: [response]); + var inputServiceMethod = InputFactory.PagingServiceMethod("GetCats", operation, pagingMetadata: pagingMetadata); + var inputClient = InputFactory.Client("TestClient", methods: [inputServiceMethod]); + + MockHelpers.LoadMockGenerator(inputModels: () => [inputModel], clients: () => [inputClient], enableMethodInstrumentation: true); + + var client = ScmCodeModelGenerator.Instance.TypeFactory.CreateClient(inputClient); + Assert.IsNotNull(client); + + // Find the CollectionResultDefinition that was generated + var collectionResultDefinition = ScmCodeModelGenerator.Instance.OutputLibrary.TypeProviders + .OfType() + .FirstOrDefault(); + Assert.IsNotNull(collectionResultDefinition); + + // CollectionResultDefinition should have an _activitySource field (not _activity) + var activitySourceField = collectionResultDefinition!.Fields.FirstOrDefault(f => f.Name == "_activitySource"); + Assert.IsNotNull(activitySourceField, "CollectionResultDefinition should have an _activitySource field"); + Assert.IsNull(collectionResultDefinition.Fields.FirstOrDefault(f => f.Name == "_activity"), + "CollectionResultDefinition should NOT have an _activity field"); + + // The constructor should accept an activitySource parameter + var ctor = collectionResultDefinition.Constructors.FirstOrDefault(); + Assert.IsNotNull(ctor); + var activitySourceParam = ctor!.Signature.Parameters.FirstOrDefault(p => p.Name == "activitySource"); + Assert.IsNotNull(activitySourceParam, "Constructor should have an 'activitySource' parameter"); + + // GetRawPages method should NOT have try-finally (no per-collection activity). + // It should call ExecutePageRequest which handles per-page activity. + var getRawPagesMethod = collectionResultDefinition.Methods.FirstOrDefault(m => m.Signature.Name == "GetRawPages"); + Assert.IsNotNull(getRawPagesMethod); + var rawPagesBody = getRawPagesMethod!.BodyStatements!.ToDisplayString(); + StringAssert.Contains("ExecutePageRequest", rawPagesBody); + StringAssert.DoesNotContain("_activitySource.StartActivity", rawPagesBody); + + // ExecutePageRequest helper should have per-page activity with try-catch + var executePageMethod = collectionResultDefinition.Methods.FirstOrDefault(m => m.Signature.Name == "ExecutePageRequest"); + Assert.IsNotNull(executePageMethod, "CollectionResultDefinition should have an ExecutePageRequest method"); + var executePageBody = executePageMethod!.BodyStatements!.ToDisplayString(); + StringAssert.Contains("_activitySource?.StartActivity(\"TestClient.GetCats\"", executePageBody); + StringAssert.Contains("using global::System.Diagnostics.Activity activity", executePageBody); + StringAssert.Contains("catch", executePageBody); + StringAssert.Contains("SetStatus", executePageBody); + StringAssert.Contains("ActivityStatusCode.Error", executePageBody); + } + } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/TestHelpers/Configuration.json b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/TestHelpers/Configuration.json index a0867eb37e3..d47eaf9a7c4 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/TestHelpers/Configuration.json +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/TestHelpers/Configuration.json @@ -5,5 +5,6 @@ "unknown-bool-property": false, "package-name": "SampleLibrary", "unknown-string-property": "unknownPropertyValue", - "disable-xml-docs": true + "disable-xml-docs": true, + "generate-method-instrumentation": false } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/TestHelpers/MockHelpers.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/TestHelpers/MockHelpers.cs index 9148f659e43..b66bc9ee2a0 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/TestHelpers/MockHelpers.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/TestHelpers/MockHelpers.cs @@ -76,7 +76,8 @@ public static Mock LoadMockGenerator( Func? createOutputLibrary = null, bool includeXmlDocs = false, Func? createCSharpTypeCoreFallback = null, - Func? createModelCore = null) + Func? createModelCore = null, + bool enableMethodInstrumentation = false) { IReadOnlyList inputNsApiVersions = apiVersions?.Invoke() ?? []; IReadOnlyList inputNsLiterals = inputLiterals?.Invoke() ?? []; @@ -148,7 +149,11 @@ public static Mock LoadMockGenerator( var loadMethod = typeof(Configuration).GetMethod("Load", BindingFlags.Static | BindingFlags.NonPublic); if (includeXmlDocs) { - configuration = "{\"disable-xml-docs\": false, \"package-name\": \"Sample.Namespace\"}"; + configuration = "{\"disable-xml-docs\": false, \"package-name\": \"Sample.Namespace\", \"generate-method-instrumentation\": false}"; + } + else if (enableMethodInstrumentation) + { + configuration = "{\"package-name\": \"SampleLibrary\", \"generate-method-instrumentation\": true}"; } object?[] parameters = [_configFilePath, configuration]; var config = loadMethod?.Invoke(null, parameters); diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Configuration.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Configuration.cs index 98169440b6f..426b0229db2 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Configuration.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Configuration.cs @@ -35,7 +35,8 @@ public Configuration( string packageName, bool disableXmlDocs, UnreferencedTypesHandlingOption unreferencedTypesHandling, - LicenseInfo? licenseInfo) + LicenseInfo? licenseInfo, + bool generateMethodInstrumentation = true) { OutputDirectory = outputPath; AdditionalConfigurationOptions = additionalConfigurationOptions; @@ -43,6 +44,7 @@ public Configuration( DisableXmlDocs = disableXmlDocs; UnreferencedTypesHandling = unreferencedTypesHandling; LicenseInfo = licenseInfo; + GenerateMethodInstrumentation = generateMethodInstrumentation; } /// @@ -53,6 +55,7 @@ private static class Options public const string PackageName = "package-name"; public const string DisableXmlDocs = "disable-xml-docs"; public const string UnreferencedTypesHandling = "unreferenced-types-handling"; + public const string GenerateMethodInstrumentation = "generate-method-instrumentation"; } /// @@ -60,6 +63,11 @@ private static class Options /// public bool DisableXmlDocs { get; } + /// + /// Gets whether ActivitySource-based distributed tracing instrumentation should be generated in client methods. + /// + public bool GenerateMethodInstrumentation { get; } + /// /// Gets the root output directory for the generated library. /// @@ -123,7 +131,8 @@ internal static Configuration Load(string outputPath, string? json = null) ReadRequiredStringOption(root, Options.PackageName), ReadOption(root, Options.DisableXmlDocs), ReadEnumOption(root, Options.UnreferencedTypesHandling), - ReadLicenseInfo(root)); + ReadLicenseInfo(root), + ReadOption(root, Options.GenerateMethodInstrumentation)); } private static LicenseInfo? ReadLicenseInfo(JsonElement root) @@ -154,6 +163,7 @@ internal static Configuration Load(string outputPath, string? json = null) private static readonly Dictionary _defaultBoolOptionValues = new() { { Options.DisableXmlDocs, false }, + { Options.GenerateMethodInstrumentation, true }, }; /// @@ -164,6 +174,7 @@ internal static Configuration Load(string outputPath, string? json = null) Options.PackageName, Options.DisableXmlDocs, Options.UnreferencedTypesHandling, + Options.GenerateMethodInstrumentation, }; private static bool ReadOption(JsonElement root, string option) diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/Configuration.json index 5444bcf8177..c8151fbc4bb 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/Configuration.json @@ -1,4 +1,5 @@ { + "generate-method-instrumentation": true, "package-name": "SampleTypeSpec", "license": { "name": "MIT License", diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/AnimalOperations.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/AnimalOperations.cs index 10d3b31fe97..523a82747ea 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/AnimalOperations.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/AnimalOperations.cs @@ -8,6 +8,7 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; @@ -17,6 +18,7 @@ namespace SampleTypeSpec public partial class AnimalOperations { private readonly Uri _endpoint; + private static readonly ActivitySource _activitySource = new ActivitySource("SampleTypeSpec"); /// Initializes a new instance of AnimalOperations for mocking. protected AnimalOperations() @@ -86,8 +88,17 @@ public virtual ClientResult UpdatePetAsAnimal(Animal animal, Cancellatio { Argument.AssertNotNull(animal, nameof(animal)); - ClientResult result = UpdatePetAsAnimal(animal, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Animal)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("AnimalOperations.UpdatePetAsAnimal", ActivityKind.Client); + try + { + ClientResult result = UpdatePetAsAnimal(animal, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Animal)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Update a pet as an animal. @@ -99,8 +110,17 @@ public virtual async Task> UpdatePetAsAnimalAsync(Animal an { Argument.AssertNotNull(animal, nameof(animal)); - ClientResult result = await UpdatePetAsAnimalAsync(animal, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Animal)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("AnimalOperations.UpdatePetAsAnimal", ActivityKind.Client); + try + { + ClientResult result = await UpdatePetAsAnimalAsync(animal, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Animal)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -154,8 +174,17 @@ public virtual ClientResult UpdateDogAsAnimal(Animal animal, Cancellatio { Argument.AssertNotNull(animal, nameof(animal)); - ClientResult result = UpdateDogAsAnimal(animal, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Animal)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("AnimalOperations.UpdateDogAsAnimal", ActivityKind.Client); + try + { + ClientResult result = UpdateDogAsAnimal(animal, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Animal)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Update a dog as an animal. @@ -167,8 +196,17 @@ public virtual async Task> UpdateDogAsAnimalAsync(Animal an { Argument.AssertNotNull(animal, nameof(animal)); - ClientResult result = await UpdateDogAsAnimalAsync(animal, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Animal)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("AnimalOperations.UpdateDogAsAnimal", ActivityKind.Client); + try + { + ClientResult result = await UpdateDogAsAnimalAsync(animal, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Animal)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResult.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResult.cs index 89c5702b006..e8ed77ee71e 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResult.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResult.cs @@ -9,12 +9,15 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; +using System.Threading.Tasks; namespace SampleTypeSpec { internal partial class SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResult : AsyncCollectionResult { private readonly SampleTypeSpecClient _client; + private readonly ActivitySource _activitySource; private readonly string _token; private readonly RequestOptions _options; @@ -22,11 +25,13 @@ internal partial class SampleTypeSpecClientGetWithContinuationTokenAsyncCollecti /// The SampleTypeSpecClient client used to send requests. /// /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - public SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResult(SampleTypeSpecClient client, string token, RequestOptions options) + /// The activity source for distributed tracing. + public SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResult(SampleTypeSpecClient client, string token, RequestOptions options, ActivitySource activitySource = null) { _client = client; _token = token; _options = options; + _activitySource = activitySource; } /// Gets the raw pages of the collection. @@ -37,7 +42,7 @@ public override async IAsyncEnumerable GetRawPagesAsync() string nextToken = null; while (true) { - ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + ClientResult result = await ExecutePageRequestAsync(message).ConfigureAwait(false); yield return result; nextToken = ((ListWithContinuationTokenResponse)result).NextToken; @@ -64,5 +69,20 @@ public override ContinuationToken GetContinuationToken(ClientResult page) return null; } } + + /// The pipeline message. + private async Task ExecutePageRequestAsync(PipelineMessage message) + { + using Activity activity = _activitySource?.StartActivity("SampleTypeSpecClient.GetWithContinuationToken", ActivityKind.Client); + try + { + return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResultOfT.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResultOfT.cs index 75eb97d46bb..51934caa899 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResultOfT.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResultOfT.cs @@ -9,6 +9,7 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; using System.Threading.Tasks; namespace SampleTypeSpec @@ -16,6 +17,7 @@ namespace SampleTypeSpec internal partial class SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResultOfT : AsyncCollectionResult { private readonly SampleTypeSpecClient _client; + private readonly ActivitySource _activitySource; private readonly string _token; private readonly RequestOptions _options; @@ -23,11 +25,13 @@ internal partial class SampleTypeSpecClientGetWithContinuationTokenAsyncCollecti /// The SampleTypeSpecClient client used to send requests. /// /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - public SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResultOfT(SampleTypeSpecClient client, string token, RequestOptions options) + /// The activity source for distributed tracing. + public SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResultOfT(SampleTypeSpecClient client, string token, RequestOptions options, ActivitySource activitySource = null) { _client = client; _token = token; _options = options; + _activitySource = activitySource; } /// Gets the raw pages of the collection. @@ -38,7 +42,7 @@ public override async IAsyncEnumerable GetRawPagesAsync() string nextToken = null; while (true) { - ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + ClientResult result = await ExecutePageRequestAsync(message).ConfigureAwait(false); yield return result; nextToken = ((ListWithContinuationTokenResponse)result).NextToken; @@ -66,6 +70,21 @@ public override ContinuationToken GetContinuationToken(ClientResult page) } } + /// The pipeline message. + private async Task ExecutePageRequestAsync(PipelineMessage message) + { + using Activity activity = _activitySource?.StartActivity("SampleTypeSpecClient.GetWithContinuationToken", ActivityKind.Client); + try + { + return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } + } + /// Gets the values from the specified page. /// /// The values from the specified page. diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenCollectionResult.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenCollectionResult.cs index 0c52e02a228..0e0aeb81884 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenCollectionResult.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenCollectionResult.cs @@ -9,12 +9,14 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; namespace SampleTypeSpec { internal partial class SampleTypeSpecClientGetWithContinuationTokenCollectionResult : CollectionResult { private readonly SampleTypeSpecClient _client; + private readonly ActivitySource _activitySource; private readonly string _token; private readonly RequestOptions _options; @@ -22,11 +24,13 @@ internal partial class SampleTypeSpecClientGetWithContinuationTokenCollectionRes /// The SampleTypeSpecClient client used to send requests. /// /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - public SampleTypeSpecClientGetWithContinuationTokenCollectionResult(SampleTypeSpecClient client, string token, RequestOptions options) + /// The activity source for distributed tracing. + public SampleTypeSpecClientGetWithContinuationTokenCollectionResult(SampleTypeSpecClient client, string token, RequestOptions options, ActivitySource activitySource = null) { _client = client; _token = token; _options = options; + _activitySource = activitySource; } /// Gets the raw pages of the collection. @@ -37,7 +41,7 @@ public override IEnumerable GetRawPages() string nextToken = null; while (true) { - ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + ClientResult result = ExecutePageRequest(message); yield return result; nextToken = ((ListWithContinuationTokenResponse)result).NextToken; @@ -64,5 +68,20 @@ public override ContinuationToken GetContinuationToken(ClientResult page) return null; } } + + /// The pipeline message. + private ClientResult ExecutePageRequest(PipelineMessage message) + { + using Activity activity = _activitySource?.StartActivity("SampleTypeSpecClient.GetWithContinuationToken", ActivityKind.Client); + try + { + return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenCollectionResultOfT.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenCollectionResultOfT.cs index d5eabeb8a8e..c11a0643c9d 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenCollectionResultOfT.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenCollectionResultOfT.cs @@ -9,12 +9,14 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; namespace SampleTypeSpec { internal partial class SampleTypeSpecClientGetWithContinuationTokenCollectionResultOfT : CollectionResult { private readonly SampleTypeSpecClient _client; + private readonly ActivitySource _activitySource; private readonly string _token; private readonly RequestOptions _options; @@ -22,11 +24,13 @@ internal partial class SampleTypeSpecClientGetWithContinuationTokenCollectionRes /// The SampleTypeSpecClient client used to send requests. /// /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - public SampleTypeSpecClientGetWithContinuationTokenCollectionResultOfT(SampleTypeSpecClient client, string token, RequestOptions options) + /// The activity source for distributed tracing. + public SampleTypeSpecClientGetWithContinuationTokenCollectionResultOfT(SampleTypeSpecClient client, string token, RequestOptions options, ActivitySource activitySource = null) { _client = client; _token = token; _options = options; + _activitySource = activitySource; } /// Gets the raw pages of the collection. @@ -37,7 +41,7 @@ public override IEnumerable GetRawPages() string nextToken = null; while (true) { - ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + ClientResult result = ExecutePageRequest(message); yield return result; nextToken = ((ListWithContinuationTokenResponse)result).NextToken; @@ -65,6 +69,21 @@ public override ContinuationToken GetContinuationToken(ClientResult page) } } + /// The pipeline message. + private ClientResult ExecutePageRequest(PipelineMessage message) + { + using Activity activity = _activitySource?.StartActivity("SampleTypeSpecClient.GetWithContinuationToken", ActivityKind.Client); + try + { + return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } + } + /// Gets the values from the specified page. /// /// The values from the specified page. diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResult.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResult.cs index ca9ff340edf..7910703fcf3 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResult.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResult.cs @@ -9,12 +9,15 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; +using System.Threading.Tasks; namespace SampleTypeSpec { internal partial class SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResult : AsyncCollectionResult { private readonly SampleTypeSpecClient _client; + private readonly ActivitySource _activitySource; private readonly string _token; private readonly RequestOptions _options; @@ -22,11 +25,13 @@ internal partial class SampleTypeSpecClientGetWithContinuationTokenHeaderRespons /// The SampleTypeSpecClient client used to send requests. /// /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - public SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResult(SampleTypeSpecClient client, string token, RequestOptions options) + /// The activity source for distributed tracing. + public SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResult(SampleTypeSpecClient client, string token, RequestOptions options, ActivitySource activitySource = null) { _client = client; _token = token; _options = options; + _activitySource = activitySource; } /// Gets the raw pages of the collection. @@ -37,7 +42,7 @@ public override async IAsyncEnumerable GetRawPagesAsync() string nextToken = null; while (true) { - ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + ClientResult result = await ExecutePageRequestAsync(message).ConfigureAwait(false); yield return result; if (result.GetRawResponse().Headers.TryGetValue("next-token", out string value) && !string.IsNullOrEmpty(value)) @@ -66,5 +71,20 @@ public override ContinuationToken GetContinuationToken(ClientResult page) return null; } } + + /// The pipeline message. + private async Task ExecutePageRequestAsync(PipelineMessage message) + { + using Activity activity = _activitySource?.StartActivity("SampleTypeSpecClient.GetWithContinuationTokenHeaderResponse", ActivityKind.Client); + try + { + return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResultOfT.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResultOfT.cs index ebdce57e71a..35a6f1d5788 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResultOfT.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResultOfT.cs @@ -9,6 +9,7 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; using System.Threading.Tasks; namespace SampleTypeSpec @@ -16,6 +17,7 @@ namespace SampleTypeSpec internal partial class SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResultOfT : AsyncCollectionResult { private readonly SampleTypeSpecClient _client; + private readonly ActivitySource _activitySource; private readonly string _token; private readonly RequestOptions _options; @@ -23,11 +25,13 @@ internal partial class SampleTypeSpecClientGetWithContinuationTokenHeaderRespons /// The SampleTypeSpecClient client used to send requests. /// /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - public SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResultOfT(SampleTypeSpecClient client, string token, RequestOptions options) + /// The activity source for distributed tracing. + public SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResultOfT(SampleTypeSpecClient client, string token, RequestOptions options, ActivitySource activitySource = null) { _client = client; _token = token; _options = options; + _activitySource = activitySource; } /// Gets the raw pages of the collection. @@ -38,7 +42,7 @@ public override async IAsyncEnumerable GetRawPagesAsync() string nextToken = null; while (true) { - ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + ClientResult result = await ExecutePageRequestAsync(message).ConfigureAwait(false); yield return result; if (result.GetRawResponse().Headers.TryGetValue("next-token", out string value) && !string.IsNullOrEmpty(value)) @@ -68,6 +72,21 @@ public override ContinuationToken GetContinuationToken(ClientResult page) } } + /// The pipeline message. + private async Task ExecutePageRequestAsync(PipelineMessage message) + { + using Activity activity = _activitySource?.StartActivity("SampleTypeSpecClient.GetWithContinuationTokenHeaderResponse", ActivityKind.Client); + try + { + return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } + } + /// Gets the values from the specified page. /// /// The values from the specified page. diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResult.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResult.cs index f50dab79b40..f9aaca34ac7 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResult.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResult.cs @@ -9,12 +9,14 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; namespace SampleTypeSpec { internal partial class SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResult : CollectionResult { private readonly SampleTypeSpecClient _client; + private readonly ActivitySource _activitySource; private readonly string _token; private readonly RequestOptions _options; @@ -22,11 +24,13 @@ internal partial class SampleTypeSpecClientGetWithContinuationTokenHeaderRespons /// The SampleTypeSpecClient client used to send requests. /// /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - public SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResult(SampleTypeSpecClient client, string token, RequestOptions options) + /// The activity source for distributed tracing. + public SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResult(SampleTypeSpecClient client, string token, RequestOptions options, ActivitySource activitySource = null) { _client = client; _token = token; _options = options; + _activitySource = activitySource; } /// Gets the raw pages of the collection. @@ -37,7 +41,7 @@ public override IEnumerable GetRawPages() string nextToken = null; while (true) { - ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + ClientResult result = ExecutePageRequest(message); yield return result; if (result.GetRawResponse().Headers.TryGetValue("next-token", out string value) && !string.IsNullOrEmpty(value)) @@ -66,5 +70,20 @@ public override ContinuationToken GetContinuationToken(ClientResult page) return null; } } + + /// The pipeline message. + private ClientResult ExecutePageRequest(PipelineMessage message) + { + using Activity activity = _activitySource?.StartActivity("SampleTypeSpecClient.GetWithContinuationTokenHeaderResponse", ActivityKind.Client); + try + { + return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResultOfT.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResultOfT.cs index b4e10128332..f021bd69d86 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResultOfT.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResultOfT.cs @@ -9,12 +9,14 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; namespace SampleTypeSpec { internal partial class SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResultOfT : CollectionResult { private readonly SampleTypeSpecClient _client; + private readonly ActivitySource _activitySource; private readonly string _token; private readonly RequestOptions _options; @@ -22,11 +24,13 @@ internal partial class SampleTypeSpecClientGetWithContinuationTokenHeaderRespons /// The SampleTypeSpecClient client used to send requests. /// /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - public SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResultOfT(SampleTypeSpecClient client, string token, RequestOptions options) + /// The activity source for distributed tracing. + public SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResultOfT(SampleTypeSpecClient client, string token, RequestOptions options, ActivitySource activitySource = null) { _client = client; _token = token; _options = options; + _activitySource = activitySource; } /// Gets the raw pages of the collection. @@ -37,7 +41,7 @@ public override IEnumerable GetRawPages() string nextToken = null; while (true) { - ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + ClientResult result = ExecutePageRequest(message); yield return result; if (result.GetRawResponse().Headers.TryGetValue("next-token", out string value) && !string.IsNullOrEmpty(value)) @@ -67,6 +71,21 @@ public override ContinuationToken GetContinuationToken(ClientResult page) } } + /// The pipeline message. + private ClientResult ExecutePageRequest(PipelineMessage message) + { + using Activity activity = _activitySource?.StartActivity("SampleTypeSpecClient.GetWithContinuationTokenHeaderResponse", ActivityKind.Client); + try + { + return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } + } + /// Gets the values from the specified page. /// /// The values from the specified page. diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkAsyncCollectionResult.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkAsyncCollectionResult.cs index 034facf2353..0de5aaa3247 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkAsyncCollectionResult.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkAsyncCollectionResult.cs @@ -9,21 +9,26 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; +using System.Threading.Tasks; namespace SampleTypeSpec { internal partial class SampleTypeSpecClientGetWithNextLinkAsyncCollectionResult : AsyncCollectionResult { private readonly SampleTypeSpecClient _client; + private readonly ActivitySource _activitySource; private readonly RequestOptions _options; /// Initializes a new instance of SampleTypeSpecClientGetWithNextLinkAsyncCollectionResult, which is used to iterate over the pages of a collection. /// The SampleTypeSpecClient client used to send requests. /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - public SampleTypeSpecClientGetWithNextLinkAsyncCollectionResult(SampleTypeSpecClient client, RequestOptions options) + /// The activity source for distributed tracing. + public SampleTypeSpecClientGetWithNextLinkAsyncCollectionResult(SampleTypeSpecClient client, RequestOptions options, ActivitySource activitySource = null) { _client = client; _options = options; + _activitySource = activitySource; } /// Gets the raw pages of the collection. @@ -34,7 +39,7 @@ public override async IAsyncEnumerable GetRawPagesAsync() Uri nextPageUri = null; while (true) { - ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + ClientResult result = await ExecutePageRequestAsync(message).ConfigureAwait(false); yield return result; nextPageUri = ((ListWithNextLinkResponse)result).Next; @@ -61,5 +66,20 @@ public override ContinuationToken GetContinuationToken(ClientResult page) return null; } } + + /// The pipeline message. + private async Task ExecutePageRequestAsync(PipelineMessage message) + { + using Activity activity = _activitySource?.StartActivity("SampleTypeSpecClient.GetWithNextLink", ActivityKind.Client); + try + { + return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkAsyncCollectionResultOfT.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkAsyncCollectionResultOfT.cs index 6ecde199e1c..7aefbc2446b 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkAsyncCollectionResultOfT.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkAsyncCollectionResultOfT.cs @@ -9,6 +9,7 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; using System.Threading.Tasks; namespace SampleTypeSpec @@ -16,15 +17,18 @@ namespace SampleTypeSpec internal partial class SampleTypeSpecClientGetWithNextLinkAsyncCollectionResultOfT : AsyncCollectionResult { private readonly SampleTypeSpecClient _client; + private readonly ActivitySource _activitySource; private readonly RequestOptions _options; /// Initializes a new instance of SampleTypeSpecClientGetWithNextLinkAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. /// The SampleTypeSpecClient client used to send requests. /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - public SampleTypeSpecClientGetWithNextLinkAsyncCollectionResultOfT(SampleTypeSpecClient client, RequestOptions options) + /// The activity source for distributed tracing. + public SampleTypeSpecClientGetWithNextLinkAsyncCollectionResultOfT(SampleTypeSpecClient client, RequestOptions options, ActivitySource activitySource = null) { _client = client; _options = options; + _activitySource = activitySource; } /// Gets the raw pages of the collection. @@ -35,7 +39,7 @@ public override async IAsyncEnumerable GetRawPagesAsync() Uri nextPageUri = null; while (true) { - ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + ClientResult result = await ExecutePageRequestAsync(message).ConfigureAwait(false); yield return result; nextPageUri = ((ListWithNextLinkResponse)result).Next; @@ -63,6 +67,21 @@ public override ContinuationToken GetContinuationToken(ClientResult page) } } + /// The pipeline message. + private async Task ExecutePageRequestAsync(PipelineMessage message) + { + using Activity activity = _activitySource?.StartActivity("SampleTypeSpecClient.GetWithNextLink", ActivityKind.Client); + try + { + return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } + } + /// Gets the values from the specified page. /// /// The values from the specified page. diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkCollectionResult.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkCollectionResult.cs index e43d87a042a..bfe752cacc2 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkCollectionResult.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkCollectionResult.cs @@ -9,21 +9,25 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; namespace SampleTypeSpec { internal partial class SampleTypeSpecClientGetWithNextLinkCollectionResult : CollectionResult { private readonly SampleTypeSpecClient _client; + private readonly ActivitySource _activitySource; private readonly RequestOptions _options; /// Initializes a new instance of SampleTypeSpecClientGetWithNextLinkCollectionResult, which is used to iterate over the pages of a collection. /// The SampleTypeSpecClient client used to send requests. /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - public SampleTypeSpecClientGetWithNextLinkCollectionResult(SampleTypeSpecClient client, RequestOptions options) + /// The activity source for distributed tracing. + public SampleTypeSpecClientGetWithNextLinkCollectionResult(SampleTypeSpecClient client, RequestOptions options, ActivitySource activitySource = null) { _client = client; _options = options; + _activitySource = activitySource; } /// Gets the raw pages of the collection. @@ -34,7 +38,7 @@ public override IEnumerable GetRawPages() Uri nextPageUri = null; while (true) { - ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + ClientResult result = ExecutePageRequest(message); yield return result; nextPageUri = ((ListWithNextLinkResponse)result).Next; @@ -61,5 +65,20 @@ public override ContinuationToken GetContinuationToken(ClientResult page) return null; } } + + /// The pipeline message. + private ClientResult ExecutePageRequest(PipelineMessage message) + { + using Activity activity = _activitySource?.StartActivity("SampleTypeSpecClient.GetWithNextLink", ActivityKind.Client); + try + { + return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkCollectionResultOfT.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkCollectionResultOfT.cs index 51e1a2f5494..ef0e550f403 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkCollectionResultOfT.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkCollectionResultOfT.cs @@ -9,21 +9,25 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; namespace SampleTypeSpec { internal partial class SampleTypeSpecClientGetWithNextLinkCollectionResultOfT : CollectionResult { private readonly SampleTypeSpecClient _client; + private readonly ActivitySource _activitySource; private readonly RequestOptions _options; /// Initializes a new instance of SampleTypeSpecClientGetWithNextLinkCollectionResultOfT, which is used to iterate over the pages of a collection. /// The SampleTypeSpecClient client used to send requests. /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - public SampleTypeSpecClientGetWithNextLinkCollectionResultOfT(SampleTypeSpecClient client, RequestOptions options) + /// The activity source for distributed tracing. + public SampleTypeSpecClientGetWithNextLinkCollectionResultOfT(SampleTypeSpecClient client, RequestOptions options, ActivitySource activitySource = null) { _client = client; _options = options; + _activitySource = activitySource; } /// Gets the raw pages of the collection. @@ -34,7 +38,7 @@ public override IEnumerable GetRawPages() Uri nextPageUri = null; while (true) { - ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + ClientResult result = ExecutePageRequest(message); yield return result; nextPageUri = ((ListWithNextLinkResponse)result).Next; @@ -62,6 +66,21 @@ public override ContinuationToken GetContinuationToken(ClientResult page) } } + /// The pipeline message. + private ClientResult ExecutePageRequest(PipelineMessage message) + { + using Activity activity = _activitySource?.StartActivity("SampleTypeSpecClient.GetWithNextLink", ActivityKind.Client); + try + { + return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } + } + /// Gets the values from the specified page. /// /// The values from the specified page. diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingAsyncCollectionResult.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingAsyncCollectionResult.cs index b62bc4e45b0..dcdebb780c7 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingAsyncCollectionResult.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingAsyncCollectionResult.cs @@ -5,24 +5,30 @@ #nullable disable +using System; using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; +using System.Threading.Tasks; namespace SampleTypeSpec { internal partial class SampleTypeSpecClientGetWithPagingAsyncCollectionResult : AsyncCollectionResult { private readonly SampleTypeSpecClient _client; + private readonly ActivitySource _activitySource; private readonly RequestOptions _options; /// Initializes a new instance of SampleTypeSpecClientGetWithPagingAsyncCollectionResult, which is used to iterate over the pages of a collection. /// The SampleTypeSpecClient client used to send requests. /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - public SampleTypeSpecClientGetWithPagingAsyncCollectionResult(SampleTypeSpecClient client, RequestOptions options) + /// The activity source for distributed tracing. + public SampleTypeSpecClientGetWithPagingAsyncCollectionResult(SampleTypeSpecClient client, RequestOptions options, ActivitySource activitySource = null) { _client = client; _options = options; + _activitySource = activitySource; } /// Gets the raw pages of the collection. @@ -30,7 +36,7 @@ public SampleTypeSpecClientGetWithPagingAsyncCollectionResult(SampleTypeSpecClie public override async IAsyncEnumerable GetRawPagesAsync() { PipelineMessage message = _client.CreateGetWithPagingRequest(_options); - yield return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return await ExecutePageRequestAsync(message).ConfigureAwait(false); } /// Gets the continuation token from the specified page. @@ -40,5 +46,20 @@ public override ContinuationToken GetContinuationToken(ClientResult page) { return null; } + + /// The pipeline message. + private async Task ExecutePageRequestAsync(PipelineMessage message) + { + using Activity activity = _activitySource?.StartActivity("SampleTypeSpecClient.GetWithPaging", ActivityKind.Client); + try + { + return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingAsyncCollectionResultOfT.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingAsyncCollectionResultOfT.cs index fa5e727fd26..1204c2db352 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingAsyncCollectionResultOfT.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingAsyncCollectionResultOfT.cs @@ -5,9 +5,11 @@ #nullable disable +using System; using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; using System.Threading.Tasks; namespace SampleTypeSpec @@ -15,15 +17,18 @@ namespace SampleTypeSpec internal partial class SampleTypeSpecClientGetWithPagingAsyncCollectionResultOfT : AsyncCollectionResult { private readonly SampleTypeSpecClient _client; + private readonly ActivitySource _activitySource; private readonly RequestOptions _options; /// Initializes a new instance of SampleTypeSpecClientGetWithPagingAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. /// The SampleTypeSpecClient client used to send requests. /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - public SampleTypeSpecClientGetWithPagingAsyncCollectionResultOfT(SampleTypeSpecClient client, RequestOptions options) + /// The activity source for distributed tracing. + public SampleTypeSpecClientGetWithPagingAsyncCollectionResultOfT(SampleTypeSpecClient client, RequestOptions options, ActivitySource activitySource = null) { _client = client; _options = options; + _activitySource = activitySource; } /// Gets the raw pages of the collection. @@ -31,7 +36,7 @@ public SampleTypeSpecClientGetWithPagingAsyncCollectionResultOfT(SampleTypeSpecC public override async IAsyncEnumerable GetRawPagesAsync() { PipelineMessage message = _client.CreateGetWithPagingRequest(_options); - yield return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return await ExecutePageRequestAsync(message).ConfigureAwait(false); } /// Gets the continuation token from the specified page. @@ -42,6 +47,21 @@ public override ContinuationToken GetContinuationToken(ClientResult page) return null; } + /// The pipeline message. + private async Task ExecutePageRequestAsync(PipelineMessage message) + { + using Activity activity = _activitySource?.StartActivity("SampleTypeSpecClient.GetWithPaging", ActivityKind.Client); + try + { + return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } + } + /// Gets the values from the specified page. /// /// The values from the specified page. diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingCollectionResult.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingCollectionResult.cs index 9fb94135cc9..3ea77a9384d 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingCollectionResult.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingCollectionResult.cs @@ -5,24 +5,29 @@ #nullable disable +using System; using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; namespace SampleTypeSpec { internal partial class SampleTypeSpecClientGetWithPagingCollectionResult : CollectionResult { private readonly SampleTypeSpecClient _client; + private readonly ActivitySource _activitySource; private readonly RequestOptions _options; /// Initializes a new instance of SampleTypeSpecClientGetWithPagingCollectionResult, which is used to iterate over the pages of a collection. /// The SampleTypeSpecClient client used to send requests. /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - public SampleTypeSpecClientGetWithPagingCollectionResult(SampleTypeSpecClient client, RequestOptions options) + /// The activity source for distributed tracing. + public SampleTypeSpecClientGetWithPagingCollectionResult(SampleTypeSpecClient client, RequestOptions options, ActivitySource activitySource = null) { _client = client; _options = options; + _activitySource = activitySource; } /// Gets the raw pages of the collection. @@ -30,7 +35,7 @@ public SampleTypeSpecClientGetWithPagingCollectionResult(SampleTypeSpecClient cl public override IEnumerable GetRawPages() { PipelineMessage message = _client.CreateGetWithPagingRequest(_options); - yield return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return ExecutePageRequest(message); } /// Gets the continuation token from the specified page. @@ -40,5 +45,20 @@ public override ContinuationToken GetContinuationToken(ClientResult page) { return null; } + + /// The pipeline message. + private ClientResult ExecutePageRequest(PipelineMessage message) + { + using Activity activity = _activitySource?.StartActivity("SampleTypeSpecClient.GetWithPaging", ActivityKind.Client); + try + { + return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingCollectionResultOfT.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingCollectionResultOfT.cs index 6031b02f615..74d1ab985f4 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingCollectionResultOfT.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingCollectionResultOfT.cs @@ -5,24 +5,29 @@ #nullable disable +using System; using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; namespace SampleTypeSpec { internal partial class SampleTypeSpecClientGetWithPagingCollectionResultOfT : CollectionResult { private readonly SampleTypeSpecClient _client; + private readonly ActivitySource _activitySource; private readonly RequestOptions _options; /// Initializes a new instance of SampleTypeSpecClientGetWithPagingCollectionResultOfT, which is used to iterate over the pages of a collection. /// The SampleTypeSpecClient client used to send requests. /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - public SampleTypeSpecClientGetWithPagingCollectionResultOfT(SampleTypeSpecClient client, RequestOptions options) + /// The activity source for distributed tracing. + public SampleTypeSpecClientGetWithPagingCollectionResultOfT(SampleTypeSpecClient client, RequestOptions options, ActivitySource activitySource = null) { _client = client; _options = options; + _activitySource = activitySource; } /// Gets the raw pages of the collection. @@ -30,7 +35,7 @@ public SampleTypeSpecClientGetWithPagingCollectionResultOfT(SampleTypeSpecClient public override IEnumerable GetRawPages() { PipelineMessage message = _client.CreateGetWithPagingRequest(_options); - yield return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return ExecutePageRequest(message); } /// Gets the continuation token from the specified page. @@ -41,6 +46,21 @@ public override ContinuationToken GetContinuationToken(ClientResult page) return null; } + /// The pipeline message. + private ClientResult ExecutePageRequest(PipelineMessage message) + { + using Activity activity = _activitySource?.StartActivity("SampleTypeSpecClient.GetWithPaging", ActivityKind.Client); + try + { + return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } + } + /// Gets the values from the specified page. /// /// The values from the specified page. diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResult.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResult.cs index 5f2f970edc6..86adf4d2544 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResult.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResult.cs @@ -9,21 +9,26 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; +using System.Threading.Tasks; namespace SampleTypeSpec { internal partial class SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResult : AsyncCollectionResult { private readonly SampleTypeSpecClient _client; + private readonly ActivitySource _activitySource; private readonly RequestOptions _options; /// Initializes a new instance of SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResult, which is used to iterate over the pages of a collection. /// The SampleTypeSpecClient client used to send requests. /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - public SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResult(SampleTypeSpecClient client, RequestOptions options) + /// The activity source for distributed tracing. + public SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResult(SampleTypeSpecClient client, RequestOptions options, ActivitySource activitySource = null) { _client = client; _options = options; + _activitySource = activitySource; } /// Gets the raw pages of the collection. @@ -34,7 +39,7 @@ public override async IAsyncEnumerable GetRawPagesAsync() Uri nextPageUri = null; while (true) { - ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + ClientResult result = await ExecutePageRequestAsync(message).ConfigureAwait(false); yield return result; string nextPageString = ((ListWithStringNextLinkResponse)result).Next; @@ -62,5 +67,20 @@ public override ContinuationToken GetContinuationToken(ClientResult page) return null; } } + + /// The pipeline message. + private async Task ExecutePageRequestAsync(PipelineMessage message) + { + using Activity activity = _activitySource?.StartActivity("SampleTypeSpecClient.GetWithStringNextLink", ActivityKind.Client); + try + { + return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT.cs index b8b6c3524a1..9357309c3b4 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT.cs @@ -9,6 +9,7 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; using System.Threading.Tasks; namespace SampleTypeSpec @@ -16,15 +17,18 @@ namespace SampleTypeSpec internal partial class SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT : AsyncCollectionResult { private readonly SampleTypeSpecClient _client; + private readonly ActivitySource _activitySource; private readonly RequestOptions _options; /// Initializes a new instance of SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. /// The SampleTypeSpecClient client used to send requests. /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - public SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT(SampleTypeSpecClient client, RequestOptions options) + /// The activity source for distributed tracing. + public SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT(SampleTypeSpecClient client, RequestOptions options, ActivitySource activitySource = null) { _client = client; _options = options; + _activitySource = activitySource; } /// Gets the raw pages of the collection. @@ -35,7 +39,7 @@ public override async IAsyncEnumerable GetRawPagesAsync() Uri nextPageUri = null; while (true) { - ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + ClientResult result = await ExecutePageRequestAsync(message).ConfigureAwait(false); yield return result; string nextPageString = ((ListWithStringNextLinkResponse)result).Next; @@ -64,6 +68,21 @@ public override ContinuationToken GetContinuationToken(ClientResult page) } } + /// The pipeline message. + private async Task ExecutePageRequestAsync(PipelineMessage message) + { + using Activity activity = _activitySource?.StartActivity("SampleTypeSpecClient.GetWithStringNextLink", ActivityKind.Client); + try + { + return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } + } + /// Gets the values from the specified page. /// /// The values from the specified page. diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkCollectionResult.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkCollectionResult.cs index 041284bd988..f15bc911235 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkCollectionResult.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkCollectionResult.cs @@ -9,21 +9,25 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; namespace SampleTypeSpec { internal partial class SampleTypeSpecClientGetWithStringNextLinkCollectionResult : CollectionResult { private readonly SampleTypeSpecClient _client; + private readonly ActivitySource _activitySource; private readonly RequestOptions _options; /// Initializes a new instance of SampleTypeSpecClientGetWithStringNextLinkCollectionResult, which is used to iterate over the pages of a collection. /// The SampleTypeSpecClient client used to send requests. /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - public SampleTypeSpecClientGetWithStringNextLinkCollectionResult(SampleTypeSpecClient client, RequestOptions options) + /// The activity source for distributed tracing. + public SampleTypeSpecClientGetWithStringNextLinkCollectionResult(SampleTypeSpecClient client, RequestOptions options, ActivitySource activitySource = null) { _client = client; _options = options; + _activitySource = activitySource; } /// Gets the raw pages of the collection. @@ -34,7 +38,7 @@ public override IEnumerable GetRawPages() Uri nextPageUri = null; while (true) { - ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + ClientResult result = ExecutePageRequest(message); yield return result; string nextPageString = ((ListWithStringNextLinkResponse)result).Next; @@ -62,5 +66,20 @@ public override ContinuationToken GetContinuationToken(ClientResult page) return null; } } + + /// The pipeline message. + private ClientResult ExecutePageRequest(PipelineMessage message) + { + using Activity activity = _activitySource?.StartActivity("SampleTypeSpecClient.GetWithStringNextLink", ActivityKind.Client); + try + { + return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkCollectionResultOfT.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkCollectionResultOfT.cs index 5d4b31a80f6..67aac7b1557 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkCollectionResultOfT.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkCollectionResultOfT.cs @@ -9,21 +9,25 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; namespace SampleTypeSpec { internal partial class SampleTypeSpecClientGetWithStringNextLinkCollectionResultOfT : CollectionResult { private readonly SampleTypeSpecClient _client; + private readonly ActivitySource _activitySource; private readonly RequestOptions _options; /// Initializes a new instance of SampleTypeSpecClientGetWithStringNextLinkCollectionResultOfT, which is used to iterate over the pages of a collection. /// The SampleTypeSpecClient client used to send requests. /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - public SampleTypeSpecClientGetWithStringNextLinkCollectionResultOfT(SampleTypeSpecClient client, RequestOptions options) + /// The activity source for distributed tracing. + public SampleTypeSpecClientGetWithStringNextLinkCollectionResultOfT(SampleTypeSpecClient client, RequestOptions options, ActivitySource activitySource = null) { _client = client; _options = options; + _activitySource = activitySource; } /// Gets the raw pages of the collection. @@ -34,7 +38,7 @@ public override IEnumerable GetRawPages() Uri nextPageUri = null; while (true) { - ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + ClientResult result = ExecutePageRequest(message); yield return result; string nextPageString = ((ListWithStringNextLinkResponse)result).Next; @@ -63,6 +67,21 @@ public override ContinuationToken GetContinuationToken(ClientResult page) } } + /// The pipeline message. + private ClientResult ExecutePageRequest(PipelineMessage message) + { + using Activity activity = _activitySource?.StartActivity("SampleTypeSpecClient.GetWithStringNextLink", ActivityKind.Client); + try + { + return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } + } + /// Gets the values from the specified page. /// /// The values from the specified page. diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/DogOperations.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/DogOperations.cs index a45d14cb50f..b8f404e70b3 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/DogOperations.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/DogOperations.cs @@ -8,6 +8,7 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; @@ -17,6 +18,7 @@ namespace SampleTypeSpec public partial class DogOperations { private readonly Uri _endpoint; + private static readonly ActivitySource _activitySource = new ActivitySource("SampleTypeSpec"); /// Initializes a new instance of DogOperations for mocking. protected DogOperations() @@ -86,8 +88,17 @@ public virtual ClientResult UpdateDogAsDog(Dog dog, CancellationToken cance { Argument.AssertNotNull(dog, nameof(dog)); - ClientResult result = UpdateDogAsDog(dog, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Dog)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("DogOperations.UpdateDogAsDog", ActivityKind.Client); + try + { + ClientResult result = UpdateDogAsDog(dog, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Dog)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Update a dog as a dog. @@ -99,8 +110,17 @@ public virtual async Task> UpdateDogAsDogAsync(Dog dog, Cancel { Argument.AssertNotNull(dog, nameof(dog)); - ClientResult result = await UpdateDogAsDogAsync(dog, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Dog)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("DogOperations.UpdateDogAsDog", ActivityKind.Client); + try + { + ClientResult result = await UpdateDogAsDogAsync(dog, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Dog)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Metrics.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Metrics.cs index 8f9c0ffffb6..167a0453524 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Metrics.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Metrics.cs @@ -8,6 +8,7 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; @@ -17,6 +18,7 @@ namespace SampleTypeSpec public partial class Metrics { private readonly Uri _endpoint; + private static readonly ActivitySource _activitySource = new ActivitySource("SampleTypeSpec"); /// Initializes a new instance of Metrics for mocking. protected Metrics() @@ -98,8 +100,17 @@ public virtual async Task GetWidgetMetricsAsync(string day, Reques /// Service returned a non-success status code. public virtual ClientResult GetWidgetMetrics(DaysOfWeekExtensibleEnum day, CancellationToken cancellationToken = default) { - ClientResult result = GetWidgetMetrics(day.ToString(), cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((GetWidgetMetricsResponse)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("Metrics.GetWidgetMetrics", ActivityKind.Client); + try + { + ClientResult result = GetWidgetMetrics(day.ToString(), cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((GetWidgetMetricsResponse)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Get Widget metrics for given day of week. @@ -108,8 +119,17 @@ public virtual ClientResult GetWidgetMetrics(DaysOfWee /// Service returned a non-success status code. public virtual async Task> GetWidgetMetricsAsync(DaysOfWeekExtensibleEnum day, CancellationToken cancellationToken = default) { - ClientResult result = await GetWidgetMetricsAsync(day.ToString(), cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((GetWidgetMetricsResponse)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("Metrics.GetWidgetMetrics", ActivityKind.Client); + try + { + ClientResult result = await GetWidgetMetricsAsync(day.ToString(), cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((GetWidgetMetricsResponse)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/PetOperations.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/PetOperations.cs index 7f7531baa9d..b4b1c64e420 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/PetOperations.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/PetOperations.cs @@ -8,6 +8,7 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; @@ -17,6 +18,7 @@ namespace SampleTypeSpec public partial class PetOperations { private readonly Uri _endpoint; + private static readonly ActivitySource _activitySource = new ActivitySource("SampleTypeSpec"); /// Initializes a new instance of PetOperations for mocking. protected PetOperations() @@ -86,8 +88,17 @@ public virtual ClientResult UpdatePetAsPet(Pet pet, CancellationToken cance { Argument.AssertNotNull(pet, nameof(pet)); - ClientResult result = UpdatePetAsPet(pet, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Pet)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("PetOperations.UpdatePetAsPet", ActivityKind.Client); + try + { + ClientResult result = UpdatePetAsPet(pet, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Pet)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Update a pet as a pet. @@ -99,8 +110,17 @@ public virtual async Task> UpdatePetAsPetAsync(Pet pet, Cancel { Argument.AssertNotNull(pet, nameof(pet)); - ClientResult result = await UpdatePetAsPetAsync(pet, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Pet)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("PetOperations.UpdatePetAsPet", ActivityKind.Client); + try + { + ClientResult result = await UpdatePetAsPetAsync(pet, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Pet)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -154,8 +174,17 @@ public virtual ClientResult UpdateDogAsPet(Pet pet, CancellationToken cance { Argument.AssertNotNull(pet, nameof(pet)); - ClientResult result = UpdateDogAsPet(pet, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Pet)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("PetOperations.UpdateDogAsPet", ActivityKind.Client); + try + { + ClientResult result = UpdateDogAsPet(pet, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Pet)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Update a dog as a pet. @@ -167,8 +196,17 @@ public virtual async Task> UpdateDogAsPetAsync(Pet pet, Cancel { Argument.AssertNotNull(pet, nameof(pet)); - ClientResult result = await UpdateDogAsPetAsync(pet, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Pet)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("PetOperations.UpdateDogAsPet", ActivityKind.Client); + try + { + ClientResult result = await UpdateDogAsPetAsync(pet, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Pet)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/PlantOperations.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/PlantOperations.cs index 6db6d1ce51e..4fb0d30d0d1 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/PlantOperations.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/PlantOperations.cs @@ -8,6 +8,7 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; @@ -17,6 +18,7 @@ namespace SampleTypeSpec public partial class PlantOperations { private readonly Uri _endpoint; + private static readonly ActivitySource _activitySource = new ActivitySource("SampleTypeSpec"); /// Initializes a new instance of PlantOperations for mocking. protected PlantOperations() @@ -74,8 +76,17 @@ public virtual async Task GetTreeAsync(RequestOptions options) /// Service returned a non-success status code. public virtual ClientResult GetTree(CancellationToken cancellationToken = default) { - ClientResult result = GetTree(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("PlantOperations.GetTree", ActivityKind.Client); + try + { + ClientResult result = GetTree(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Get a tree as a plant. @@ -83,8 +94,17 @@ public virtual ClientResult GetTree(CancellationToken cancellationToken = /// Service returned a non-success status code. public virtual async Task> GetTreeAsync(CancellationToken cancellationToken = default) { - ClientResult result = await GetTreeAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("PlantOperations.GetTree", ActivityKind.Client); + try + { + ClientResult result = await GetTreeAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -126,8 +146,17 @@ public virtual async Task GetTreeAsJsonAsync(RequestOptions option /// Service returned a non-success status code. public virtual ClientResult GetTreeAsJson(CancellationToken cancellationToken = default) { - ClientResult result = GetTreeAsJson(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("PlantOperations.GetTreeAsJson", ActivityKind.Client); + try + { + ClientResult result = GetTreeAsJson(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Get a tree as a plant. @@ -135,8 +164,17 @@ public virtual ClientResult GetTreeAsJson(CancellationToken cancellationTo /// Service returned a non-success status code. public virtual async Task> GetTreeAsJsonAsync(CancellationToken cancellationToken = default) { - ClientResult result = await GetTreeAsJsonAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("PlantOperations.GetTreeAsJson", ActivityKind.Client); + try + { + ClientResult result = await GetTreeAsJsonAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -190,9 +228,18 @@ public virtual ClientResult UpdateTree(Tree tree, CancellationToken cancel { Argument.AssertNotNull(tree, nameof(tree)); - using BinaryContent content = tree.ToBinaryContent("X"); - ClientResult result = UpdateTree(content, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("PlantOperations.UpdateTree", ActivityKind.Client); + try + { + using BinaryContent content = tree.ToBinaryContent("X"); + ClientResult result = UpdateTree(content, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Update a tree as a plant. @@ -204,9 +251,18 @@ public virtual async Task> UpdateTreeAsync(Tree tree, Cancell { Argument.AssertNotNull(tree, nameof(tree)); - using BinaryContent content = tree.ToBinaryContent("X"); - ClientResult result = await UpdateTreeAsync(content, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("PlantOperations.UpdateTree", ActivityKind.Client); + try + { + using BinaryContent content = tree.ToBinaryContent("X"); + ClientResult result = await UpdateTreeAsync(content, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -260,9 +316,18 @@ public virtual ClientResult UpdateTreeAsJson(Tree tree, CancellationToken { Argument.AssertNotNull(tree, nameof(tree)); - using BinaryContent content = tree.ToBinaryContent("J"); - ClientResult result = UpdateTreeAsJson(content, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("PlantOperations.UpdateTreeAsJson", ActivityKind.Client); + try + { + using BinaryContent content = tree.ToBinaryContent("J"); + ClientResult result = UpdateTreeAsJson(content, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Update a tree as a plant. @@ -274,9 +339,18 @@ public virtual async Task> UpdateTreeAsJsonAsync(Tree tree, C { Argument.AssertNotNull(tree, nameof(tree)); - using BinaryContent content = tree.ToBinaryContent("J"); - ClientResult result = await UpdateTreeAsJsonAsync(content, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("PlantOperations.UpdateTreeAsJson", ActivityKind.Client); + try + { + using BinaryContent content = tree.ToBinaryContent("J"); + ClientResult result = await UpdateTreeAsJsonAsync(content, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecClient.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecClient.cs index f2e56c36cb0..95f59346336 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecClient.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecClient.cs @@ -9,6 +9,7 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -20,6 +21,7 @@ namespace SampleTypeSpec public partial class SampleTypeSpecClient { private readonly Uri _endpoint; + private static readonly ActivitySource _activitySource = new ActivitySource("SampleTypeSpec"); /// A credential used to authenticate to the service. private readonly ApiKeyCredential _keyCredential; private const string AuthorizationHeader = "my-api-key"; @@ -157,8 +159,17 @@ public virtual ClientResult SayHi(string headParameter, string queryParam Argument.AssertNotNullOrEmpty(headParameter, nameof(headParameter)); Argument.AssertNotNullOrEmpty(queryParameter, nameof(queryParameter)); - ClientResult result = SayHi(headParameter, queryParameter, optionalQuery, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.SayHi", ActivityKind.Client); + try + { + ClientResult result = SayHi(headParameter, queryParameter, optionalQuery, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Return hi. @@ -174,8 +185,17 @@ public virtual async Task> SayHiAsync(string headParameter, Argument.AssertNotNullOrEmpty(headParameter, nameof(headParameter)); Argument.AssertNotNullOrEmpty(queryParameter, nameof(queryParameter)); - ClientResult result = await SayHiAsync(headParameter, queryParameter, optionalQuery, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.SayHi", ActivityKind.Client); + try + { + ClientResult result = await SayHiAsync(headParameter, queryParameter, optionalQuery, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -244,8 +264,17 @@ public virtual ClientResult HelloAgain(string p2, string p1, Rou Argument.AssertNotNullOrEmpty(p1, nameof(p1)); Argument.AssertNotNull(action, nameof(action)); - ClientResult result = HelloAgain(p2, p1, action, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.HelloAgain", ActivityKind.Client); + try + { + ClientResult result = HelloAgain(p2, p1, action, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Return hi again. @@ -262,8 +291,17 @@ public virtual async Task> HelloAgainAsync(string p Argument.AssertNotNullOrEmpty(p1, nameof(p1)); Argument.AssertNotNull(action, nameof(action)); - ClientResult result = await HelloAgainAsync(p2, p1, action, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.HelloAgain", ActivityKind.Client); + try + { + ClientResult result = await HelloAgainAsync(p2, p1, action, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -327,8 +365,17 @@ public virtual ClientResult NoContentType(Wrapper info, Cancella { Argument.AssertNotNull(info, nameof(info)); - ClientResult result = NoContentType(info.P2, info.P1, info.Action, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.NoContentType", ActivityKind.Client); + try + { + ClientResult result = NoContentType(info.P2, info.P1, info.Action, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Return hi again. @@ -340,8 +387,17 @@ public virtual async Task> NoContentTypeAsync(Wrapp { Argument.AssertNotNull(info, nameof(info)); - ClientResult result = await NoContentTypeAsync(info.P2, info.P1, info.Action, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.NoContentType", ActivityKind.Client); + try + { + ClientResult result = await NoContentTypeAsync(info.P2, info.P1, info.Action, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -383,8 +439,17 @@ public virtual async Task HelloDemo2Async(RequestOptions options) /// Service returned a non-success status code. public virtual ClientResult HelloDemo2(CancellationToken cancellationToken = default) { - ClientResult result = HelloDemo2(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.HelloDemo2", ActivityKind.Client); + try + { + ClientResult result = HelloDemo2(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Return hi in demo2. @@ -392,8 +457,17 @@ public virtual ClientResult HelloDemo2(CancellationToken cancellationToke /// Service returned a non-success status code. public virtual async Task> HelloDemo2Async(CancellationToken cancellationToken = default) { - ClientResult result = await HelloDemo2Async(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.HelloDemo2", ActivityKind.Client); + try + { + ClientResult result = await HelloDemo2Async(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -447,8 +521,17 @@ public virtual ClientResult CreateLiteral(Thing body, CancellationToken c { Argument.AssertNotNull(body, nameof(body)); - ClientResult result = CreateLiteral(body, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.CreateLiteral", ActivityKind.Client); + try + { + ClientResult result = CreateLiteral(body, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Create with literal value. @@ -460,8 +543,17 @@ public virtual async Task> CreateLiteralAsync(Thing body, Ca { Argument.AssertNotNull(body, nameof(body)); - ClientResult result = await CreateLiteralAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.CreateLiteral", ActivityKind.Client); + try + { + ClientResult result = await CreateLiteralAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -503,8 +595,17 @@ public virtual async Task HelloLiteralAsync(RequestOptions options /// Service returned a non-success status code. public virtual ClientResult HelloLiteral(CancellationToken cancellationToken = default) { - ClientResult result = HelloLiteral(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.HelloLiteral", ActivityKind.Client); + try + { + ClientResult result = HelloLiteral(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Send literal parameters. @@ -512,8 +613,17 @@ public virtual ClientResult HelloLiteral(CancellationToken cancellationTo /// Service returned a non-success status code. public virtual async Task> HelloLiteralAsync(CancellationToken cancellationToken = default) { - ClientResult result = await HelloLiteralAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.HelloLiteral", ActivityKind.Client); + try + { + ClientResult result = await HelloLiteralAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -558,8 +668,17 @@ public virtual async Task TopActionAsync(DateTimeOffset action, Re /// Service returned a non-success status code. public virtual ClientResult TopAction(DateTimeOffset action, CancellationToken cancellationToken = default) { - ClientResult result = TopAction(action, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.TopAction", ActivityKind.Client); + try + { + ClientResult result = TopAction(action, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// top level method. @@ -568,8 +687,17 @@ public virtual ClientResult TopAction(DateTimeOffset action, Cancellation /// Service returned a non-success status code. public virtual async Task> TopActionAsync(DateTimeOffset action, CancellationToken cancellationToken = default) { - ClientResult result = await TopActionAsync(action, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.TopAction", ActivityKind.Client); + try + { + ClientResult result = await TopActionAsync(action, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -718,27 +846,36 @@ public virtual ClientResult AnonymousBody(string name, BinaryData require Argument.AssertNotNullOrEmpty(requiredBadDescription, nameof(requiredBadDescription)); Argument.AssertNotNullOrEmpty(propertyWithSpecialDocs, nameof(propertyWithSpecialDocs)); - Thing spreadModel = new Thing( - default, - requiredUnion, - "accept", - requiredNullableString, - optionalNullableString, - 123, - 1.23F, - false, - optionalLiteralString, - requiredNullableLiteralString, - optionalLiteralInt, - optionalLiteralFloat, - optionalLiteralBool, - requiredBadDescription, - optionalNullableList?.ToList() as IList ?? new ChangeTrackingList(), - requiredNullableList?.ToList() as IList ?? new ChangeTrackingList(), - propertyWithSpecialDocs, - default); - ClientResult result = AnonymousBody(spreadModel, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.AnonymousBody", ActivityKind.Client); + try + { + Thing spreadModel = new Thing( + default, + requiredUnion, + "accept", + requiredNullableString, + optionalNullableString, + 123, + 1.23F, + false, + optionalLiteralString, + requiredNullableLiteralString, + optionalLiteralInt, + optionalLiteralFloat, + optionalLiteralBool, + requiredBadDescription, + optionalNullableList?.ToList() as IList ?? new ChangeTrackingList(), + requiredNullableList?.ToList() as IList ?? new ChangeTrackingList(), + propertyWithSpecialDocs, + default); + ClientResult result = AnonymousBody(spreadModel, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// body parameter without body decorator. @@ -769,27 +906,36 @@ public virtual async Task> AnonymousBodyAsync(string name, B Argument.AssertNotNullOrEmpty(requiredBadDescription, nameof(requiredBadDescription)); Argument.AssertNotNullOrEmpty(propertyWithSpecialDocs, nameof(propertyWithSpecialDocs)); - Thing spreadModel = new Thing( - default, - requiredUnion, - "accept", - requiredNullableString, - optionalNullableString, - 123, - 1.23F, - false, - optionalLiteralString, - requiredNullableLiteralString, - optionalLiteralInt, - optionalLiteralFloat, - optionalLiteralBool, - requiredBadDescription, - optionalNullableList?.ToList() as IList ?? new ChangeTrackingList(), - requiredNullableList?.ToList() as IList ?? new ChangeTrackingList(), - propertyWithSpecialDocs, - default); - ClientResult result = await AnonymousBodyAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.AnonymousBody", ActivityKind.Client); + try + { + Thing spreadModel = new Thing( + default, + requiredUnion, + "accept", + requiredNullableString, + optionalNullableString, + 123, + 1.23F, + false, + optionalLiteralString, + requiredNullableLiteralString, + optionalLiteralInt, + optionalLiteralFloat, + optionalLiteralBool, + requiredBadDescription, + optionalNullableList?.ToList() as IList ?? new ChangeTrackingList(), + requiredNullableList?.ToList() as IList ?? new ChangeTrackingList(), + propertyWithSpecialDocs, + default); + ClientResult result = await AnonymousBodyAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -844,9 +990,18 @@ public virtual ClientResult FriendlyModel(string name, CancellationToken { Argument.AssertNotNullOrEmpty(name, nameof(name)); - Friend spreadModel = new Friend(name, default); - ClientResult result = FriendlyModel(spreadModel, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Friend)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.FriendlyModel", ActivityKind.Client); + try + { + Friend spreadModel = new Friend(name, default); + ClientResult result = FriendlyModel(spreadModel, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Friend)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Model can have its friendly name. @@ -859,9 +1014,18 @@ public virtual async Task> FriendlyModelAsync(string name, { Argument.AssertNotNullOrEmpty(name, nameof(name)); - Friend spreadModel = new Friend(name, default); - ClientResult result = await FriendlyModelAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Friend)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.FriendlyModel", ActivityKind.Client); + try + { + Friend spreadModel = new Friend(name, default); + ClientResult result = await FriendlyModelAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Friend)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -903,7 +1067,16 @@ public virtual async Task AddTimeHeaderAsync(RequestOptions option /// Service returned a non-success status code. public virtual ClientResult AddTimeHeader(CancellationToken cancellationToken = default) { - return AddTimeHeader(cancellationToken.ToRequestOptions()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.AddTimeHeader", ActivityKind.Client); + try + { + return AddTimeHeader(cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// AddTimeHeader. @@ -911,7 +1084,16 @@ public virtual ClientResult AddTimeHeader(CancellationToken cancellationToken = /// Service returned a non-success status code. public virtual async Task AddTimeHeaderAsync(CancellationToken cancellationToken = default) { - return await AddTimeHeaderAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.AddTimeHeader", ActivityKind.Client); + try + { + return await AddTimeHeaderAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -966,9 +1148,18 @@ public virtual ClientResult ProjectedNameModel(string otherN { Argument.AssertNotNullOrEmpty(otherName, nameof(otherName)); - RenamedModelCustom spreadModel = new RenamedModelCustom(default, otherName); - ClientResult result = ProjectedNameModel(spreadModel, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((RenamedModelCustom)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.ProjectedNameModel", ActivityKind.Client); + try + { + RenamedModelCustom spreadModel = new RenamedModelCustom(default, otherName); + ClientResult result = ProjectedNameModel(spreadModel, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((RenamedModelCustom)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Model can have its projected name. @@ -981,9 +1172,18 @@ public virtual async Task> ProjectedNameModelAs { Argument.AssertNotNullOrEmpty(otherName, nameof(otherName)); - RenamedModelCustom spreadModel = new RenamedModelCustom(default, otherName); - ClientResult result = await ProjectedNameModelAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((RenamedModelCustom)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.ProjectedNameModel", ActivityKind.Client); + try + { + RenamedModelCustom spreadModel = new RenamedModelCustom(default, otherName); + ClientResult result = await ProjectedNameModelAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((RenamedModelCustom)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -1025,8 +1225,17 @@ public virtual async Task ReturnsAnonymousModelAsync(RequestOption /// Service returned a non-success status code. public virtual ClientResult ReturnsAnonymousModel(CancellationToken cancellationToken = default) { - ClientResult result = ReturnsAnonymousModel(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((ReturnsAnonymousModelResponse)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.ReturnsAnonymousModel", ActivityKind.Client); + try + { + ClientResult result = ReturnsAnonymousModel(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((ReturnsAnonymousModelResponse)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// return anonymous model. @@ -1034,8 +1243,17 @@ public virtual ClientResult ReturnsAnonymousModel /// Service returned a non-success status code. public virtual async Task> ReturnsAnonymousModelAsync(CancellationToken cancellationToken = default) { - ClientResult result = await ReturnsAnonymousModelAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((ReturnsAnonymousModelResponse)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.ReturnsAnonymousModel", ActivityKind.Client); + try + { + ClientResult result = await ReturnsAnonymousModelAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((ReturnsAnonymousModelResponse)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -1092,8 +1310,17 @@ public virtual ClientResult GetUnknownValue(string accept, CancellationT { Argument.AssertNotNullOrEmpty(accept, nameof(accept)); - ClientResult result = GetUnknownValue(accept, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue(result.GetRawResponse().Content.ToString(), result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.GetUnknownValue", ActivityKind.Client); + try + { + ClientResult result = GetUnknownValue(accept, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue(result.GetRawResponse().Content.ToString(), result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// get extensible enum. @@ -1106,8 +1333,17 @@ public virtual async Task> GetUnknownValueAsync(string acce { Argument.AssertNotNullOrEmpty(accept, nameof(accept)); - ClientResult result = await GetUnknownValueAsync(accept, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue(result.GetRawResponse().Content.ToString(), result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.GetUnknownValue", ActivityKind.Client); + try + { + ClientResult result = await GetUnknownValueAsync(accept, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue(result.GetRawResponse().Content.ToString(), result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -1161,8 +1397,17 @@ public virtual ClientResult InternalProtocol(Thing body, CancellationToke { Argument.AssertNotNull(body, nameof(body)); - ClientResult result = InternalProtocol(body, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.InternalProtocol", ActivityKind.Client); + try + { + ClientResult result = InternalProtocol(body, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// When set protocol false and convenient true, then the protocol method should be internal. @@ -1174,8 +1419,17 @@ public virtual async Task> InternalProtocolAsync(Thing body, { Argument.AssertNotNull(body, nameof(body)); - ClientResult result = await InternalProtocolAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.InternalProtocol", ActivityKind.Client); + try + { + ClientResult result = await InternalProtocolAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -1217,7 +1471,16 @@ public virtual async Task StillConvenientAsync(RequestOptions opti /// Service returned a non-success status code. public virtual ClientResult StillConvenient(CancellationToken cancellationToken = default) { - return StillConvenient(cancellationToken.ToRequestOptions()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.StillConvenient", ActivityKind.Client); + try + { + return StillConvenient(cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// When set protocol false and convenient true, the convenient method should be generated even it has the same signature as protocol one. @@ -1225,7 +1488,16 @@ public virtual ClientResult StillConvenient(CancellationToken cancellationToken /// Service returned a non-success status code. public virtual async Task StillConvenientAsync(CancellationToken cancellationToken = default) { - return await StillConvenientAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.StillConvenient", ActivityKind.Client); + try + { + return await StillConvenientAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -1282,7 +1554,16 @@ public virtual ClientResult HeadAsBoolean(string id, CancellationToken cancellat { Argument.AssertNotNullOrEmpty(id, nameof(id)); - return HeadAsBoolean(id, cancellationToken.ToRequestOptions()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.HeadAsBoolean", ActivityKind.Client); + try + { + return HeadAsBoolean(id, cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// head as boolean. @@ -1295,7 +1576,16 @@ public virtual async Task HeadAsBooleanAsync(string id, Cancellati { Argument.AssertNotNullOrEmpty(id, nameof(id)); - return await HeadAsBooleanAsync(id, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.HeadAsBoolean", ActivityKind.Client); + try + { + return await HeadAsBooleanAsync(id, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -1352,7 +1642,16 @@ public virtual ClientResult WithApiVersion(string p1, CancellationToken cancella { Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - return WithApiVersion(p1, cancellationToken.ToRequestOptions()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.WithApiVersion", ActivityKind.Client); + try + { + return WithApiVersion(p1, cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Return hi again. @@ -1365,7 +1664,16 @@ public virtual async Task WithApiVersionAsync(string p1, Cancellat { Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - return await WithApiVersionAsync(p1, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.WithApiVersion", ActivityKind.Client); + try + { + return await WithApiVersionAsync(p1, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -1405,7 +1713,7 @@ public virtual AsyncCollectionResult GetWithNextLinkAsync(RequestOptions options /// Service returned a non-success status code. public virtual CollectionResult GetWithNextLink(CancellationToken cancellationToken = default) { - return new SampleTypeSpecClientGetWithNextLinkCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + return new SampleTypeSpecClientGetWithNextLinkCollectionResultOfT(this, cancellationToken.ToRequestOptions(), _activitySource); } /// List things with nextlink. @@ -1413,7 +1721,7 @@ public virtual CollectionResult GetWithNextLink(CancellationToken cancell /// Service returned a non-success status code. public virtual AsyncCollectionResult GetWithNextLinkAsync(CancellationToken cancellationToken = default) { - return new SampleTypeSpecClientGetWithNextLinkAsyncCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + return new SampleTypeSpecClientGetWithNextLinkAsyncCollectionResultOfT(this, cancellationToken.ToRequestOptions(), _activitySource); } /// @@ -1453,7 +1761,7 @@ public virtual AsyncCollectionResult GetWithStringNextLinkAsync(RequestOptions o /// Service returned a non-success status code. public virtual CollectionResult GetWithStringNextLink(CancellationToken cancellationToken = default) { - return new SampleTypeSpecClientGetWithStringNextLinkCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + return new SampleTypeSpecClientGetWithStringNextLinkCollectionResultOfT(this, cancellationToken.ToRequestOptions(), _activitySource); } /// List things with nextlink. @@ -1461,7 +1769,7 @@ public virtual CollectionResult GetWithStringNextLink(CancellationToken c /// Service returned a non-success status code. public virtual AsyncCollectionResult GetWithStringNextLinkAsync(CancellationToken cancellationToken = default) { - return new SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + return new SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT(this, cancellationToken.ToRequestOptions(), _activitySource); } /// @@ -1504,7 +1812,7 @@ public virtual AsyncCollectionResult GetWithContinuationTokenAsync(string token, /// Service returned a non-success status code. public virtual CollectionResult GetWithContinuationToken(string token = default, CancellationToken cancellationToken = default) { - return new SampleTypeSpecClientGetWithContinuationTokenCollectionResultOfT(this, token, cancellationToken.ToRequestOptions()); + return new SampleTypeSpecClientGetWithContinuationTokenCollectionResultOfT(this, token, cancellationToken.ToRequestOptions(), _activitySource); } /// List things with continuation token. @@ -1513,7 +1821,7 @@ public virtual CollectionResult GetWithContinuationToken(string token = d /// Service returned a non-success status code. public virtual AsyncCollectionResult GetWithContinuationTokenAsync(string token = default, CancellationToken cancellationToken = default) { - return new SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResultOfT(this, token, cancellationToken.ToRequestOptions()); + return new SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResultOfT(this, token, cancellationToken.ToRequestOptions(), _activitySource); } /// @@ -1556,7 +1864,7 @@ public virtual AsyncCollectionResult GetWithContinuationTokenHeaderResponseAsync /// Service returned a non-success status code. public virtual CollectionResult GetWithContinuationTokenHeaderResponse(string token = default, CancellationToken cancellationToken = default) { - return new SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResultOfT(this, token, cancellationToken.ToRequestOptions()); + return new SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResultOfT(this, token, cancellationToken.ToRequestOptions(), _activitySource); } /// List things with continuation token header response. @@ -1565,7 +1873,7 @@ public virtual CollectionResult GetWithContinuationTokenHeaderResponse(st /// Service returned a non-success status code. public virtual AsyncCollectionResult GetWithContinuationTokenHeaderResponseAsync(string token = default, CancellationToken cancellationToken = default) { - return new SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResultOfT(this, token, cancellationToken.ToRequestOptions()); + return new SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResultOfT(this, token, cancellationToken.ToRequestOptions(), _activitySource); } /// @@ -1605,7 +1913,7 @@ public virtual AsyncCollectionResult GetWithPagingAsync(RequestOptions options) /// Service returned a non-success status code. public virtual CollectionResult GetWithPaging(CancellationToken cancellationToken = default) { - return new SampleTypeSpecClientGetWithPagingCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + return new SampleTypeSpecClientGetWithPagingCollectionResultOfT(this, cancellationToken.ToRequestOptions(), _activitySource); } /// List things with paging. @@ -1613,7 +1921,7 @@ public virtual CollectionResult GetWithPaging(CancellationToken cancellat /// Service returned a non-success status code. public virtual AsyncCollectionResult GetWithPagingAsync(CancellationToken cancellationToken = default) { - return new SampleTypeSpecClientGetWithPagingAsyncCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + return new SampleTypeSpecClientGetWithPagingAsyncCollectionResultOfT(this, cancellationToken.ToRequestOptions(), _activitySource); } /// @@ -1681,7 +1989,16 @@ public virtual ClientResult EmbeddedParameters(ModelWithEmbeddedNonBodyParameter { Argument.AssertNotNull(body, nameof(body)); - return EmbeddedParameters(body.RequiredHeader, body.RequiredQuery, body, body.OptionalHeader, body.OptionalQuery, cancellationToken.ToRequestOptions()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.EmbeddedParameters", ActivityKind.Client); + try + { + return EmbeddedParameters(body.RequiredHeader, body.RequiredQuery, body, body.OptionalHeader, body.OptionalQuery, cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// An operation with embedded parameters within the body. @@ -1693,7 +2010,16 @@ public virtual async Task EmbeddedParametersAsync(ModelWithEmbedde { Argument.AssertNotNull(body, nameof(body)); - return await EmbeddedParametersAsync(body.RequiredHeader, body.RequiredQuery, body, body.OptionalHeader, body.OptionalQuery, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.EmbeddedParameters", ActivityKind.Client); + try + { + return await EmbeddedParametersAsync(body.RequiredHeader, body.RequiredQuery, body, body.OptionalHeader, body.OptionalQuery, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -1747,7 +2073,16 @@ public virtual ClientResult DynamicModelOperation(DynamicModel body, Cancellatio { Argument.AssertNotNull(body, nameof(body)); - return DynamicModelOperation(body, cancellationToken.ToRequestOptions()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.DynamicModelOperation", ActivityKind.Client); + try + { + return DynamicModelOperation(body, cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// An operation with a dynamic model. @@ -1759,7 +2094,16 @@ public virtual async Task DynamicModelOperationAsync(DynamicModel { Argument.AssertNotNull(body, nameof(body)); - return await DynamicModelOperationAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.DynamicModelOperation", ActivityKind.Client); + try + { + return await DynamicModelOperationAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -1801,8 +2145,17 @@ public virtual async Task GetXmlAdvancedModelAsync(RequestOptions /// Service returned a non-success status code. public virtual ClientResult GetXmlAdvancedModel(CancellationToken cancellationToken = default) { - ClientResult result = GetXmlAdvancedModel(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.GetXmlAdvancedModel", ActivityKind.Client); + try + { + ClientResult result = GetXmlAdvancedModel(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Get an advanced XML model with various property types. @@ -1810,8 +2163,17 @@ public virtual ClientResult GetXmlAdvancedModel(CancellationTo /// Service returned a non-success status code. public virtual async Task> GetXmlAdvancedModelAsync(CancellationToken cancellationToken = default) { - ClientResult result = await GetXmlAdvancedModelAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.GetXmlAdvancedModel", ActivityKind.Client); + try + { + ClientResult result = await GetXmlAdvancedModelAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// @@ -1865,8 +2227,17 @@ public virtual ClientResult UpdateXmlAdvancedModel(XmlAdvanced { Argument.AssertNotNull(body, nameof(body)); - ClientResult result = UpdateXmlAdvancedModel(body, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.UpdateXmlAdvancedModel", ActivityKind.Client); + try + { + ClientResult result = UpdateXmlAdvancedModel(body, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Update an advanced XML model with various property types. @@ -1878,8 +2249,17 @@ public virtual async Task> UpdateXmlAdvancedModel { Argument.AssertNotNull(body, nameof(body)); - ClientResult result = await UpdateXmlAdvancedModelAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); + using Activity activity = _activitySource.StartActivity("SampleTypeSpecClient.UpdateXmlAdvancedModel", ActivityKind.Client); + try + { + ClientResult result = await UpdateXmlAdvancedModelAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); + } + catch (Exception ex) + { + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } /// Initializes a new instance of AnimalOperations. diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/api-key/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/api-key/Configuration.json index a44e714e395..035f2081f98 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/api-key/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/api-key/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Authentication.ApiKey" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/http/custom/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/http/custom/Configuration.json index 26b8aa910d3..cc063137721 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/http/custom/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/http/custom/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Authentication.Http.Custom" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/oauth2/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/oauth2/Configuration.json index b7899aea872..7777f2aab51 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/oauth2/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/oauth2/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Authentication.OAuth2" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/union/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/union/Configuration.json index 5e333f3ee24..c4c745fe2ff 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/union/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/union/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Authentication.Union" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/client-operation-group/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/client-operation-group/Configuration.json index 553878dcc41..fb5bcd90bd8 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/client-operation-group/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/client-operation-group/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Client.Structure.Service" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/default/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/default/Configuration.json index e75adbce7d4..e60df20b84c 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/default/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/default/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Client.Structure.Service.Default" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/multi-client/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/multi-client/Configuration.json index cd7567f13fd..1edcec08c28 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/multi-client/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/multi-client/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Client.Structure.Service.Multi.Client" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/renamed-operation/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/renamed-operation/Configuration.json index 2c423376a5d..fe5abb223d1 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/renamed-operation/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/renamed-operation/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Client.Structure.Service.Renamed.Operation" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/two-operation-group/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/two-operation-group/Configuration.json index 58a22dafa6e..da51b8cf774 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/two-operation-group/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/two-operation-group/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Client.Structure.Service.TwoOperationGroup" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/documentation/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/documentation/Configuration.json index 3335831568c..5464bb22227 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/documentation/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/documentation/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Documentation" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/encode/array/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/encode/array/Configuration.json index 8bd0bb4f945..c03fc48bf93 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/encode/array/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/encode/array/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Encode.Array" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/encode/bytes/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/encode/bytes/Configuration.json index 48efce938b5..030f9410a0f 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/encode/bytes/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/encode/bytes/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Encode.Bytes" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/encode/datetime/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/encode/datetime/Configuration.json index 0a0a84d86e4..d14072a85f8 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/encode/datetime/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/encode/datetime/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Encode.Datetime" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/encode/duration/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/encode/duration/Configuration.json index e90188553c2..7b3d3e35934 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/encode/duration/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/encode/duration/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Encode.Duration" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/encode/numeric/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/encode/numeric/Configuration.json index e4685321069..f0e51ed86e3 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/encode/numeric/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/encode/numeric/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Encode.Numeric" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/basic/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/basic/Configuration.json index 481cf25b9ee..04cdf49e82b 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/basic/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/basic/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Parameters.Basic" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-optionality/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-optionality/Configuration.json index 87417f1028e..5a36f3d4c5e 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-optionality/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-optionality/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Parameters.BodyOptionality" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/collection-format/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/collection-format/Configuration.json index 96a68122676..6467873cfb9 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/collection-format/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/collection-format/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Parameters.CollectionFormat" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/path/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/path/Configuration.json index 1c48fac1025..4d9295fbdb1 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/path/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/path/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Parameters.Path" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/Configuration.json index 18b95047fda..c05e4703f1e 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Parameters.Query" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/spread/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/spread/Configuration.json index 18cbb063e8d..5903e41fad9 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/spread/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/spread/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Parameters.Spread" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/content-negotiation/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/content-negotiation/Configuration.json index 804b2d9bd5f..66596f12ec6 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/content-negotiation/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/content-negotiation/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Payload.ContentNegotiation" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/json-merge-patch/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/json-merge-patch/Configuration.json index 4b0db821922..ee92289e3c3 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/json-merge-patch/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/json-merge-patch/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Payload.JsonMergePatch" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/media-type/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/media-type/Configuration.json index e5d0e20486a..2c5f6a2e7fc 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/media-type/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/media-type/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Payload.MediaType" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/multipart/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/multipart/Configuration.json index a4e60904404..ac9ded5e277 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/multipart/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/multipart/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Payload.MultiPart" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/pageable/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/pageable/Configuration.json index a8b33a617ab..84ed0d3246d 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/pageable/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/pageable/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Payload.Pageable" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/Configuration.json index a7354dd1925..060aab31f11 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Payload.Xml" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/resiliency/srv-driven/v1/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/resiliency/srv-driven/v1/Configuration.json index e1c0feb0334..1e0f5c6091d 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/resiliency/srv-driven/v1/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/resiliency/srv-driven/v1/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Resiliency.SrvDriven.V1" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/resiliency/srv-driven/v2/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/resiliency/srv-driven/v2/Configuration.json index cda8e93495c..d7d10ec4356 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/resiliency/srv-driven/v2/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/resiliency/srv-driven/v2/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Resiliency.SrvDriven.V2" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/response/status-code-range/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/response/status-code-range/Configuration.json index 20947b8a356..5adc80dbebc 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/response/status-code-range/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/response/status-code-range/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Response.StatusCodeRange" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/routes/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/routes/Configuration.json index b2443847ee1..e84bc9b2548 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/routes/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/routes/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Routes" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/serialization/encoded-name/json/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/serialization/encoded-name/json/Configuration.json index 67ae85dad77..61a8da35054 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/serialization/encoded-name/json/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/serialization/encoded-name/json/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Serialization.EncodedName.Json" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/server/endpoint/not-defined/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/server/endpoint/not-defined/Configuration.json index ffea67465e2..b11b4a61bc1 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/server/endpoint/not-defined/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/server/endpoint/not-defined/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Server.Endpoint.NotDefined" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/server/path/multiple/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/server/path/multiple/Configuration.json index d4233efb232..d19ef11cc78 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/server/path/multiple/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/server/path/multiple/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Server.Path.Multiple" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/server/path/single/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/server/path/single/Configuration.json index ee6ea4b1942..5b0f161badd 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/server/path/single/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/server/path/single/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Server.Path.Single" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/server/versions/not-versioned/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/server/versions/not-versioned/Configuration.json index 85d581eec3e..2086b5a4fdc 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/server/versions/not-versioned/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/server/versions/not-versioned/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Server.Versions.NotVersioned" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/server/versions/versioned/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/server/versions/versioned/Configuration.json index 4e9a6472ce2..f651a51f2b8 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/server/versions/versioned/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/server/versions/versioned/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Server.Versions.Versioned" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/special-headers/conditional-request/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/special-headers/conditional-request/Configuration.json index 6c924699d48..540062f0ea4 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/special-headers/conditional-request/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/special-headers/conditional-request/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "SpecialHeaders.ConditionalRequest" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/special-headers/repeatability/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/special-headers/repeatability/Configuration.json index 04f07c86704..4b3effe7978 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/special-headers/repeatability/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/special-headers/repeatability/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "SpecialHeaders.Repeatability" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/special-words/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/special-words/Configuration.json index 86cff884aea..a797f380597 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/special-words/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/special-words/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "SpecialWords" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/array/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/array/Configuration.json index fd8654bd80d..d3622607708 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/array/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/array/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Type.Array" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/dictionary/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/dictionary/Configuration.json index b86c2d49328..3258334efb0 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/dictionary/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/dictionary/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Type.Dictionary" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/enum/extensible/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/enum/extensible/Configuration.json index 3f63e3ba1da..fa3bee416cf 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/enum/extensible/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/enum/extensible/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Type.Enum.Extensible" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/enum/fixed/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/enum/fixed/Configuration.json index 6e0a90c0ca3..dade51b58a2 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/enum/fixed/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/enum/fixed/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Type.Enum.Fixed" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/empty/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/empty/Configuration.json index 2869a238afc..b6e8a9de3ee 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/empty/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/empty/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Type.Model.Empty" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/enum-discriminator/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/enum-discriminator/Configuration.json index 7d4e0762f65..1945dd8eeb8 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/enum-discriminator/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/enum-discriminator/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Type.Model.Inheritance.EnumDiscriminator" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/nested-discriminator/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/nested-discriminator/Configuration.json index 1d4ccc8b5fe..23a818ba5f6 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/nested-discriminator/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/nested-discriminator/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Type.Model.Inheritance.NestedDiscriminator" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/not-discriminated/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/not-discriminated/Configuration.json index 307a5dce4f5..c2c403b032b 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/not-discriminated/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/not-discriminated/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Type.Model.Inheritance.NotDiscriminated" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/recursive/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/recursive/Configuration.json index dd38b6f0328..c06197b0740 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/recursive/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/recursive/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Type.Model.Inheritance.Recursive" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/Configuration.json index 63b51a5d6fc..8301560150e 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Type.Model.Inheritance.SingleDiscriminator" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/usage/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/usage/Configuration.json index dcf477b29ba..48bb442cb24 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/usage/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/usage/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Type.Model.Usage" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/visibility/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/visibility/Configuration.json index 098d67ccb5f..edae200108a 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/visibility/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/visibility/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Type.Model.Visibility" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/property/additional-properties/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/property/additional-properties/Configuration.json index 3a64aca40cf..0afa0e9b064 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/property/additional-properties/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/property/additional-properties/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Type.Property.AdditionalProperties" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/property/nullable/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/property/nullable/Configuration.json index 8843693bc40..67ee217b895 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/property/nullable/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/property/nullable/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Type.Property.Nullable" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/property/optionality/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/property/optionality/Configuration.json index 4d9a2e48d18..5439be53b71 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/property/optionality/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/property/optionality/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Type.Property.Optional" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/property/value-types/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/property/value-types/Configuration.json index d7ad85315d2..0d1aefa10ea 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/property/value-types/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/property/value-types/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Type.Property.ValueTypes" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/scalar/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/scalar/Configuration.json index 14a986ecea4..b63810cc117 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/scalar/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/scalar/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Type.Scalar" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/Configuration.json index a03ddf04c20..aafbee1fcee 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Type.Union" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/added/v1/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/added/v1/Configuration.json index fced31fd667..c51477a7f97 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/added/v1/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/added/v1/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Versioning.Added.V1" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/added/v2/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/added/v2/Configuration.json index 4ec3e56aec9..4c6b6f45523 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/added/v2/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/added/v2/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Versioning.Added.V2" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/madeOptional/v1/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/madeOptional/v1/Configuration.json index 1b156b851a2..2d4f72de89e 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/madeOptional/v1/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/madeOptional/v1/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Versioning.MadeOptional.V1" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/madeOptional/v2/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/madeOptional/v2/Configuration.json index 09874324060..18f0aa608f3 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/madeOptional/v2/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/madeOptional/v2/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Versioning.MadeOptional.V2" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/removed/v1/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/removed/v1/Configuration.json index bb3e37ca9a2..1a856443fd5 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/removed/v1/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/removed/v1/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Versioning.Removed.V1" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/removed/v2/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/removed/v2/Configuration.json index 936dc888824..1b803a6a366 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/removed/v2/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/removed/v2/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Versioning.Removed.V2" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/removed/v2Preview/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/removed/v2Preview/Configuration.json index b8a4b1ee2ec..747bbb4098a 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/removed/v2Preview/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/removed/v2Preview/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Versioning.Removed.V2Preview" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/renamedFrom/v1/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/renamedFrom/v1/Configuration.json index 01c11ac4101..b9452fcea46 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/renamedFrom/v1/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/renamedFrom/v1/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Versioning.RenamedFrom.V1" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/renamedFrom/v2/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/renamedFrom/v2/Configuration.json index fb28ade7416..a73919050e2 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/renamedFrom/v2/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/renamedFrom/v2/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Versioning.RenamedFrom.V2" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/returnTypeChangedFrom/v1/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/returnTypeChangedFrom/v1/Configuration.json index 40b00692dfc..428d3846bfa 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/returnTypeChangedFrom/v1/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/returnTypeChangedFrom/v1/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Versioning.ReturnTypeChangedFrom.V1" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/returnTypeChangedFrom/v2/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/returnTypeChangedFrom/v2/Configuration.json index f6801f05d79..d14631361c6 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/returnTypeChangedFrom/v2/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/returnTypeChangedFrom/v2/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Versioning.ReturnTypeChangedFrom.V2" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/typeChangedFrom/v1/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/typeChangedFrom/v1/Configuration.json index 3e3258c3e7e..17217ee2396 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/typeChangedFrom/v1/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/typeChangedFrom/v1/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Versioning.TypeChangedFrom.V1" } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/typeChangedFrom/v2/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/typeChangedFrom/v2/Configuration.json index 270c0344667..8629a8b0ee8 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/typeChangedFrom/v2/Configuration.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/versioning/typeChangedFrom/v2/Configuration.json @@ -1,3 +1,4 @@ { + "generate-method-instrumentation": true, "package-name": "Versioning.TypeChangedFrom.V2" }