-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add builders for setting optional attributes on HTTP extractors (open…
…-telemetry#5347) * Add builders for setting optional attributes on HTTP extractors * errorprone * fix compilation failure
- Loading branch information
Showing
18 changed files
with
166 additions
and
35 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
39 changes: 39 additions & 0 deletions
39
...telemetry/instrumentation/api/instrumenter/http/HttpClientAttributesExtractorBuilder.java
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,39 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.api.instrumenter.http; | ||
|
||
import io.opentelemetry.instrumentation.api.config.Config; | ||
|
||
/** A builder of {@link HttpClientAttributesExtractor}. */ | ||
public final class HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE> { | ||
|
||
final HttpClientAttributesGetter<REQUEST, RESPONSE> getter; | ||
CapturedHttpHeaders capturedHttpHeaders = CapturedHttpHeaders.client(Config.get()); | ||
|
||
HttpClientAttributesExtractorBuilder(HttpClientAttributesGetter<REQUEST, RESPONSE> getter) { | ||
this.getter = getter; | ||
} | ||
|
||
/** | ||
* Configures the HTTP headers that will be captured as span attributes. | ||
* | ||
* @param capturedHttpHeaders A configuration object specifying which HTTP request and response | ||
* headers should be captured as span attributes. | ||
*/ | ||
public HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE> captureHttpHeaders( | ||
CapturedHttpHeaders capturedHttpHeaders) { | ||
this.capturedHttpHeaders = capturedHttpHeaders; | ||
return this; | ||
} | ||
|
||
/** | ||
* Returns a new {@link HttpClientAttributesExtractor} with the settings of this {@link | ||
* HttpClientAttributesExtractorBuilder}. | ||
*/ | ||
public HttpClientAttributesExtractor<REQUEST, RESPONSE> build() { | ||
return new HttpClientAttributesExtractor<>(getter, capturedHttpHeaders); | ||
} | ||
} |
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
39 changes: 39 additions & 0 deletions
39
...telemetry/instrumentation/api/instrumenter/http/HttpServerAttributesExtractorBuilder.java
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,39 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.api.instrumenter.http; | ||
|
||
import io.opentelemetry.instrumentation.api.config.Config; | ||
|
||
/** A builder of {@link HttpServerAttributesExtractor}. */ | ||
public final class HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> { | ||
|
||
final HttpServerAttributesGetter<REQUEST, RESPONSE> getter; | ||
CapturedHttpHeaders capturedHttpHeaders = CapturedHttpHeaders.server(Config.get()); | ||
|
||
HttpServerAttributesExtractorBuilder(HttpServerAttributesGetter<REQUEST, RESPONSE> getter) { | ||
this.getter = getter; | ||
} | ||
|
||
/** | ||
* Configures the HTTP headers that will be captured as span attributes. | ||
* | ||
* @param capturedHttpHeaders A configuration object specifying which HTTP request and response | ||
* headers should be captured as span attributes. | ||
*/ | ||
public HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> captureHttpHeaders( | ||
CapturedHttpHeaders capturedHttpHeaders) { | ||
this.capturedHttpHeaders = capturedHttpHeaders; | ||
return this; | ||
} | ||
|
||
/** | ||
* Returns a new {@link HttpServerAttributesExtractor} with the settings of this {@link | ||
* HttpServerAttributesExtractorBuilder}. | ||
*/ | ||
public HttpServerAttributesExtractor<REQUEST, RESPONSE> build() { | ||
return new HttpServerAttributesExtractor<>(getter, capturedHttpHeaders); | ||
} | ||
} |
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
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
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