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"));
}
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));
}
});
}
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;
}
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;
}
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;
}
Aggregations