Skip to content

Commit

Permalink
Ensure our transaction activity is always observed
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejgordon committed Oct 3, 2024
1 parent 7854d2d commit 3e7d6ef
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Elastic.Apm/Model/Transaction.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Licensed to Elasticsearch B.V under
// one or more agreements.
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information

Expand Down Expand Up @@ -29,6 +28,13 @@ internal class Transaction : ITransaction

#if NET
internal static readonly ActivitySource ElasticApmActivitySource = new("Elastic.Apm");

// This simply ensures our transaction activity is always created.
internal static readonly ActivityListener Listener = new()
{
ShouldListenTo = s => s.Name == ElasticApmActivitySource.Name,
Sample = (ref ActivityCreationOptions<ActivityContext> _) => ActivitySamplingResult.AllData
};
#endif

internal readonly TraceState _traceState;
Expand Down

0 comments on commit 3e7d6ef

Please sign in to comment.