Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize HTTP headers capturing configuration property names #4459

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/config/common.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ You can configure the agent to capture predefined HTTP headers as span attribute
[semantic convention](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/http.md#http-request-and-response-headers).
Use the following properties to define which HTTP headers you want to capture:

| System property | Environment variable | Description |
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ----------- |
| `otel.instrumentation.common.experimental.capture-http-headers.client.request` | `OTEL_INSTRUMENTATION_COMMON_EXPERIMENTAL_CAPTURE_HTTP_HEADERS_CLIENT_REQUEST` | A comma-separated list of HTTP header names. HTTP client instrumentations will capture HTTP request header values for all configured header names.
| `otel.instrumentation.common.experimental.capture-http-headers.client.response` | `OTEL_INSTRUMENTATION_COMMON_EXPERIMENTAL_CAPTURE_HTTP_HEADERS_CLIENT_RESPONSE` | A comma-separated list of HTTP header names. HTTP client instrumentations will capture HTTP response header values for all configured header names.
| `otel.instrumentation.common.experimental.capture-http-headers.server.request` | `OTEL_INSTRUMENTATION_COMMON_EXPERIMENTAL_CAPTURE_HTTP_HEADERS_SERVER_REQUEST` | A comma-separated list of HTTP header names. HTTP server instrumentations will capture HTTP request header values for all configured header names.
| `otel.instrumentation.common.experimental.capture-http-headers.server.response` | `OTEL_INSTRUMENTATION_COMMON_EXPERIMENTAL_CAPTURE_HTTP_HEADERS_SERVER_RESPONSE` | A comma-separated list of HTTP header names. HTTP server instrumentations will capture HTTP response header values for all configured header names.
| System property | Environment variable | Description |
| ----------------------------------------------------------- | ----------------------------------------------------------- | ----------- |
| `otel.instrumentation.http.capture-headers.client.request` | `OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_CLIENT_REQUEST` | A comma-separated list of HTTP header names. HTTP client instrumentations will capture HTTP request header values for all configured header names.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed on Thu SIG last week - I replaced the common part with http since this property applies to all instrumentations that implement the HTTP semantic convention

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need instrumentation part here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm in favor of keeping it. If you remove it, you'll be left with otel.http.capture-headers.client.request which is a bit vague - what does http refer to? HTTP exporters? Instrumentations? Is this something supported by the SDK, or the javaagent?

| `otel.instrumentation.http.capture-headers.client.response` | `OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_CLIENT_RESPONSE` | A comma-separated list of HTTP header names. HTTP client instrumentations will capture HTTP response header values for all configured header names.
| `otel.instrumentation.http.capture-headers.server.request` | `OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST` | A comma-separated list of HTTP header names. HTTP server instrumentations will capture HTTP request header values for all configured header names.
| `otel.instrumentation.http.capture-headers.server.response` | `OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_RESPONSE` | A comma-separated list of HTTP header names. HTTP server instrumentations will capture HTTP response header values for all configured header names.

These configuration options are supported by all HTTP client and server instrumentations.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,48 @@ public static CapturedHttpHeaders empty() {
return EMPTY;
}

private static final String CLIENT_REQUEST_PROPERTY =
"otel.instrumentation.http.capture-headers.client.request";
private static final String CLIENT_RESPONSE_PROPERTY =
"otel.instrumentation.http.capture-headers.client.response";
private static final String EXPERIMENTAL_CLIENT_REQUEST_PROPERTY =
"otel.instrumentation.common.experimental.capture-http-headers.client.request";
private static final String EXPERIMENTAL_CLIENT_RESPONSE_PROPERTY =
mateuszrzeszutek marked this conversation as resolved.
Show resolved Hide resolved
"otel.instrumentation.common.experimental.capture-http-headers.client.response";

/**
* Returns a configuration that captures HTTP client request and response headers as configured in
* the received {@code config}.
*/
public static CapturedHttpHeaders client(Config config) {
// fall back to the experimental properties in the stable one isn't supplied
mateuszrzeszutek marked this conversation as resolved.
Show resolved Hide resolved
return CapturedHttpHeaders.create(
config.getList(
"otel.instrumentation.common.experimental.capture-http-headers.client.request"),
CLIENT_REQUEST_PROPERTY, config.getList(EXPERIMENTAL_CLIENT_REQUEST_PROPERTY)),
config.getList(
"otel.instrumentation.common.experimental.capture-http-headers.client.response"));
CLIENT_RESPONSE_PROPERTY, config.getList(EXPERIMENTAL_CLIENT_RESPONSE_PROPERTY)));
}

private static final String SERVER_REQUEST_PROPERTY =
"otel.instrumentation.http.capture-headers.server.request";
private static final String SERVER_RESPONSE_PROPERTY =
"otel.instrumentation.http.capture-headers.server.response";
private static final String EXPERIMENTAL_SERVER_REQUEST_PROPERTY =
"otel.instrumentation.common.experimental.capture-http-headers.server.request";
private static final String EXPERIMENTAL_SERVER_RESPONSE_PROPERTY =
"otel.instrumentation.common.experimental.capture-http-headers.server.response";

/**
* Returns a configuration that captures HTTP server request and response headers as configured in
* the received {@code config}.
*/
public static CapturedHttpHeaders server(Config config) {
// fall back to the experimental properties in the stable one isn't supplied
return CapturedHttpHeaders.create(
config.getList(
"otel.instrumentation.common.experimental.capture-http-headers.server.request"),
SERVER_REQUEST_PROPERTY, config.getList(EXPERIMENTAL_SERVER_REQUEST_PROPERTY)),
config.getList(
"otel.instrumentation.common.experimental.capture-http-headers.server.response"));
SERVER_RESPONSE_PROPERTY, config.getList(EXPERIMENTAL_SERVER_RESPONSE_PROPERTY)));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,10 @@ public class CapturedHttpHeadersTestConfigSource implements ConfigPropertySource
@Override
public Map<String, String> getProperties() {
Map<String, String> testConfig = new HashMap<>();
testConfig.put(
"otel.instrumentation.common.experimental.capture-http-headers.client.request",
"X-Test-Request");
testConfig.put(
"otel.instrumentation.common.experimental.capture-http-headers.client.response",
"X-Test-Response");
testConfig.put(
"otel.instrumentation.common.experimental.capture-http-headers.server.request",
"X-Test-Request");
testConfig.put(
"otel.instrumentation.common.experimental.capture-http-headers.server.response",
"X-Test-Response");
testConfig.put("otel.instrumentation.http.capture-headers.client.request", "X-Test-Request");
testConfig.put("otel.instrumentation.http.capture-headers.client.response", "X-Test-Response");
testConfig.put("otel.instrumentation.http.capture-headers.server.request", "X-Test-Request");
testConfig.put("otel.instrumentation.http.capture-headers.server.response", "X-Test-Response");
return testConfig;
}
}