Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Commit e70e5a5

Browse files
author
N. Taylor Mullen
committed
Disabled instrumentation in writing scopes.
1 parent a77c8c8 commit e70e5a5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/CSharpTagHelperCodeRenderer.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,11 @@ private void BuildBufferedWritingScope(IList<Chunk> chunks)
409409
// ensure we capture all content that's written, directly or indirectly.
410410
var oldWriter = _context.TargetWriterName;
411411
_context.TargetWriterName = null;
412+
413+
// Need to disable instrumentation inside of writing scopes, the instrumentation will not detect
414+
// content written inside writing scopes.
415+
var oldInstrumentation = _context.Host.EnableInstrumentation;
416+
_context.Host.EnableInstrumentation = false;
412417

413418
_writer.WriteMethodInvocation(_tagHelperContext.StartWritingScopeMethodName);
414419

@@ -417,6 +422,9 @@ private void BuildBufferedWritingScope(IList<Chunk> chunks)
417422
_writer.WriteStartAssignment(StringValueBufferVariableName)
418423
.WriteMethodInvocation(_tagHelperContext.EndWritingScopeMethodName);
419424

425+
// Restore the instrumentation
426+
_context.Host.EnableInstrumentation = oldInstrumentation;
427+
420428
// Reset the writer/buffer back to what it was, no longer in a writing scope.
421429
_context.TargetWriterName = oldWriter;
422430
}

0 commit comments

Comments
 (0)