-
Notifications
You must be signed in to change notification settings - Fork 0
TracingInterceptorOptions
If non-null, this is called for each argument passed to the method (e.g. a
and b
on ISomething.Add
above), and the result is set as a tag on the span for the method call. The key for the tag will be the parameter name.
ISomething something = new FakeSomething().WrapInterfaceWithTracingAdapter<ISomething>(
formatArgumentForTag: obj => "number " + obj,
/* ... */);
something.Add(1, 2);
The span produced will be 'FakeSomething.Add' with tags { ["a"] = "number 1", ["b"] = "number 2" }
If non-null, this is called for the return value of the method, and the result is set as a tag on the span for the method call. The key for the tag will be result
, until/unless the OpenTracing Semantic Conventions spec provides a standard for this.
ISomething something = new FakeSomething().WrapInterfaceWithTracingAdapter<ISomething>(
formatResultForTag: (Task<int> intTask) => "value: " + intTask.Result,
/* ... */);
something.Add(1, 2);
The span produced will be 'FakeSomething.Add' with tag { ["result"] = "value: 3" }
If this is true, and the return value for a method on the interface is also an interface, that return value will be wrapped with tracing as well.
// Note that this example is for demonstrative purposes, as actually right now System.* namespaces are explicitly excluded from this, specifically because of this scenario here
IEnumerable sample = /* ... */;
IEnumerable tracedSample = sample.WrapInterfaceWithTracingAdapter<ISomething>(
wrapInterfaces: true,
/* ... */);
IEnumerator enumerator = tracedSample.GetEnumerator(); // Starts/Finishes an IEnumerable.GetEnumerator span
enumerator.MoveNext(); // Starts/Finishes an IEnumerator.MoveNext span
Show the difference versus RecursivelyWrapInterfaces
interface ICount
{
int Count { get; }
ICount MePlusOne();
}
ICount sample = /* ... */;
IEnumerable tracedSample = sample.WrapInterfaceWithTracingAdapter<ICount>(
wrapInterfaces: true,
recursivelyWrapInterfaces: false,
/* ... */);
tracedSample
.MePlusOne() // Starts/Finishes an ICount.MePlusOne span
.MePlusOne() // No tracing
.MePlusOne();// No tracing
Please see WrapInterfaces first.
This is akin to WrapInterfaces, except that instead of 1-level down it will wrap results for as long as methods are returning interfaces.
interface ICount
{
int Count { get; }
ICount MePlusOne();
}
ICount sample = /* ... */;
IEnumerable tracedSample = sample.WrapInterfaceWithTracingAdapter<ICount>(
wrapInterfaces: true,
recursivelyWrapInterfaces: true,
/* ... */);
tracedSample
.MePlusOne() // Starts/Finishes an ICount.MePlusOne span
.MePlusOne() // Starts/Finishes an ICount.MePlusOne span
.MePlusOne();// Starts/Finishes an ICount.MePlusOne span
If true, the concrete implementation's class name is prepended to the OperationName for the span. E.g. FakeSomething.Add
.
If false, only the method names are used for the OperationName. E.g. Add