Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
1605ace
Support W3C Baggage spec.
CodeBlanch Aug 9, 2020
37f6df5
Moved baggage propagation to its own ITextFormat. Removed IsInjected.
CodeBlanch Aug 9, 2020
a34a80c
updating some tests
eddynaka Aug 9, 2020
7483e90
creating nw files
eddynaka Aug 9, 2020
4d7fd7d
updating files
eddynaka Aug 9, 2020
ec65bc0
buildable in release
eddynaka Aug 9, 2020
1964da6
adding baggage tests
eddynaka Aug 10, 2020
685c298
updating tests
eddynaka Aug 10, 2020
a26e2ce
updating default textformat for http instrumentation
eddynaka Aug 10, 2020
de2898e
Removed a few null checks.
CodeBlanch Aug 11, 2020
1ab0969
Removed DistributedContext. Drive CorrelationContext off of Activity.…
CodeBlanch Aug 11, 2020
3a1f65b
Merge branch 'master' into baggage
eddynaka Aug 11, 2020
387406a
Merge branch 'baggage' of https://github.com/CodeBlanch/opentelemetry…
eddynaka Aug 11, 2020
6454533
updating issues after merge
eddynaka Aug 11, 2020
a07482c
updating based on sanity check
eddynaka Aug 11, 2020
0fecef0
updating baggage test
eddynaka Aug 11, 2020
2a02388
updating tests
eddynaka Aug 11, 2020
6f5f2f1
reiley's comments
eddynaka Aug 11, 2020
90ca374
move to using
eddynaka Aug 11, 2020
a5196e7
Merge branch 'master' into baggage
CodeBlanch Aug 12, 2020
9b815e7
Updates for http-in and http-out. Updated CHANGELOGs.
CodeBlanch Aug 12, 2020
0503bbb
Merge branch 'master' into baggage
eddynaka Aug 12, 2020
172dd1b
Adding tests.
CodeBlanch Aug 13, 2020
f48bc05
Merge branch 'master' into baggage
eddynaka Aug 13, 2020
f9a3f8b
updating correlation context
eddynaka Aug 13, 2020
2f6a3ff
Added test for TraceContextFormat + BaggageFormat used together.
CodeBlanch Aug 14, 2020
80c56b8
Merging from master.
CodeBlanch Aug 14, 2020
34c6667
Fixed broken tests.
CodeBlanch Aug 14, 2020
1a8a922
Code review.
CodeBlanch Aug 14, 2020
8c95541
Test fixup.
CodeBlanch Aug 14, 2020
302267f
updating order
eddynaka Aug 14, 2020
bb25ad0
updating tests
eddynaka Aug 14, 2020
374b4b0
updating tests, adding dispose, clearing objects
eddynaka Aug 14, 2020
e913a56
Merge branch 'master' into baggage
CodeBlanch Aug 15, 2020
f8c967b
Merge branch 'master' into baggage
cijothomas Aug 18, 2020
c3f05f8
Merge branch 'master' into baggage
cijothomas Aug 18, 2020
4fb391a
updating changelog
eddynaka Aug 18, 2020
eb85991
Use "Baggage" instead of "baggage" as the header name.
CodeBlanch Aug 18, 2020
1b3b49f
Added some basic support for the Baggage limits specified in the spec.
CodeBlanch Aug 18, 2020
0a283bf
Fixed and improved ITextFormat log messages.
CodeBlanch Aug 18, 2020
3c2e9fd
Rename TextFormatContext -> PropagationContext.
CodeBlanch Aug 18, 2020
07b8b46
Updated ITextFormat implementations so they don't double-extract.
CodeBlanch Aug 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Test fixup.
  • Loading branch information
CodeBlanch committed Aug 14, 2020
commit 8c95541cd4f847d5a1033cad286885f71f19d423
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ public class AspNetInstrumentationOptions
/// <summary>
/// Gets or sets a hook to exclude calls based on domain or other per-request criterion.
/// </summary>
internal Predicate<HttpContext> RequestFilter { get; set; } = DefaultFilter;

private static bool DefaultFilter(HttpContext httpContext)
{
return true;
}
internal Predicate<HttpContext> RequestFilter { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public override void OnStartActivity(Activity activity, object payload)
return;
}

if (this.options.RequestFilter != null && !this.options.RequestFilter(context))
if (this.options.RequestFilter?.Invoke(context) == false)
{
AspNetInstrumentationEventSource.Log.RequestIsFilteredOut(activity.OperationName);
activity.IsAllDataRequested = false;
Expand Down Expand Up @@ -121,6 +121,7 @@ public override void OnStartActivity(Activity activity, object payload)
public override void OnStopActivity(Activity activity, object payload)
{
Activity activityToEnrich = activity;
Activity createdActivity = null;

if (!(this.options.TextFormat is TraceContextFormat))
{
Expand All @@ -132,9 +133,10 @@ public override void OnStopActivity(Activity activity, object payload)
if (activity.OperationName.Equals("Microsoft.AspNet.HttpReqIn.Start"))
{
// This block is hit if Asp.Net did restore Current to its own activity,
// then we need to retrieve the one created by HttpInListener
// and populate tags to it.
activityToEnrich = (Activity)activity.GetCustomProperty("ActivityByHttpInListener");
// and we need to retrieve the one created by HttpInListener,
// or an additional activity was never created.
createdActivity = (Activity)activity.GetCustomProperty("ActivityByHttpInListener");
activityToEnrich = createdActivity ?? activity;
}
}

Expand Down Expand Up @@ -197,13 +199,12 @@ public override void OnStopActivity(Activity activity, object payload)
var activityByAspNet = (Activity)activity.GetCustomProperty("ActivityByAspNet");
Activity.Current = activityByAspNet;
}
else if (activity.OperationName.Equals("Microsoft.AspNet.HttpReqIn.Start"))
else if (createdActivity != null)
{
// This block is hit if Asp.Net did restore Current to its own activity,
// then we need to retrieve the one created by HttpInListener
// and stop it.
var activityByHttpInListener = (Activity)activity.GetCustomProperty("ActivityByHttpInListener");
activityByHttpInListener.Stop();
createdActivity.Stop();

// Restore current back to the one created by Asp.Net
Activity.Current = activity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ public class AspNetCoreInstrumentationOptions
/// <summary>
/// Gets or sets a hook to exclude calls based on domain or other per-request criterion.
/// </summary>
internal Predicate<HttpContext> RequestFilter { get; set; } = DefaultFilter;

private static bool DefaultFilter(HttpContext httpContext)
{
return true;
}
internal Predicate<HttpContext> RequestFilter { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public override void OnStartActivity(Activity activity, object payload)
return;
}

if (this.options.RequestFilter != null && !this.options.RequestFilter(context))
if (this.options.RequestFilter?.Invoke(context) == false)
{
AspNetCoreInstrumentationEventSource.Log.RequestIsFilteredOut(activity.OperationName);
activity.IsAllDataRequested = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ public void Dispose()
[InlineData("https://localhost:443/about_attr_route/10", 2, "about_attr_route/{customerId}", "TraceContext")]
[InlineData("http://localhost:1880/api/weatherforecast", 3, "api/{controller}/{id}", "TraceContext")]
[InlineData("https://localhost:1843/subroute/10", 4, "subroute/{customerId}", "TraceContext")]

// TODO: Reenable this tests once filtering mechanism is designed.
// [InlineData("http://localhost/api/value", 0, null, "/api/value")] // Request will be filtered
// [InlineData("http://localhost/api/value", 0, null, "{ThrowException}")] // Filter user code will throw an exception
[InlineData("http://localhost/api/value", 0, null, "TraceContext", "/api/value")] // Request will be filtered
[InlineData("http://localhost/api/value", 0, null, "TraceContext", "{ThrowException}")] // Filter user code will throw an exception
[InlineData("http://localhost/api/value/2", 0, null, "CustomContext", "/api/value")] // Request will not be filtered
[InlineData("http://localhost/api/value/2", 0, null, "CustomContext", "/api/value", true)] // Request will not be filtered
public void AspNetRequestsAreCollectedSuccessfully(
Expand Down Expand Up @@ -188,7 +186,19 @@ public void AspNetRequestsAreCollectedSuccessfully(

if (HttpContext.Current.Request.Path == filter || filter == "{ThrowException}")
{
Assert.Equal(0, activityProcessor.Invocations.Count); // Nothing was called because request was filtered.
if (filter == "{ThrowException}")
{
// This behavior is not good. If filter throws, Stop is called without Start.
// Need to do something here, but user can't currently set the filter
// so it wil always noop. When we support user filter,
// treat this as a todo: define exception behavior.
Assert.Equal(2, activityProcessor.Invocations.Count); // Stop & Disposed called.
}
else
{
Assert.Equal(1, activityProcessor.Invocations.Count); // Only disposed was called because request was filtered.
}

return;
}

Expand Down