Esempio n. 1
0
        /// <summary>
        /// OnMethodBegin callback
        /// </summary>
        /// <typeparam name="TTarget">Type of the target</typeparam>
        /// <typeparam name="TDeleteMessageBatchRequest">Type of the request object</typeparam>
        /// <param name="instance">Instance value, aka `this` of the instrumented method</param>
        /// <param name="request">The request for the SQS operation</param>
        /// <param name="cancellationToken">CancellationToken value</param>
        /// <returns>Calltarget state value</returns>
        internal static CallTargetState OnMethodBegin <TTarget, TDeleteMessageBatchRequest>(TTarget instance, TDeleteMessageBatchRequest request, CancellationToken cancellationToken)
            where TDeleteMessageBatchRequest : IAmazonSQSRequestWithQueueUrl, IDuckType
        {
            if (request.Instance is null)
            {
                return(CallTargetState.GetDefault());
            }

            var scope = AwsSqsCommon.CreateScope(Tracer.Instance, Operation, out AwsSqsTags tags);

            tags.QueueUrl = request.QueueUrl;

            return(new CallTargetState(scope));
        }
        /// <summary>
        /// OnMethodBegin callback
        /// </summary>
        /// <typeparam name="TTarget">Type of the target</typeparam>
        /// <typeparam name="TCreateQueueRequest">Type of the request object</typeparam>
        /// <param name="instance">Instance value, aka `this` of the instrumented method</param>
        /// <param name="request">The request for the SQS operation</param>
        /// <returns>Calltarget state value</returns>
        internal static CallTargetState OnMethodBegin <TTarget, TCreateQueueRequest>(TTarget instance, TCreateQueueRequest request)
            where TCreateQueueRequest : ICreateQueueRequest, IDuckType
        {
            if (request.Instance is null)
            {
                return(CallTargetState.GetDefault());
            }

            var scope = AwsSqsCommon.CreateScope(Tracer.Instance, Operation, out AwsSqsTags tags);

            tags.QueueName = request.QueueName;

            return(new CallTargetState(scope));
        }
        /// <summary>
        /// OnMethodBegin callback
        /// </summary>
        /// <typeparam name="TTarget">Type of the target</typeparam>
        /// <typeparam name="TSendMessageRequest">Type of the request object</typeparam>
        /// <param name="instance">Instance value, aka `this` of the instrumented method</param>
        /// <param name="request">The request for the SQS operation</param>
        /// <param name="cancellationToken">CancellationToken value</param>
        /// <returns>Calltarget state value</returns>
        internal static CallTargetState OnMethodBegin <TTarget, TSendMessageRequest>(TTarget instance, TSendMessageRequest request, CancellationToken cancellationToken)
        {
            if (request is null)
            {
                return(CallTargetState.GetDefault());
            }

            var requestProxy = request.DuckCast <ISendMessageRequest>();

            var scope = AwsSqsCommon.CreateScope(Tracer.Instance, Operation, out AwsSqsTags tags);

            tags.QueueUrl = requestProxy.QueueUrl;

            if (scope?.Span.Context != null)
            {
                ContextPropagation.InjectHeadersIntoMessage <TSendMessageRequest>(requestProxy, scope.Span.Context);
            }

            return(new CallTargetState(scope));
        }
Esempio n. 4
0
        /// <summary>
        /// OnMethodBegin callback
        /// </summary>
        /// <typeparam name="TTarget">Type of the target</typeparam>
        /// <typeparam name="TSendMessageBatchRequest">Type of the request object</typeparam>
        /// <param name="instance">Instance value, aka `this` of the instrumented method</param>
        /// <param name="request">The request for the SQS operation</param>
        /// <param name="cancellationToken">CancellationToken value</param>
        /// <returns>Calltarget state value</returns>
        internal static CallTargetState OnMethodBegin <TTarget, TSendMessageBatchRequest>(TTarget instance, TSendMessageBatchRequest request, CancellationToken cancellationToken)
        {
            if (request is null)
            {
                return(CallTargetState.GetDefault());
            }

            var requestProxy = request.DuckCast <ISendMessageBatchRequest>();

            var scope = AwsSqsCommon.CreateScope(Tracer.Instance, Operation, out AwsSqsTags tags);

            tags.QueueUrl = requestProxy.QueueUrl;

            if (scope?.Span?.Context != null && requestProxy.Entries.Count > 0)
            {
                for (int i = 0; i < requestProxy.Entries.Count; i++)
                {
                    var entry = requestProxy.Entries[i].DuckCast <IContainsMessageAttributes>();
                    ContextPropagation.InjectHeadersIntoMessage <TSendMessageBatchRequest>(entry, scope.Span.Context);
                }
            }

            return(new CallTargetState(scope));
        }