Skip to content

Commit

Permalink
Add headers to outgoing http requests for Open Telemetry (#141)
Browse files Browse the repository at this point in the history
* Add otel headers to outgoing http client requests

* format
  • Loading branch information
adamhathcock authored Oct 14, 2024
1 parent 4c52072 commit 3b859ba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Speckle.Sdk/Helpers/SpeckleHttpClientHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ CancellationToken cancellationToken
context.Add("retryCount", 0);

request.Headers.Add("x-request-id", context.CorrelationId.ToString());
activity?.InjectHeaders((k, v) => request.Headers.TryAddWithoutValidation(k, v));

var policyResult = await _resiliencePolicy
.ExecuteAndCaptureAsync(
Expand Down
2 changes: 2 additions & 0 deletions src/Speckle.Sdk/Logging/ISdkActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public interface ISdkActivity : IDisposable
void RecordException(Exception e);
string TraceId { get; }
void SetStatus(SdkActivityStatusCode code);

void InjectHeaders(Action<string, string> header);
}

public enum SdkActivityStatusCode
Expand Down

0 comments on commit 3b859ba

Please sign in to comment.