-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DisableActivityHandler for disabling ActivitySources
This allows for end users to completely disable certain ActivitySource names by using the new configuration key DisabledOpenTelemetryIntegrations and DD_DISABLED_OPENTELEMETRY_INTEGRATIONS which accepts a semi-colon separated list of ActivitySource names to disable. Note that the names must be an exact match.
- Loading branch information
Showing
10 changed files
with
120 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
tracer/src/Datadog.Trace/Activity/Handlers/DisableActivityHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// <copyright file="DisableActivityHandler.cs" company="Datadog"> | ||
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. | ||
// </copyright> | ||
|
||
#nullable enable | ||
|
||
using System; | ||
using Datadog.Trace.Activity.DuckTypes; | ||
|
||
namespace Datadog.Trace.Activity.Handlers | ||
{ | ||
internal class DisableActivityHandler : IActivityHandler | ||
{ | ||
public void ActivityStarted<T>(string sourceName, T activity) | ||
where T : IActivity | ||
{ | ||
// do nothing | ||
throw new InvalidOperationException("Should not happen"); | ||
} | ||
|
||
public void ActivityStopped<T>(string sourceName, T activity) | ||
where T : IActivity | ||
{ | ||
// do nothing | ||
throw new InvalidOperationException("Should not happen"); | ||
} | ||
|
||
public bool ShouldListenTo(string sourceName, string? version) | ||
{ | ||
var toDisable = Tracer.Instance.Settings.DisabledOpenTelemetryIntegrations; | ||
if (toDisable is null || string.IsNullOrWhiteSpace(toDisable)) | ||
{ | ||
return false; | ||
} | ||
|
||
var toDisableSplit = toDisable.Split(';'); | ||
foreach (var disabledSourceName in toDisableSplit) | ||
{ | ||
if (sourceName == disabledSourceName) | ||
{ | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters