-
Notifications
You must be signed in to change notification settings - Fork 867
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mateusz Rzeszutek
committed
Apr 20, 2022
1 parent
3124065
commit 02733bc
Showing
10 changed files
with
302 additions
and
185 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
61 changes: 61 additions & 0 deletions
61
...i-semconv/src/main/java/io/opentelemetry/instrumentation/api/internal/HttpRouteState.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,61 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.api.internal; | ||
|
||
import io.opentelemetry.context.Context; | ||
import io.opentelemetry.context.ContextKey; | ||
import io.opentelemetry.context.ImplicitContextKeyed; | ||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
* any time. | ||
*/ | ||
public final class HttpRouteState implements ImplicitContextKeyed { | ||
|
||
private static final ContextKey<HttpRouteState> KEY = | ||
ContextKey.named("opentelemetry-http-server-route-key"); | ||
|
||
@Nullable | ||
public static HttpRouteState fromContextOrNull(Context context) { | ||
return context.get(KEY); | ||
} | ||
|
||
public static HttpRouteState create(int updatedBySourceOrder, @Nullable String route) { | ||
return new HttpRouteState(updatedBySourceOrder, route); | ||
} | ||
|
||
private volatile int updatedBySourceOrder; | ||
@Nullable private volatile String route; | ||
|
||
private HttpRouteState(int updatedBySourceOrder, @Nullable String route) { | ||
this.updatedBySourceOrder = updatedBySourceOrder; | ||
this.route = route; | ||
} | ||
|
||
@Override | ||
public Context storeInContext(Context context) { | ||
return context.with(KEY, this); | ||
} | ||
|
||
public int getUpdatedBySourceOrder() { | ||
return updatedBySourceOrder; | ||
} | ||
|
||
@Nullable | ||
public String getRoute() { | ||
return route; | ||
} | ||
|
||
public void update( | ||
@SuppressWarnings("unused") | ||
Context context, // context is used by the javaagent bridge instrumentation | ||
int updatedBySourceOrder, | ||
String route) { | ||
this.updatedBySourceOrder = updatedBySourceOrder; | ||
this.route = route; | ||
} | ||
} |
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.