Skip to content

Commit

Permalink
Merge branch 'master' into nacho/IastUnitTestsDebugCI
Browse files Browse the repository at this point in the history
  • Loading branch information
NachoEchevarria authored Feb 4, 2025
2 parents 94aa4eb + 28a8766 commit 5006786
Show file tree
Hide file tree
Showing 24 changed files with 2,375 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@
<type fullname="System.Func`6" />
<type fullname="System.Func`7" />
<type fullname="System.GC" />
<type fullname="System.GCMemoryInfo" />
<type fullname="System.Globalization.CultureInfo" />
<type fullname="System.Globalization.DateTimeStyles" />
<type fullname="System.Globalization.NumberFormatInfo" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ internal static class Debugger
/// <seealso cref="DebuggerSettings.RedactedIdentifiers"/>
public const string RedactedIdentifiers = "DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS";

/// <summary>
/// Configuration key for set of identifiers that are excluded from redaction decisions.
/// </summary>
/// <seealso cref="DebuggerSettings.RedactedExcludedIdentifiers"/>
public const string RedactionExcludedIdentifiers = "DD_DYNAMIC_INSTRUMENTATION_REDACTION_EXCLUDED_IDENTIFIERS";

/// <summary>
/// Configuration key for set of identifiers that are excluded from redaction decisions.
/// </summary>
/// <seealso cref="DebuggerSettings.RedactedExcludedIdentifiers"/>
public const string RedactedExcludedIdentifiers = "DD_DYNAMIC_INSTRUMENTATION_REDACTED_EXCLUDED_IDENTIFIERS";

/// <summary>
/// Configuration key for set of types that are used in redaction decisions.
/// </summary>
Expand Down
51 changes: 51 additions & 0 deletions tracer/src/Datadog.Trace/Debugger/Caching/CacheItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// <copyright file="CacheItem.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 System.Threading;

namespace Datadog.Trace.Debugger.Caching;

internal class CacheItem<TValue>
{
private readonly DateTime _created;
private long _lastAccessed;
private long _accessCount;

public CacheItem(TValue? value, TimeSpan? slidingExpiration)
{
if (slidingExpiration.HasValue && slidingExpiration.Value <= TimeSpan.Zero)
{
throw new ArgumentException("Sliding expiration must be positive", nameof(slidingExpiration));
}

Value = value;
_created = DateTime.UtcNow;
LastAccessed = _created;
SlidingExpiration = slidingExpiration;
}

public DateTimeOffset Created => _created;

public TimeSpan? SlidingExpiration { get; set; }

public TValue? Value { get; set; }

internal DateTimeOffset LastAccessed
{
get => DateTime.FromBinary(Interlocked.Read(ref _lastAccessed));
set => Interlocked.Exchange(ref _lastAccessed, value.UtcDateTime.ToBinary());
}

internal long AccessCount => Interlocked.Read(ref _accessCount);

internal void UpdateAccess(DateTime now)
{
LastAccessed = now;
Interlocked.Increment(ref _accessCount);
}
}
Loading

0 comments on commit 5006786

Please sign in to comment.