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

Updates to http.server_name #5369

Merged
merged 7 commits into from
Feb 18, 2022

Conversation

trask
Copy link
Member

@trask trask commented Feb 14, 2022

from the spec, http.server_name is:

The primary server name of the matched virtual host. This should be obtained via configuration. If no such configuration can be obtained, this attribute MUST NOT be set ( net.host.name should be used instead).

...

For example, http.server_name has shown great value in practice, as bogus HTTP Host headers occur often in the wild.

It is strongly recommended to set http.server_name to allow associating requests with some logical server entity.

The servlet and tomcat instrumentation currently capture http.server_name based on HTTP Host (e.g. https://docs.oracle.com/javaee/7/api/javax/servlet/ServletRequest.html#getServerName--), so this PR removes the capturing of http.server_name for those two instrumentations.

The only other instrumentation that captures http.server_name is armeria, which does appear to be capturing a configuration-based value.

I'm not sure if the one instrumentation justifies keeping serverName() in HttpServerAttributesGetter?

For this PR though, at least it seems the RESPONSE parameter is not needed for serverName() (and based on the spec definition it doesn't seem like this should be something that we need to wait for the RESPONSE for), so I have removed the RESPONSE parameter from the serverName() method.

return ((ServiceRequestContext) ctx).config().virtualHost().hostnamePattern();
return ((ServiceRequestContext) ctx).config().virtualHost().defaultHostname();
Copy link
Member Author

Choose a reason for hiding this comment

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

@anuraaga can you ack this change?

Comment on lines -145 to +143
return accessor.getRequestServerName(requestContext.request());
public String serverName(ServletRequestContext<REQUEST> requestContext) {
return null;
Copy link
Member Author

Choose a reason for hiding this comment

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

^^ the servlet change

return request.serverName().toString();
public String serverName(Request request) {
return null;
Copy link
Member Author

Choose a reason for hiding this comment

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

^^ the tomcat change

@trask trask marked this pull request as ready for review February 14, 2022 19:21
@trask trask requested a review from a team as a code owner February 14, 2022 19:21
@laurit
Copy link
Contributor

laurit commented Feb 14, 2022

from the spec, http.server_name is:

The primary server name of the matched virtual host. This should be obtained via configuration. If no such configuration can be obtained, this attribute MUST NOT be set ( net.host.name should be used instead).
...

currently we don't set net.host.name at all, should we?

@trask
Copy link
Member Author

trask commented Feb 14, 2022

currently we don't set net.host.name at all, should we?

ya, probably, opened #5375 to discuss/track

@trask trask merged commit 53a8b85 into open-telemetry:main Feb 18, 2022
@trask trask deleted the updates-to-http-server-name branch February 18, 2022 17:38
RashmiRam pushed a commit to RashmiRam/opentelemetry-auto-instr-java that referenced this pull request May 23, 2022
* Updates to http.server_name

* Tests

* fix

* armeria

* fix

* fix

* codenarc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants