Exemplo n.º 1
0
        public void KV_default_span_tags_are_added_when_not_using_threshold_logging_tracer(RedactionLevel redactionLevel)
        {
            const string bucketName  = "the-bucket";
            const string documentKey = "the-key";

            LogManager.RedactionLevel = redactionLevel;

            var expectedTags = new Dictionary <string, string>
            {
                { Tags.Component.Key, ClientIdentifier.GetClientDescription() },
                { Tags.DbType.Key, CouchbaseTags.DbTypeCouchbase },
                { Tags.SpanKind.Key, Tags.SpanKindClient },
                { CouchbaseTags.OperationId, "0x0" },
                { CouchbaseTags.Service, CouchbaseTags.ServiceKv },
                { Tags.DbInstance.Key, bucketName }
            };

            if (redactionLevel == RedactionLevel.None)
            {
                expectedTags.Add(CouchbaseTags.DocumentKey, documentKey);
            }

            var mockTracer    = new MockTracer();
            var mockOperation = new Mock <IOperation>();

            mockOperation.Setup(x => x.Key).Returns(documentKey);

            using (mockTracer.StartParentScope(mockOperation.Object, bucketName))
            {
                // start and end scope
            }

            Assert.AreEqual(1, mockTracer.FinishedSpans().Count);
            var span = mockTracer.FinishedSpans().First();

            Assert.AreEqual(expectedTags, span.Tags);
        }
Exemplo n.º 2
0
 private static void ThrowArgumentOutOfRangeException(RedactionLevel redactionLevel)
 {
     throw new ArgumentOutOfRangeException(Enum.GetName(typeof(RedactionLevel), redactionLevel),
                                           "Unexpected redaction level: {redactionLevel}");
 }
Exemplo n.º 3
0
 internal TypedRedactor(RedactionLevel redactionLevel)
 {
     RedactionLevel = redactionLevel;
 }