Skip to content

Commit

Permalink
Revert wrong file
Browse files Browse the repository at this point in the history
  • Loading branch information
lojzatran committed Nov 30, 2023
1 parent 5cdade4 commit f6482f1
Showing 1 changed file with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

package com.commercetools.sdk.examples.springmvc.service;

import com.commercetools.api.client.ProjectApiRoot;
import com.commercetools.api.client.ProjectScopedApiRoot;
import com.commercetools.api.defaultconfig.ApiRootBuilder;

import com.commercetools.monitoring.opentelemetry.OpenTelemetryMiddleware;
import com.commercetools.monitoring.opentelemetry.OpenTelemetryResponseSerializer;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.vrap.rmf.base.client.*;
Expand All @@ -13,6 +15,7 @@
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.annotation.RequestScope;

@Configuration
@EnableAutoConfiguration
Expand All @@ -27,27 +30,16 @@ public class CtpClientBeanService {
@Value(value = "${ctp.project.key}")
private String projectKey;

@Value(value = "${ctp.enable.histogram:true}")
private boolean enableHistogram;

private ClientCredentials credentials() {
return ClientCredentials.of().withClientId(clientId).withClientSecret(clientSecret).build();
}

@Bean
public ProjectScopedApiRoot apiRoot() {
if (enableHistogram){
return ApiRootBuilder.of()
.defaultClient(credentials())
.withSerializer(new OpenTelemetryResponseSerializer(ResponseSerializer.of(), GlobalOpenTelemetry.get()))
.withTelemetryMiddleware(new OpenTelemetryMiddleware(GlobalOpenTelemetry.get()))
.build(projectKey);
} else {
return ApiRootBuilder.of()
.defaultClient(credentials())
.withTelemetryMiddleware(new OpenTelemetryMiddleware(GlobalOpenTelemetry.get(), false))
.build(projectKey);
}

return ApiRootBuilder.of()
.defaultClient(credentials())
.withSerializer(new OpenTelemetryResponseSerializer(ResponseSerializer.of(), GlobalOpenTelemetry.get()))
.withTelemetryMiddleware(new OpenTelemetryMiddleware(GlobalOpenTelemetry.get()))
.build(projectKey);
}
}

0 comments on commit f6482f1

Please sign in to comment.