-
Notifications
You must be signed in to change notification settings - Fork 870
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add HttpServerResponseCustomizer support for Netty (#8094)
Add `HttpServerResponseCustomizer` support for Netty 3.8, 4.0 and 4.1 instrumentations and enable testing for it in their respective `HttpServerTest` tests.
- Loading branch information
1 parent
2ebed6c
commit 079e0fa
Showing
14 changed files
with
166 additions
and
7 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
20 changes: 20 additions & 0 deletions
20
...o/opentelemetry/javaagent/instrumentation/netty/v3_8/server/NettyHttpResponseMutator.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,20 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.netty.v3_8.server; | ||
|
||
import io.opentelemetry.javaagent.bootstrap.http.HttpServerResponseMutator; | ||
import org.jboss.netty.handler.codec.http.HttpResponse; | ||
|
||
public enum NettyHttpResponseMutator implements HttpServerResponseMutator<HttpResponse> { | ||
INSTANCE; | ||
|
||
NettyHttpResponseMutator() {} | ||
|
||
@Override | ||
public void appendHeader(HttpResponse response, String name, String value) { | ||
response.headers().add(name, 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
20 changes: 20 additions & 0 deletions
20
...o/opentelemetry/javaagent/instrumentation/netty/v4_0/server/NettyHttpResponseMutator.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,20 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.netty.v4_0.server; | ||
|
||
import io.netty.handler.codec.http.HttpResponse; | ||
import io.opentelemetry.javaagent.bootstrap.http.HttpServerResponseMutator; | ||
|
||
public enum NettyHttpResponseMutator implements HttpServerResponseMutator<HttpResponse> { | ||
INSTANCE; | ||
|
||
NettyHttpResponseMutator() {} | ||
|
||
@Override | ||
public void appendHeader(HttpResponse response, String name, String value) { | ||
response.headers().add(name, 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
22 changes: 22 additions & 0 deletions
22
...etry/javaagent/instrumentation/netty/v4_1/NettyHttpServerResponseBeforeCommitHandler.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,22 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.netty.v4_1; | ||
|
||
import io.netty.handler.codec.http.HttpResponse; | ||
import io.opentelemetry.context.Context; | ||
import io.opentelemetry.instrumentation.netty.v4_1.internal.server.HttpServerResponseBeforeCommitHandler; | ||
import io.opentelemetry.javaagent.bootstrap.http.HttpServerResponseCustomizerHolder; | ||
|
||
public enum NettyHttpServerResponseBeforeCommitHandler | ||
implements HttpServerResponseBeforeCommitHandler { | ||
INSTANCE; | ||
|
||
@Override | ||
public void handle(Context context, HttpResponse response) { | ||
HttpServerResponseCustomizerHolder.getCustomizer() | ||
.customize(context, response, NettyHttpServerResponseMutator.INSTANCE); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...io/opentelemetry/javaagent/instrumentation/netty/v4_1/NettyHttpServerResponseMutator.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,18 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.netty.v4_1; | ||
|
||
import io.netty.handler.codec.http.HttpResponse; | ||
import io.opentelemetry.javaagent.bootstrap.http.HttpServerResponseMutator; | ||
|
||
public enum NettyHttpServerResponseMutator implements HttpServerResponseMutator<HttpResponse> { | ||
INSTANCE; | ||
|
||
@Override | ||
public void appendHeader(HttpResponse response, String name, String value) { | ||
response.headers().add(name, 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
28 changes: 28 additions & 0 deletions
28
...try/instrumentation/netty/v4_1/internal/server/HttpServerResponseBeforeCommitHandler.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,28 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.netty.v4_1.internal.server; | ||
|
||
import io.netty.handler.codec.http.HttpResponse; | ||
import io.opentelemetry.context.Context; | ||
|
||
/** | ||
* This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
* any time. | ||
*/ | ||
public interface HttpServerResponseBeforeCommitHandler { | ||
void handle(Context context, HttpResponse response); | ||
|
||
/** | ||
* This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
* any time. | ||
*/ | ||
enum Noop implements HttpServerResponseBeforeCommitHandler { | ||
INSTANCE; | ||
|
||
@Override | ||
public void handle(Context context, HttpResponse response) {} | ||
} | ||
} |
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