-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tracer] Add API to extract SpanContext (#2694)
* Add API to extract SpanContext * Rename and add kafka tests * Renaming and RabbitMQTests * fix tests * Apply suggestions from code review Co-authored-by: Zach Montoya <[email protected]> Co-authored-by: Zach Montoya <[email protected]>
- Loading branch information
1 parent
f74af6a
commit a5656c4
Showing
8 changed files
with
188 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// <copyright file="ISpanContextExtractor.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> | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
#nullable enable | ||
|
||
namespace Datadog.Trace | ||
{ | ||
/// <summary> | ||
/// The ISpanContextExtractor is responsible for extracting SpanContext in the rare cases where the Tracer couldn't propagate it itself. | ||
/// This can happen for instance when libraries add an extra layer above the instrumented ones | ||
/// (eg consuming Kafka messages and enqueuing them prior to generate a span). | ||
/// </summary> | ||
public interface ISpanContextExtractor | ||
{ | ||
/// <summary> | ||
/// Given a SpanContext carrier and a function to access the values, this method will extract SpanContext if any | ||
/// </summary> | ||
/// <param name="carrier">The carrier of the SpanContext. Often a header (http, kafka message header...)</param> | ||
/// <param name="getter">Given a key name, returns values from the carrier</param> | ||
/// <typeparam name="TCarrier">Type of the carrier</typeparam> | ||
/// <returns>A potentially null Datadog SpanContext</returns> | ||
public ISpanContext? Extract<TCarrier>(TCarrier carrier, Func<TCarrier, string, IEnumerable<string?>> getter); | ||
} | ||
} |
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,21 @@ | ||
// <copyright file="SpanContextExtractor.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> | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using Datadog.Trace.Propagators; | ||
|
||
#nullable enable | ||
|
||
namespace Datadog.Trace | ||
{ | ||
/// <inheritdoc /> | ||
public class SpanContextExtractor : ISpanContextExtractor | ||
{ | ||
/// <inheritdoc /> | ||
public ISpanContext? Extract<TCarrier>(TCarrier carrier, Func<TCarrier, string, IEnumerable<string?>> getter) | ||
=> SpanContextPropagator.Instance.Extract(carrier, getter); | ||
} | ||
} |
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