-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inject instrumentation metadata into HTTP headers
Motivation: In order to instrument distributed systems, metadata such as trace ids must be propagated across network boundaries. As HTTPClient operates at one such boundary, it should take care of injecting metadata into HTTP headers automatically using the configured instrument. Modifications: HTTPClient gains new method overloads accepting LoggingContext. Result: - New HTTPClient method overloads accepting LoggingContext - Existing overloads accepting Logger construct a DefaultLoggingContext - Existing methods that neither take Logger nor LoggingContext construct a DefaultLoggingContext
- Loading branch information
Showing
6 changed files
with
249 additions
and
11 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
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,25 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the AsyncHTTPClient open source project | ||
// | ||
// Copyright (c) 2020 Apple Inc. and the AsyncHTTPClient project authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
// See LICENSE.txt for license information | ||
// See CONTRIBUTORS.txt for the list of AsyncHTTPClient project authors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import Instrumentation | ||
import NIOHTTP1 | ||
|
||
/// Injects values into `NIOHTTP1.HTTPHeaders`. | ||
struct HTTPHeadersInjector: Injector { | ||
init() {} | ||
|
||
func inject(_ value: String, forKey key: String, into headers: inout HTTPHeaders) { | ||
headers.replaceOrAdd(name: key, value: value) | ||
} | ||
} |
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
Oops, something went wrong.