Skip to content

Commit f7ca82e

Browse files
Revert "Removed Wavefront support"
This reverts commit 5a46936.
1 parent be95637 commit f7ca82e

File tree

4 files changed

+111
-1
lines changed

4 files changed

+111
-1
lines changed

pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
<opentelemetry.version>1.2.0</opentelemetry.version>
7171
<opentelemetry.alpha.version>1.2.0-alpha</opentelemetry.alpha.version>
7272
<opentelemetry-instrumentation.version>1.1.0-alpha</opentelemetry-instrumentation.version>
73+
<wavefront.version>2.2.0-SNAPSHOT</wavefront.version>
7374
<spring-security-boot-autoconfigure.version>2.3.4.RELEASE</spring-security-boot-autoconfigure.version>
7475
<disable.nohttp.checks>false</disable.nohttp.checks>
7576
<okhttp.version>4.9.0</okhttp.version>
@@ -302,6 +303,13 @@
302303
<artifactId>jsr305</artifactId>
303304
<version>${jsr305.version}</version>
304305
</dependency>
306+
<dependency>
307+
<groupId>com.wavefront</groupId>
308+
<artifactId>wavefront-spring-boot-bom</artifactId>
309+
<version>${wavefront.version}</version>
310+
<type>pom</type>
311+
<scope>import</scope>
312+
</dependency>
305313
</dependencies>
306314
</dependencyManagement>
307315

spring-cloud-sleuth-otel-autoconfigure/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050
<artifactId>spring-boot-configuration-processor</artifactId>
5151
<optional>true</optional>
5252
</dependency>
53+
<dependency>
54+
<groupId>com.wavefront</groupId>
55+
<artifactId>wavefront-spring-boot</artifactId>
56+
<optional>true</optional>
57+
</dependency>
5358

5459
<dependency>
5560
<groupId>javax.jms</groupId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
* Copyright 2013-2020 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.cloud.sleuth.autoconfig.otel.wavefront;
18+
19+
import java.util.Collection;
20+
21+
import com.wavefront.spring.autoconfigure.WavefrontAutoConfiguration;
22+
import com.wavefront.spring.autoconfigure.WavefrontSleuthSpanHandler;
23+
import io.opentelemetry.sdk.common.CompletableResultCode;
24+
import io.opentelemetry.sdk.trace.data.SpanData;
25+
import io.opentelemetry.sdk.trace.export.SpanExporter;
26+
27+
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
28+
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
29+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
30+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
31+
import org.springframework.cloud.sleuth.TraceContext;
32+
import org.springframework.cloud.sleuth.otel.bridge.OtelFinishedSpan;
33+
import org.springframework.context.annotation.Bean;
34+
import org.springframework.context.annotation.Configuration;
35+
36+
/**
37+
* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration}
38+
* Auto-configuration enables reporting to Wavefront.
39+
*
40+
* @author Marcin Grzejszczak
41+
* @since 1.0.0
42+
*/
43+
@Configuration(proxyBeanMethods = false)
44+
@ConditionalOnProperty(value = { "spring.sleuth.enabled", "spring.sleuth.wavefront.enabled" }, matchIfMissing = true)
45+
@ConditionalOnClass(WavefrontSleuthSpanHandler.class)
46+
@AutoConfigureAfter(WavefrontAutoConfiguration.class)
47+
public class WavefrontOtelAutoConfiguration {
48+
49+
@Bean
50+
@ConditionalOnBean(WavefrontSleuthSpanHandler.class)
51+
SpanExporter wavefrontSpanExporter(WavefrontSleuthSpanHandler spanHandler) {
52+
return new SpanExporter() {
53+
@Override
54+
public CompletableResultCode export(Collection<SpanData> spans) {
55+
spans.forEach(spanData -> spanHandler.end(traceContext(spanData), OtelFinishedSpan.fromOtel(spanData)));
56+
return CompletableResultCode.ofSuccess();
57+
}
58+
59+
private TraceContext traceContext(SpanData spanData) {
60+
return new TraceContext() {
61+
@Override
62+
public String traceId() {
63+
return spanData.getTraceId();
64+
}
65+
66+
@Override
67+
public String parentId() {
68+
return spanData.getParentSpanId();
69+
}
70+
71+
@Override
72+
public String spanId() {
73+
return spanData.getSpanId();
74+
}
75+
76+
@Override
77+
public Boolean sampled() {
78+
return spanData.getSpanContext().isSampled();
79+
}
80+
};
81+
}
82+
83+
@Override
84+
public CompletableResultCode flush() {
85+
return CompletableResultCode.ofSuccess();
86+
}
87+
88+
@Override
89+
public CompletableResultCode shutdown() {
90+
spanHandler.close();
91+
return CompletableResultCode.ofSuccess();
92+
}
93+
};
94+
}
95+
96+
}

spring-cloud-sleuth-otel-autoconfigure/src/main/resources/META-INF/spring.factories

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
33
org.springframework.cloud.sleuth.autoconfig.otel.OtelAutoConfiguration,\
44
org.springframework.cloud.sleuth.autoconfig.otel.MultipleTracerAutoConfigurationsDetector,\
55
org.springframework.cloud.sleuth.autoconfig.otel.instrument.opentracing.OtelOpentracingAutoConfiguration,\
6-
org.springframework.cloud.sleuth.autoconfig.otel.zipkin2.ZipkinOtelAutoConfiguration
6+
org.springframework.cloud.sleuth.autoconfig.otel.zipkin2.ZipkinOtelAutoConfiguration,\
7+
org.springframework.cloud.sleuth.autoconfig.otel.wavefront.WavefrontOtelAutoConfiguration

0 commit comments

Comments
 (0)