|
| 1 | +${className}::InvokeOutcome ${className}::InvokeServiceOperation( |
| 2 | + const AmazonWebServiceRequest& request, |
| 3 | +#if($metadata.protocol == "rest-json" || $metadata.protocol == "rest-xml") |
| 4 | + const std::function<void(Aws::Endpoint::ResolveEndpointOutcome&)>& resolveUri, |
| 5 | +#end |
| 6 | +#if($serviceModel.metadata.namespace == "S3" || $serviceModel.metadata.namespace == "S3Crt") |
| 7 | + Aws::String bucketName, |
| 8 | +#end |
| 9 | + Aws::Http::HttpMethod httpMethod |
| 10 | +) const |
| 11 | +{ |
| 12 | + auto operationName = request.GetServiceRequestName(); |
| 13 | + auto serviceName = GetServiceClientName(); |
| 14 | + |
| 15 | + AWS_OPERATION_GUARD_DYNAMIC(operationName); |
| 16 | + |
| 17 | + AWS_OPERATION_CHECK_PTR_DYNAMIC(m_endpointProvider, operationName, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE); |
| 18 | + AWS_OPERATION_CHECK_PTR_DYNAMIC(m_telemetryProvider, operationName, CoreErrors, CoreErrors::NOT_INITIALIZED); |
| 19 | + |
| 20 | + auto tracer = m_telemetryProvider->getTracer(serviceName, {}); |
| 21 | + auto meter = m_telemetryProvider->getMeter(serviceName, {}); |
| 22 | + AWS_OPERATION_CHECK_PTR_DYNAMIC(meter, operationName, CoreErrors, CoreErrors::NOT_INITIALIZED); |
| 23 | + |
| 24 | + auto span = tracer->CreateSpan(Aws::String(serviceName) + "." + operationName, |
| 25 | + {{TracingUtils::SMITHY_METHOD_DIMENSION, operationName}, |
| 26 | + {TracingUtils::SMITHY_SERVICE_DIMENSION, serviceName}, |
| 27 | + {TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE}}, |
| 28 | + smithy::components::tracing::SpanKind::CLIENT); |
| 29 | + |
| 30 | +#if($serviceModel.metadata.namespace == "S3" || $serviceModel.metadata.namespace == "S3Crt") |
| 31 | + if (!bucketName.empty()) { |
| 32 | + request.SetServiceSpecificParameters([bucketName]() -> std::shared_ptr<Http::ServiceSpecificParameters> { |
| 33 | + Aws::Map<Aws::String, Aws::String> params; |
| 34 | + params.emplace("bucketName", bucketName); |
| 35 | + ServiceSpecificParameters serviceSpecificParameters{params}; |
| 36 | + return Aws::MakeShared<ServiceSpecificParameters>(ALLOCATION_TAG, serviceSpecificParameters); |
| 37 | + }()); |
| 38 | + } |
| 39 | +#end |
| 40 | + |
| 41 | + return TracingUtils::MakeCallWithTiming<InvokeOutcome>( |
| 42 | + [&]() -> InvokeOutcome { |
| 43 | + auto endpointResolutionOutcome = TracingUtils::MakeCallWithTiming<ResolveEndpointOutcome>( |
| 44 | + [&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); }, |
| 45 | + TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, *meter, |
| 46 | + {{TracingUtils::SMITHY_METHOD_DIMENSION, operationName}, |
| 47 | + {TracingUtils::SMITHY_SERVICE_DIMENSION, serviceName}}); |
| 48 | + |
| 49 | + AWS_OPERATION_CHECK_SUCCESS_DYNAMIC(endpointResolutionOutcome, operationName, CoreErrors, |
| 50 | + CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage()); |
| 51 | + |
| 52 | +#if($metadata.findFirstSupportedProtocol() == "smithy-rpc-v2-cbor") |
| 53 | + endpointResolutionOutcome.GetResult().AddPathSegments("/service/${serviceModel.metadata.targetPrefix}/operation/"); |
| 54 | + endpointResolutionOutcome.GetResult().AddPathSegment(operationName); |
| 55 | +#end |
| 56 | + |
| 57 | +#if($metadata.protocol == "rest-json" || $metadata.protocol == "rest-xml") |
| 58 | + resolveUri(endpointResolutionOutcome); |
| 59 | +#end |
| 60 | + |
| 61 | + return MakeRequest(request, endpointResolutionOutcome.GetResult(), httpMethod, Aws::Auth::SIGV4_SIGNER); |
| 62 | + }, |
| 63 | + TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter, |
| 64 | + {{TracingUtils::SMITHY_METHOD_DIMENSION, operationName}, |
| 65 | + {TracingUtils::SMITHY_SERVICE_DIMENSION, serviceName}}); |
| 66 | +} |
0 commit comments