Exemple #1
0
        private static SNSEvent CreateDummySnsEvent()
        {
            SNSEvent snsEvent = new SNSEvent();
            var      r        = new SNSRecord();

            r.Sns = new SNSMessage()
            {
                Message = CreateDummyMessageJson()
            };
            snsEvent.Records = new List <SNSRecord>()
            {
                r
            };
            return(snsEvent);
        }
        public override void Handle(ILambdaContext context, IScope scope)
        {
            SNSRecord first = null;

            string[] operationSplit = null;
            string   operation      = "";
            string   message        = "";

            try
            {
                base.Handle(context, scope);

                first          = input?.Records?.FirstOrDefault();
                operationSplit = first.EventSubscriptionArn?.Split(':');

                if (operationSplit != null)
                {
                    operation = operationSplit[operationSplit.Length - 2];
                }

                message = first.Sns?.Message;

                scope.Span.SetTag("event.id", first.Sns?.MessageId);
                scope.Span.SetTag("resource.type", "sns");
                scope.Span.SetTag("resource.operation", operation);
                scope.Span.SetTag("aws.sns.Notification Subject", first.Sns?.Subject);
                scope.Span.SetDataIfNeeded("aws.sns.Notification Message", first.Sns?.Message);
            }
            catch (NullReferenceException)
            {
                Utils.DebugLogIfEnabled("null reference, locals: {@locals}", new
                {
                    Context        = context,
                    scope          = scope,
                    First          = first,
                    OperationSplit = operationSplit,
                    Operation      = operation,
                    Message        = message
                });
            }
        }
Exemple #3
0
        public override void Handle(ILambdaContext context, IScope scope)
        {
            SNSRecord first = null;

            string[] topicArnSplit = null;
            string   topicName     = "";
            string   message       = "";

            try {
                base.Handle(context, scope);

                first         = input?.Records?.FirstOrDefault();
                topicArnSplit = first.EventSubscriptionArn?.Split(':');

                if (topicArnSplit != null)
                {
                    topicName = topicArnSplit[topicArnSplit.Length - 2];
                }

                message = first.Sns?.Message;
                var attributes = first.Sns?.MessageAttributes.ToDictionary(attr => attr.Key, attr => attr.Value);

                scope.Span.SetTag("event.id", first.Sns?.MessageId);
                scope.Span.SetTag("resource.type", "sns");
                scope.Span.SetTag("resource.name", topicName);
                scope.Span.SetTag("resource.operation", first.Sns?.Type);
                scope.Span.SetTag("aws.sns.subject", first.Sns?.Subject);
                scope.Span.SetDataIfNeeded("aws.sns.message", message);
                scope.Span.SetDataIfNeeded("aws.sns.message_attributes", attributes);
            } catch (NullReferenceException) {
                Utils.DebugLogIfEnabled("null reference, locals: {@locals}", new {
                    scope,
                    context,
                    first,
                    topicArnSplit,
                    topicName,
                    message,
                });
            }
        }