-
Notifications
You must be signed in to change notification settings - Fork 764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove ActivitySourceAdapter #1836
Changes from 1 commit
febda2d
1c8e418
0f21319
999ca2b
6cd0ced
9291faa
c696f15
808a25b
2a3fac7
6d71638
1f32aa6
0dc0772
1970d6f
7f0b2f8
f24b04d
bc32f82
0869911
04fe5e0
1685599
90df48a
4c5df69
5fe89c0
0e337f7
ce2173c
d499a4d
32824d0
c9deb90
a8509ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// <copyright file="ActivitySourceDemo.cs" company="OpenTelemetry Authors"> | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
|
||
using System.Diagnostics; | ||
|
||
namespace Demo | ||
{ | ||
internal static class ActivitySourceDemo | ||
{ | ||
internal static readonly ActivitySource MyActivitySource = new ActivitySource( | ||
"MyCompany.MyProduct.MyLibrary"); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,11 +29,10 @@ internal class AspNetCoreInstrumentation : IDisposable | |
/// <summary> | ||
/// Initializes a new instance of the <see cref="AspNetCoreInstrumentation"/> class. | ||
/// </summary> | ||
/// <param name="activitySource">ActivitySource adapter instance.</param> | ||
/// <param name="options">Configuration options for ASP.NET Core instrumentation.</param> | ||
public AspNetCoreInstrumentation(ActivitySourceAdapter activitySource, AspNetCoreInstrumentationOptions options) | ||
public AspNetCoreInstrumentation(AspNetCoreInstrumentationOptions options) | ||
{ | ||
this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber(new HttpInListener("Microsoft.AspNetCore", options, activitySource), null); | ||
this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber(new HttpInListener("Microsoft.AspNetCore", options), null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there are lot of special names - lets move them to a common place where it can be commented and probbaly linked to aspnetcore repo source code. |
||
this.diagnosticSourceSubscriber.Subscribe(); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// <copyright file="ActivityInstrumentationHelper.cs" company="OpenTelemetry Authors"> | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
|
||
using System; | ||
using System.Diagnostics; | ||
using System.Linq.Expressions; | ||
|
||
namespace OpenTelemetry.Instrumentation | ||
{ | ||
internal static class ActivityInstrumentationHelper | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we compile the existing extension instead of duplicating it? |
||
{ | ||
internal static readonly Action<Activity, ActivityKind> SetKindProperty = CreateActivityKindSetter(); | ||
internal static readonly Action<Activity, ActivitySource> SetActivitySourceProperty = CreateActivitySourceSetter(); | ||
|
||
private static Action<Activity, ActivitySource> CreateActivitySourceSetter() | ||
{ | ||
ParameterExpression instance = Expression.Parameter(typeof(Activity), "instance"); | ||
ParameterExpression propertyValue = Expression.Parameter(typeof(ActivitySource), "propertyValue"); | ||
var body = Expression.Assign(Expression.Property(instance, "Source"), propertyValue); | ||
return Expression.Lambda<Action<Activity, ActivitySource>>(body, instance, propertyValue).Compile(); | ||
} | ||
|
||
private static Action<Activity, ActivityKind> CreateActivityKindSetter() | ||
{ | ||
ParameterExpression instance = Expression.Parameter(typeof(Activity), "instance"); | ||
ParameterExpression propertyValue = Expression.Parameter(typeof(ActivityKind), "propertyValue"); | ||
var body = Expression.Assign(Expression.Property(instance, "Kind"), propertyValue); | ||
return Expression.Lambda<Action<Activity, ActivityKind>>(body, instance, propertyValue).Compile(); | ||
} | ||
} | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially thought (inccoreclty) this is a breaking change! The public api analyzer is a gift!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we change this to internal?