Skip to content

Commit 7b133a5

Browse files
more cleanup
1 parent 2280b9b commit 7b133a5

File tree

6 files changed

+8
-45
lines changed

6 files changed

+8
-45
lines changed

src/Framework/Microsoft.Build.Framework.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@
3131
<!-- Framework and standard don't have these. -->
3232
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' OR '$(TargetFrameworkIdentifier)' == '.NETStandard'">
3333
<PackageReference Include="System.Collections.Immutable" />
34-
<PackageReference Include="System.Diagnostics.DiagnosticSource" />
3534
</ItemGroup>
3635

3736
<!-- When targeting NS2.0, make private all references not exposed in the public API. -->
3837
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard'">
38+
<PackageReference Include="System.Diagnostics.DiagnosticSource" PrivateAssets="all" />
3939
<PackageReference Update="System.Collections.Immutable" PrivateAssets="all" />
40-
<PackageReference Update="System.Diagnostics.DiagnosticSource" PrivateAssets="all" />
4140
</ItemGroup>
4241

4342
<ItemGroup>

src/Framework/Telemetry/DiagnosticActivity.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
#if !NETFRAMEWORK
5+
46
using System.Collections.Generic;
57
using System.Diagnostics;
68

@@ -43,13 +45,6 @@ public DiagnosticActivity(Activity activity)
4345
return this;
4446
}
4547

46-
public IActivity? AddEvent(ActivityEvent activityEvent)
47-
{
48-
_activity.AddEvent(activityEvent);
49-
50-
return this;
51-
}
52-
5348
public void Dispose()
5449
{
5550
if (_disposed)
@@ -63,3 +58,5 @@ public void Dispose()
6358
}
6459
}
6560
}
61+
62+
#endif

src/Framework/Telemetry/IActivity.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5-
using System.Diagnostics;
65

76
namespace Microsoft.Build.Framework.Telemetry
87
{
@@ -25,12 +24,5 @@ internal interface IActivity : IDisposable
2524
/// <param name="value">The tag value.</param>
2625
/// <returns>The activity instance for method chaining.</returns>
2726
IActivity? SetTag(string key, object? value);
28-
29-
/// <summary>
30-
/// Adds an event to the activity.
31-
/// </summary>
32-
/// <param name="activityEvent">The event to add.</param>
33-
/// <returns>The activity instance for method chaining.</returns>
34-
IActivity? AddEvent(ActivityEvent activityEvent);
3527
}
3628
}

src/Framework/Telemetry/IActivityTelemetryDataHolder.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Collections.Generic;
5-
using System.Diagnostics;
65

76
namespace Microsoft.Build.Framework.Telemetry;
87

98
/// <summary>
10-
/// Interface for classes that hold telemetry data that should be added as tags to an <see cref="Activity"/>.
9+
/// Interface for classes that hold telemetry data that should be added as tags to an <see cref="IActivity"/>.
1110
/// </summary>
1211
internal interface IActivityTelemetryDataHolder
1312
{

src/Framework/Telemetry/MSBuildActivitySource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public MSBuildActivitySource(string name)
4242

4343
#if NETFRAMEWORK
4444
TelemetryScope<OperationEvent>? operation = _telemetrySession?.StartOperation(eventName);
45-
return operation != null ? new VsTelemetryActivity(operation, _telemetrySession) : null;
45+
return operation != null ? new VsTelemetryActivity(operation) : null;
4646
#else
4747
Activity? activity = Activity.Current?.HasRemoteParent == true
4848
? _source.StartActivity(eventName, ActivityKind.Internal, parentId: Activity.Current.ParentId)

src/Framework/Telemetry/VSTelemetryActivity.cs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#if NETFRAMEWORK
55

66
using System.Collections.Generic;
7-
using System.Diagnostics;
87
using Microsoft.VisualStudio.Telemetry;
98

109
namespace Microsoft.Build.Framework.Telemetry
@@ -17,21 +16,13 @@ namespace Microsoft.Build.Framework.Telemetry
1716
internal class VsTelemetryActivity : IActivity
1817
{
1918
private readonly TelemetryScope<OperationEvent> _scope;
20-
private readonly TelemetrySession? _session;
2119
private TelemetryResult _result = TelemetryResult.Success;
2220

2321
private bool _disposed;
2422

25-
public VsTelemetryActivity(TelemetryScope<OperationEvent> scope, TelemetrySession? session)
23+
public VsTelemetryActivity(TelemetryScope<OperationEvent> scope)
2624
{
2725
_scope = scope;
28-
_session = session;
29-
}
30-
31-
public IActivity? SetResult(TelemetryResult result)
32-
{
33-
_result = result;
34-
return this;
3526
}
3627

3728
public IActivity? SetTags(IActivityTelemetryDataHolder? dataHolder)
@@ -59,21 +50,6 @@ public VsTelemetryActivity(TelemetryScope<OperationEvent> scope, TelemetrySessio
5950
return this;
6051
}
6152

62-
public IActivity? AddEvent(ActivityEvent activityEvent)
63-
{
64-
// VS Telemetry doesn't have a direct equivalent to ActivityEvent.
65-
// We create and post a custom event to the session associated with this activity.
66-
var telemetryEvent = new TelemetryEvent(activityEvent.Name);
67-
foreach (KeyValuePair<string, object?> tag in activityEvent.Tags)
68-
{
69-
telemetryEvent.Properties[$"{TelemetryConstants.PropertyPrefix}{tag.Key}"] = tag.Value;
70-
}
71-
72-
_session?.PostEvent(telemetryEvent);
73-
74-
return this;
75-
}
76-
7753
public void Dispose()
7854
{
7955
if (_disposed)

0 commit comments

Comments
 (0)