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.
Continue PR quarkusio#40191 - Add docs - Add tests - Fix parent-child spans for reactive request
- Loading branch information
Showing
13 changed files
with
380 additions
and
39 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
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
23 changes: 23 additions & 0 deletions
23
...ient/deployment/src/main/java/io/quarkus/mongodb/deployment/ContextProviderBuildItem.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,23 @@ | ||
package io.quarkus.mongodb.deployment; | ||
|
||
import java.util.List; | ||
|
||
import com.mongodb.reactivestreams.client.ReactiveContextProvider; | ||
|
||
import io.quarkus.builder.item.SimpleBuildItem; | ||
|
||
/** | ||
* Register additional {@link ReactiveContextProvider}s for the MongoDB clients. | ||
*/ | ||
public final class ContextProviderBuildItem extends SimpleBuildItem { | ||
|
||
private final List<String> classNames; | ||
|
||
public ContextProviderBuildItem(List<String> classNames) { | ||
this.classNames = classNames; | ||
} | ||
|
||
public List<String> getContextProviderClassNames() { | ||
return classNames; | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
...client/runtime/src/main/java/io/quarkus/mongodb/runtime/MongoReactiveContextProvider.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,17 @@ | ||
package io.quarkus.mongodb.runtime; | ||
|
||
import org.reactivestreams.Subscriber; | ||
|
||
import com.mongodb.RequestContext; | ||
import com.mongodb.reactivestreams.client.ReactiveContextProvider; | ||
|
||
import io.opentelemetry.context.Context; | ||
|
||
public class MongoReactiveContextProvider implements ReactiveContextProvider { | ||
|
||
@Override | ||
public RequestContext getContext(Subscriber<?> subscriber) { | ||
return new MongoRequestContext(Context.current()); | ||
} | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
.../mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/MongoRequestContext.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,55 @@ | ||
package io.quarkus.mongodb.runtime; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import java.util.stream.Stream; | ||
|
||
import com.mongodb.RequestContext; | ||
|
||
import io.opentelemetry.context.Context; | ||
|
||
@SuppressWarnings("unchecked") | ||
public class MongoRequestContext implements RequestContext { | ||
public static final String OTEL_CONTEXT_KEY = "otel.context.current"; | ||
private final Map<Object, Object> valuesMap; | ||
|
||
MongoRequestContext(Context currentContext) { | ||
valuesMap = new ConcurrentHashMap<>(); | ||
valuesMap.put(OTEL_CONTEXT_KEY, currentContext); | ||
} | ||
|
||
@Override | ||
public <T> T get(Object key) { | ||
return (T) valuesMap.get(key); | ||
} | ||
|
||
@Override | ||
public boolean hasKey(Object key) { | ||
return valuesMap.containsKey(key); | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return valuesMap.isEmpty(); | ||
} | ||
|
||
@Override | ||
public void put(Object key, Object value) { | ||
valuesMap.put(key, value); | ||
} | ||
|
||
@Override | ||
public void delete(Object key) { | ||
valuesMap.remove(key); | ||
} | ||
|
||
@Override | ||
public int size() { | ||
return valuesMap.size(); | ||
} | ||
|
||
@Override | ||
public Stream<Map.Entry<Object, Object>> stream() { | ||
return valuesMap.entrySet().stream(); | ||
} | ||
} |
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.