forked from quarkusio/quarkus
-
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.
Micrometer Vert.x HTTP request propagation
- Loading branch information
Showing
8 changed files
with
143 additions
and
129 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
56 changes: 0 additions & 56 deletions
56
...eter/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/vertx/MetricsContext.java
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
...meter/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/vertx/RequestMetric.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,56 @@ | ||
package io.quarkus.micrometer.runtime.binder.vertx; | ||
|
||
import java.util.HashMap; | ||
|
||
import io.vertx.core.Context; | ||
import io.vertx.ext.web.RoutingContext; | ||
|
||
public class RequestMetric extends HashMap<String, Object> { | ||
static final String METRICS_CONTEXT = "HTTP_REQUEST_METRICS_CONTEXT"; | ||
|
||
static final String HTTP_REQUEST_PATH = "HTTP_REQUEST_PATH"; | ||
static final String HTTP_REQUEST_SAMPLE = "HTTP_REQUEST_SAMPLE"; | ||
|
||
volatile RoutingContext routingContext; | ||
|
||
/** | ||
* Stash the RequestMetric in the Vertx Context | ||
* | ||
* @param context Vertx context to store RequestMetric in | ||
* @param requestMetric | ||
* @see VertxMeterFilter | ||
*/ | ||
public static void setRequestMetric(Context context, RequestMetric requestMetric) { | ||
if (context != null) { | ||
context.put(METRICS_CONTEXT, requestMetric); | ||
} | ||
} | ||
|
||
/** | ||
* Retrieve and remove the RequestMetric from the Vertx Context | ||
* | ||
* @param context | ||
* @return the RequestMetricContext stored in the Vertx Context, or null | ||
* @see VertxMeterFilter | ||
*/ | ||
public static RequestMetric retrieveRequestMetric(Context context) { | ||
if (context != null) { | ||
RequestMetric requestMetric = context.get(METRICS_CONTEXT); | ||
context.remove(METRICS_CONTEXT); | ||
return requestMetric; | ||
} | ||
return null; | ||
} | ||
|
||
<T> T getFromRoutingContext(String key) { | ||
if (routingContext != null) { | ||
return routingContext.get(key); | ||
} | ||
return null; | ||
} | ||
|
||
<T> T getValue(String key) { | ||
Object o = this.get(key); | ||
return o == null ? null : (T) o; | ||
} | ||
} |
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
Oops, something went wrong.