Search in sources :

Example 41 with RequestSpan

use of com.couchbase.client.core.cnc.RequestSpan in project couchbase-jvm-clients by couchbase.

the class AsyncQueryIndexManager method exec.

private CompletableFuture<QueryResult> exec(QueryType queryType, CharSequence statement, CommonOptions<?>.BuiltCommonOptions options, String spanName, String bucketName, JsonArray parameters) {
    QueryOptions queryOpts = toQueryOptions(options).readonly(requireNonNull(queryType) == READ_ONLY);
    if (parameters != null && !parameters.isEmpty()) {
        queryOpts.parameters(parameters);
    }
    RequestSpan parent = cluster.environment().requestTracer().requestSpan(spanName, options.parentSpan().orElse(null));
    parent.attribute(TracingIdentifiers.ATTR_SYSTEM, TracingIdentifiers.ATTR_SYSTEM_COUCHBASE);
    if (bucketName != null) {
        parent.attribute(TracingIdentifiers.ATTR_NAME, bucketName);
    }
    queryOpts.parentSpan(parent);
    return cluster.query(statement.toString(), queryOpts).exceptionally(t -> {
        throw translateException(t);
    }).whenComplete((r, t) -> parent.end());
}
Also used : Arrays(java.util.Arrays) Validators.notNull(com.couchbase.client.core.util.Validators.notNull) RetryExhaustedException(com.couchbase.client.core.retry.reactor.RetryExhaustedException) CbThrowables.findCause(com.couchbase.client.core.util.CbThrowables.findCause) TimeoutException(java.util.concurrent.TimeoutException) QueryResult(com.couchbase.client.java.query.QueryResult) Collectors.toMap(java.util.stream.Collectors.toMap) Duration(java.time.Duration) Map(java.util.Map) CbThrowables.throwIfUnchecked(com.couchbase.client.core.util.CbThrowables.throwIfUnchecked) RequestSpan(com.couchbase.client.core.cnc.RequestSpan) READ_ONLY(com.couchbase.client.java.manager.query.AsyncQueryIndexManager.QueryType.READ_ONLY) IndexExistsException(com.couchbase.client.core.error.IndexExistsException) Collectors.toSet(java.util.stream.Collectors.toSet) DropPrimaryQueryIndexOptions.dropPrimaryQueryIndexOptions(com.couchbase.client.java.manager.query.DropPrimaryQueryIndexOptions.dropPrimaryQueryIndexOptions) CbThrowables.hasCause(com.couchbase.client.core.util.CbThrowables.hasCause) Predicate(java.util.function.Predicate) Mapper(com.couchbase.client.core.json.Mapper) Collection(java.util.Collection) Set(java.util.Set) InvalidArgumentException(com.couchbase.client.core.error.InvalidArgumentException) Collectors(java.util.stream.Collectors) Validators.notNullOrEmpty(com.couchbase.client.core.util.Validators.notNullOrEmpty) QueryOptions(com.couchbase.client.java.query.QueryOptions) List(java.util.List) GetAllQueryIndexesOptions.getAllQueryIndexesOptions(com.couchbase.client.java.manager.query.GetAllQueryIndexesOptions.getAllQueryIndexesOptions) RedactableArgument.redactMeta(com.couchbase.client.core.logging.RedactableArgument.redactMeta) Optional(java.util.Optional) WRITE(com.couchbase.client.java.manager.query.AsyncQueryIndexManager.QueryType.WRITE) CreatePrimaryQueryIndexOptions.createPrimaryQueryIndexOptions(com.couchbase.client.java.manager.query.CreatePrimaryQueryIndexOptions.createPrimaryQueryIndexOptions) CreateQueryIndexOptions.createQueryIndexOptions(com.couchbase.client.java.manager.query.CreateQueryIndexOptions.createQueryIndexOptions) Retry(com.couchbase.client.core.retry.reactor.Retry) CouchbaseException(com.couchbase.client.core.error.CouchbaseException) CompletableFuture(java.util.concurrent.CompletableFuture) WatchQueryIndexesOptions.watchQueryIndexesOptions(com.couchbase.client.java.manager.query.WatchQueryIndexesOptions.watchQueryIndexesOptions) QueryException(com.couchbase.client.core.error.QueryException) Function(java.util.function.Function) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) CommonOptions(com.couchbase.client.java.CommonOptions) TracingIdentifiers(com.couchbase.client.core.cnc.TracingIdentifiers) Objects.requireNonNull(java.util.Objects.requireNonNull) Stability(com.couchbase.client.core.annotation.Stability) IndexFailureException(com.couchbase.client.core.error.IndexFailureException) IndexesNotReadyException(com.couchbase.client.core.error.IndexesNotReadyException) DropQueryIndexOptions.dropQueryIndexOptions(com.couchbase.client.java.manager.query.DropQueryIndexOptions.dropQueryIndexOptions) Reactor(com.couchbase.client.core.Reactor) IndexNotFoundException(com.couchbase.client.core.error.IndexNotFoundException) Mono(reactor.core.publisher.Mono) JsonArray(com.couchbase.client.java.json.JsonArray) Collectors.toList(java.util.stream.Collectors.toList) BuildQueryIndexOptions.buildDeferredQueryIndexesOptions(com.couchbase.client.java.manager.query.BuildQueryIndexOptions.buildDeferredQueryIndexesOptions) AsyncCluster(com.couchbase.client.java.AsyncCluster) QueryOptions(com.couchbase.client.java.query.QueryOptions) RequestSpan(com.couchbase.client.core.cnc.RequestSpan)

Example 42 with RequestSpan

use of com.couchbase.client.core.cnc.RequestSpan in project couchbase-jvm-clients by couchbase.

the class AsyncAnalyticsIndexManager method exec.

/**
 * Executes a statement with options against analytics.
 *
 * @param statement the statement of the query.
 * @param options the options that should be passed along.
 * @param spanName the name of the span as the outer parent.
 * @return a future eventually containing the analytics result once complete, or a failure.
 */
private CompletableFuture<AnalyticsResult> exec(final String statement, final CommonOptions<?>.BuiltCommonOptions options, final String spanName) {
    RequestSpan parent = CbTracing.newSpan(cluster.environment().requestTracer(), spanName, options.parentSpan().orElse(null));
    final AnalyticsOptions analyticsOptions = toAnalyticsOptions(options).parentSpan(parent);
    return cluster.analyticsQuery(statement, analyticsOptions).whenComplete((r, t) -> parent.end());
}
Also used : GetLinksAnalyticsOptions.getLinksAnalyticsOptions(com.couchbase.client.java.manager.analytics.GetLinksAnalyticsOptions.getLinksAnalyticsOptions) ReplaceLinkAnalyticsOptions.replaceLinkAnalyticsOptions(com.couchbase.client.java.manager.analytics.ReplaceLinkAnalyticsOptions.replaceLinkAnalyticsOptions) GetAllIndexesAnalyticsOptions.getAllIndexesAnalyticsOptions(com.couchbase.client.java.manager.analytics.GetAllIndexesAnalyticsOptions.getAllIndexesAnalyticsOptions) CreateLinkAnalyticsOptions.createLinkAnalyticsOptions(com.couchbase.client.java.manager.analytics.CreateLinkAnalyticsOptions.createLinkAnalyticsOptions) CreateIndexAnalyticsOptions.createIndexAnalyticsOptions(com.couchbase.client.java.manager.analytics.CreateIndexAnalyticsOptions.createIndexAnalyticsOptions) DropLinkAnalyticsOptions.dropLinkAnalyticsOptions(com.couchbase.client.java.manager.analytics.DropLinkAnalyticsOptions.dropLinkAnalyticsOptions) DisconnectLinkAnalyticsOptions.disconnectLinkAnalyticsOptions(com.couchbase.client.java.manager.analytics.DisconnectLinkAnalyticsOptions.disconnectLinkAnalyticsOptions) DropDatasetAnalyticsOptions.dropDatasetAnalyticsOptions(com.couchbase.client.java.manager.analytics.DropDatasetAnalyticsOptions.dropDatasetAnalyticsOptions) AnalyticsOptions(com.couchbase.client.java.analytics.AnalyticsOptions) GetAllDataversesAnalyticsOptions.getAllDataversesAnalyticsOptions(com.couchbase.client.java.manager.analytics.GetAllDataversesAnalyticsOptions.getAllDataversesAnalyticsOptions) CreateDatasetAnalyticsOptions.createDatasetAnalyticsOptions(com.couchbase.client.java.manager.analytics.CreateDatasetAnalyticsOptions.createDatasetAnalyticsOptions) GetAllDatasetsAnalyticsOptions.getAllDatasetsAnalyticsOptions(com.couchbase.client.java.manager.analytics.GetAllDatasetsAnalyticsOptions.getAllDatasetsAnalyticsOptions) ConnectLinkAnalyticsOptions.connectLinkAnalyticsOptions(com.couchbase.client.java.manager.analytics.ConnectLinkAnalyticsOptions.connectLinkAnalyticsOptions) DropDataverseAnalyticsOptions.dropDataverseAnalyticsOptions(com.couchbase.client.java.manager.analytics.DropDataverseAnalyticsOptions.dropDataverseAnalyticsOptions) GetPendingMutationsAnalyticsOptions.getPendingMutationsAnalyticsOptions(com.couchbase.client.java.manager.analytics.GetPendingMutationsAnalyticsOptions.getPendingMutationsAnalyticsOptions) CreateDataverseAnalyticsOptions.createDataverseAnalyticsOptions(com.couchbase.client.java.manager.analytics.CreateDataverseAnalyticsOptions.createDataverseAnalyticsOptions) DropIndexAnalyticsOptions.dropIndexAnalyticsOptions(com.couchbase.client.java.manager.analytics.DropIndexAnalyticsOptions.dropIndexAnalyticsOptions) RequestSpan(com.couchbase.client.core.cnc.RequestSpan)

Aggregations

RequestSpan (com.couchbase.client.core.cnc.RequestSpan)42 Duration (java.time.Duration)30 RetryStrategy (com.couchbase.client.core.retry.RetryStrategy)28 TracingIdentifiers (com.couchbase.client.core.cnc.TracingIdentifiers)12 CompletableFuture (java.util.concurrent.CompletableFuture)11 Stability (com.couchbase.client.core.annotation.Stability)10 Validators.notNullOrEmpty (com.couchbase.client.core.util.Validators.notNullOrEmpty)10 List (java.util.List)10 Core (com.couchbase.client.core.Core)9 ArrayList (java.util.ArrayList)9 Map (java.util.Map)9 BucketConfig (com.couchbase.client.core.config.BucketConfig)8 CouchbaseException (com.couchbase.client.core.error.CouchbaseException)8 Objects.requireNonNull (java.util.Objects.requireNonNull)8 Mono (reactor.core.publisher.Mono)8 Reactor (com.couchbase.client.core.Reactor)7 InvalidArgumentException (com.couchbase.client.core.error.InvalidArgumentException)7 GetRequest (com.couchbase.client.core.msg.kv.GetRequest)7 Function (java.util.function.Function)7 CoreContext (com.couchbase.client.core.CoreContext)6