Search in sources :

Example 1 with WithSpan

use of io.opentelemetry.extension.annotations.WithSpan in project observable-demo by lrwh.

the class OtelController method doSomeWorkNewSpan.

@WithSpan
private void doSomeWorkNewSpan() {
    logger.info("Doing some work In New span");
    Span span = Span.current();
    span.setAttribute("attribute.a2", "some value");
    span.setAttribute("func", "doSomeWorkNewSpan");
    span.setAttribute("app", "otel");
    span.addEvent("app.processing2.start", atttributes("321"));
    span.addEvent("app.processing2.end", atttributes("321"));
}
Also used : Span(io.opentelemetry.api.trace.Span) WithSpan(io.opentelemetry.extension.annotations.WithSpan) WithSpan(io.opentelemetry.extension.annotations.WithSpan)

Example 2 with WithSpan

use of io.opentelemetry.extension.annotations.WithSpan in project DataSpaceConnector by eclipse-dataspaceconnector.

the class TransferProcessManagerImpl method sendConsumerRequest.

@WithSpan
private void sendConsumerRequest(TransferProcess process, DataRequest dataRequest) {
    process.transitionRequested();
    // update before sending to accommodate synchronous transports; reliability will be managed by retry and idempotency
    transferProcessStore.update(process);
    observable.invokeForEach(l -> l.requested(process));
    dispatcherRegistry.send(Object.class, dataRequest, process::getId).thenApply(o -> {
        // TODO: what's the point of this state transition?
        transitionToRequestAck(process.getId());
        return o;
    }).whenComplete((o, throwable) -> {
        if (o != null) {
            monitor.info("Object received: " + o);
            TransferProcess transferProcess = transferProcessStore.find(process.getId());
            if (transferProcess == null) {
                monitor.severe(format("TransferProcessManager: no TransferProcess found with id %s", process.getId()));
                return;
            }
            transferProcess.transitionInProgressOrStreaming();
            transferProcessStore.update(transferProcess);
            observable.invokeForEach(l -> l.inProgress(transferProcess));
        }
    });
}
Also used : ProvisionedResource(org.eclipse.dataspaceconnector.spi.types.domain.transfer.ProvisionedResource) TypeManager(org.eclipse.dataspaceconnector.spi.types.TypeManager) CommandRunner(org.eclipse.dataspaceconnector.spi.command.CommandRunner) TransferProcess(org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferProcess) PROVISIONED(org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferProcessStates.PROVISIONED) Function(java.util.function.Function) ProvisionManager(org.eclipse.dataspaceconnector.spi.transfer.provision.ProvisionManager) Telemetry(org.eclipse.dataspaceconnector.spi.telemetry.Telemetry) DataFlowManager(org.eclipse.dataspaceconnector.spi.transfer.flow.DataFlowManager) REQUESTED_ACK(org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferProcessStates.REQUESTED_ACK) TransferProcessObservable(org.eclipse.dataspaceconnector.spi.transfer.observe.TransferProcessObservable) IN_PROGRESS(org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferProcessStates.IN_PROGRESS) CONSUMER(org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferProcess.Type.CONSUMER) WaitStrategy(org.eclipse.dataspaceconnector.spi.retry.WaitStrategy) StatusCheckerRegistry(org.eclipse.dataspaceconnector.spi.types.domain.transfer.StatusCheckerRegistry) ResponseStatus(org.eclipse.dataspaceconnector.spi.response.ResponseStatus) TransferInitiateResult(org.eclipse.dataspaceconnector.spi.transfer.TransferInitiateResult) ResourceManifestGenerator(org.eclipse.dataspaceconnector.spi.transfer.provision.ResourceManifestGenerator) ERROR(org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferProcessStates.ERROR) Collections.emptyList(java.util.Collections.emptyList) DataRequest(org.eclipse.dataspaceconnector.spi.types.domain.transfer.DataRequest) TransferProcessCommand(org.eclipse.dataspaceconnector.spi.types.domain.transfer.command.TransferProcessCommand) PROVIDER(org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferProcess.Type.PROVIDER) DEPROVISIONED(org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferProcessStates.DEPROVISIONED) Vault(org.eclipse.dataspaceconnector.spi.security.Vault) String.format(java.lang.String.format) TransferProcessStore(org.eclipse.dataspaceconnector.spi.transfer.store.TransferProcessStore) DataAddress(org.eclipse.dataspaceconnector.spi.types.domain.DataAddress) Objects(java.util.Objects) List(java.util.List) UUID.randomUUID(java.util.UUID.randomUUID) COMPLETED(org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferProcessStates.COMPLETED) TransferProcessManager(org.eclipse.dataspaceconnector.spi.transfer.TransferProcessManager) StateMachine(org.eclipse.dataspaceconnector.common.statemachine.StateMachine) CommandProcessor(org.eclipse.dataspaceconnector.spi.command.CommandProcessor) WithSpan(io.opentelemetry.extension.annotations.WithSpan) StateProcessorImpl(org.eclipse.dataspaceconnector.common.statemachine.StateProcessorImpl) ProvisionResponse(org.eclipse.dataspaceconnector.spi.types.domain.transfer.ProvisionResponse) RemoteMessageDispatcherRegistry(org.eclipse.dataspaceconnector.spi.message.RemoteMessageDispatcherRegistry) CommandQueue(org.eclipse.dataspaceconnector.spi.command.CommandQueue) INITIAL(org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferProcessStates.INITIAL) ProvisionedDataDestinationResource(org.eclipse.dataspaceconnector.spi.types.domain.transfer.ProvisionedDataDestinationResource) TransferProcessStates(org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferProcessStates) Monitor(org.eclipse.dataspaceconnector.spi.monitor.Monitor) DEPROVISIONING_REQ(org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferProcessStates.DEPROVISIONING_REQ) TransferProcess(org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferProcess) WithSpan(io.opentelemetry.extension.annotations.WithSpan)

Example 3 with WithSpan

use of io.opentelemetry.extension.annotations.WithSpan in project DataSpaceConnector by eclipse-dataspaceconnector.

the class ProviderContractNegotiationManagerImpl method processDeclining.

/**
 * Processes {@link ContractNegotiation} in state DECLINING. Tries to send a contract rejection
 * to the respective consumer. If this succeeds, the ContractNegotiation is transitioned
 * to state DECLINED. Else, it is transitioned to DECLINING for a retry.
 *
 * @return true if processed, false elsewhere
 */
@WithSpan
private boolean processDeclining(ContractNegotiation negotiation) {
    ContractRejection rejection = ContractRejection.Builder.newInstance().protocol(negotiation.getProtocol()).connectorId(negotiation.getCounterPartyId()).connectorAddress(negotiation.getCounterPartyAddress()).correlationId(negotiation.getCorrelationId()).rejectionReason(negotiation.getErrorDetail()).build();
    // TODO protocol-independent response type?
    dispatcherRegistry.send(Object.class, rejection, () -> null).whenComplete(onRejectionSent(negotiation.getId()));
    return false;
}
Also used : ContractRejection(org.eclipse.dataspaceconnector.spi.types.domain.contract.negotiation.ContractRejection) WithSpan(io.opentelemetry.extension.annotations.WithSpan)

Example 4 with WithSpan

use of io.opentelemetry.extension.annotations.WithSpan in project DataSpaceConnector by eclipse-dataspaceconnector.

the class ProviderContractNegotiationManagerImpl method processConfirming.

/**
 * Processes {@link ContractNegotiation} in state CONFIRMING. Tries to send a contract
 * agreement to the respective consumer. If this succeeds, the ContractNegotiation is
 * transitioned to state CONFIRMED. Else, it is transitioned to CONFIRMING for a retry.
 *
 * @return true if processed, false elsewhere
 */
@WithSpan
private boolean processConfirming(ContractNegotiation negotiation) {
    var retrievedAgreement = negotiation.getContractAgreement();
    ContractAgreement agreement;
    Policy policy;
    if (retrievedAgreement == null) {
        var lastOffer = negotiation.getLastContractOffer();
        var contractIdTokens = parseContractId(lastOffer.getId());
        if (contractIdTokens.length != 2) {
            monitor.severe("ProviderContractNegotiationManagerImpl.checkConfirming(): Offer Id not correctly formatted.");
            return false;
        }
        var definitionId = contractIdTokens[DEFINITION_PART];
        policy = lastOffer.getPolicy();
        // TODO move to own service
        agreement = ContractAgreement.Builder.newInstance().id(ContractId.createContractId(definitionId)).contractStartDate(Instant.now().getEpochSecond()).contractEndDate(// TODO Make configurable (issue #722)
        Instant.now().plus(365, ChronoUnit.DAYS).getEpochSecond()).contractSigningDate(Instant.now().getEpochSecond()).providerAgentId(String.valueOf(lastOffer.getProvider())).consumerAgentId(String.valueOf(lastOffer.getConsumer())).policyId(policy.getUid()).assetId(lastOffer.getAsset().getId()).build();
    } else {
        agreement = retrievedAgreement;
        policy = policyStore.findById(agreement.getPolicyId());
    }
    var request = ContractAgreementRequest.Builder.newInstance().protocol(negotiation.getProtocol()).connectorId(negotiation.getCounterPartyId()).connectorAddress(negotiation.getCounterPartyAddress()).contractAgreement(agreement).correlationId(negotiation.getCorrelationId()).policy(policy).build();
    // TODO protocol-independent response type?
    dispatcherRegistry.send(Object.class, request, () -> null).whenComplete(onAgreementSent(negotiation.getId(), agreement));
    return true;
}
Also used : Policy(org.eclipse.dataspaceconnector.policy.model.Policy) ContractAgreement(org.eclipse.dataspaceconnector.spi.types.domain.contract.agreement.ContractAgreement) WithSpan(io.opentelemetry.extension.annotations.WithSpan)

Example 5 with WithSpan

use of io.opentelemetry.extension.annotations.WithSpan in project DataSpaceConnector by eclipse-dataspaceconnector.

the class TransferProcessManagerImpl method processInitial.

/**
 * Process INITIAL transfer<p>
 * set it to PROVISIONING
 *
 * @param process the INITIAL transfer fetched
 * @return if the transfer has been processed or not
 */
@WithSpan
private boolean processInitial(TransferProcess process) {
    var dataRequest = process.getDataRequest();
    var policy = policyArchive.findPolicyForContract(dataRequest.getContractId());
    ResourceManifest manifest;
    if (process.getType() == CONSUMER) {
        manifest = manifestGenerator.generateConsumerResourceManifest(dataRequest, policy);
    } else {
        var assetId = process.getDataRequest().getAssetId();
        var dataAddress = addressResolver.resolveForAsset(assetId);
        if (dataAddress == null) {
            process.transitionError("Asset not found: " + assetId);
            updateTransferProcess(process, l -> l.preError(process));
        }
        // default the content address to the asset address; this may be overridden during provisioning
        process.addContentDataAddress(dataAddress);
        manifest = manifestGenerator.generateProviderResourceManifest(dataRequest, dataAddress, policy);
    }
    process.transitionProvisioning(manifest);
    updateTransferProcess(process, l -> l.preProvisioning(process));
    return true;
}
Also used : ResourceManifest(org.eclipse.dataspaceconnector.spi.types.domain.transfer.ResourceManifest) WithSpan(io.opentelemetry.extension.annotations.WithSpan)

Aggregations

WithSpan (io.opentelemetry.extension.annotations.WithSpan)8 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 Book (com.radcortez.quarkus.playground.services.book.entity.Book)1 Span (io.opentelemetry.api.trace.Span)1 String.format (java.lang.String.format)1 Collections.emptyList (java.util.Collections.emptyList)1 List (java.util.List)1 Objects (java.util.Objects)1 UUID.randomUUID (java.util.UUID.randomUUID)1 Function (java.util.function.Function)1 Request (okhttp3.Request)1 RequestBody (okhttp3.RequestBody)1 StateMachine (org.eclipse.dataspaceconnector.common.statemachine.StateMachine)1 StateProcessorImpl (org.eclipse.dataspaceconnector.common.statemachine.StateProcessorImpl)1 Policy (org.eclipse.dataspaceconnector.policy.model.Policy)1 EdcException (org.eclipse.dataspaceconnector.spi.EdcException)1 CommandProcessor (org.eclipse.dataspaceconnector.spi.command.CommandProcessor)1 CommandQueue (org.eclipse.dataspaceconnector.spi.command.CommandQueue)1 CommandRunner (org.eclipse.dataspaceconnector.spi.command.CommandRunner)1 RemoteMessageDispatcherRegistry (org.eclipse.dataspaceconnector.spi.message.RemoteMessageDispatcherRegistry)1