-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add OpenTelemetry feature into Gravitee Node
BREAKING CHANGE: Tracing plugin has been removed and is now embedded inside node framework
- Loading branch information
1 parent
539400d
commit 8da7990
Showing
105 changed files
with
4,653 additions
and
599 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
gravitee-node-api/src/main/java/io/gravitee/node/api/opentelemetry/InstrumenterTracer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright © 2015 The Gravitee team (http://gravitee.io) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.gravitee.node.api.opentelemetry; | ||
|
||
import io.vertx.core.Context; | ||
|
||
/** | ||
* @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) | ||
* @author GraviteeSource Team | ||
*/ | ||
public interface InstrumenterTracer { | ||
String instrumentationName(); | ||
|
||
<R> boolean canHandle(final R request); | ||
|
||
<R> Span startSpan(final Context vertxContext, final R request, final boolean root, final Span parentSpan); | ||
|
||
<R> void endSpan(final Context vertxContext, final Span span, final R response, final Throwable throwable); | ||
} |
17 changes: 8 additions & 9 deletions
17
.../io/gravitee/node/api/tracing/Tracer.java → ...ntelemetry/InstrumenterTracerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,26 @@ | ||
/** | ||
* Copyright (C) 2015 The Gravitee team (http://gravitee.io) | ||
/* | ||
* Copyright © 2015 The Gravitee team (http://gravitee.io) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.gravitee.node.api.tracing; | ||
package io.gravitee.node.api.opentelemetry; | ||
|
||
import io.gravitee.common.component.LifecycleComponent; | ||
import io.gravitee.tracing.api.Span; | ||
import io.opentelemetry.api.OpenTelemetry; | ||
|
||
/** | ||
* @author David BRASSELY (david.brassely at graviteesource.com) | ||
* @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) | ||
* @author GraviteeSource Team | ||
*/ | ||
public interface Tracer extends LifecycleComponent<Tracer> { | ||
Span trace(String spanName); | ||
public interface InstrumenterTracerFactory { | ||
InstrumenterTracer createInstrumenterTracer(final OpenTelemetry openTelemetry); | ||
} |
18 changes: 9 additions & 9 deletions
18
...tee/node/tracing/plugin/TracerPlugin.java → ...gravitee/node/api/opentelemetry/Span.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
/** | ||
* Copyright (C) 2015 The Gravitee team (http://gravitee.io) | ||
/* | ||
* Copyright © 2015 The Gravitee team (http://gravitee.io) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.gravitee.node.tracing.plugin; | ||
|
||
import io.gravitee.plugin.core.api.Plugin; | ||
package io.gravitee.node.api.opentelemetry; | ||
|
||
/** | ||
* @author David BRASSELY (david.brassely at graviteesource.com) | ||
* @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) | ||
* @author GraviteeSource Team | ||
*/ | ||
public interface TracerPlugin extends Plugin { | ||
String PLUGIN_TYPE = "tracer"; | ||
public interface Span { | ||
boolean isRoot(); | ||
|
||
<T> Span withAttribute(final String name, final T value); | ||
} |
43 changes: 43 additions & 0 deletions
43
gravitee-node-api/src/main/java/io/gravitee/node/api/opentelemetry/Tracer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright © 2015 The Gravitee team (http://gravitee.io) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.gravitee.node.api.opentelemetry; | ||
|
||
import io.gravitee.common.service.Service; | ||
import io.vertx.core.Context; | ||
|
||
/** | ||
* @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) | ||
* @author GraviteeSource Team | ||
*/ | ||
public interface Tracer extends Service<Tracer> { | ||
<R> Span startRootSpanFrom(final Context vertxContext, final R request); | ||
|
||
<R> Span startSpanFrom(final Context vertxContext, final R request); | ||
|
||
<R> Span startSpanWithParentFrom(Context vertxContext, Span parentSpan, R request); | ||
|
||
void end(final Context vertxContext, final Span span); | ||
|
||
void endOnError(final Context vertxContext, final Span span, final Throwable throwable); | ||
|
||
void endOnError(final Context vertxContext, final Span span, final String message); | ||
|
||
<R> void endWithResponse(final Context vertxContext, final Span span, final R response); | ||
|
||
<R> void endWithResponseAndError(final Context vertxContext, final Span span, final R response, final Throwable throwable); | ||
|
||
<R> void endWithResponseAndError(final Context vertxContext, final Span span, final R response, final String message); | ||
} |
32 changes: 32 additions & 0 deletions
32
gravitee-node-api/src/main/java/io/gravitee/node/api/opentelemetry/TracerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright © 2015 The Gravitee team (http://gravitee.io) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.gravitee.node.api.opentelemetry; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) | ||
* @author GraviteeSource Team | ||
*/ | ||
public interface TracerFactory { | ||
Tracer createTracer( | ||
final String id, | ||
final String serviceName, | ||
final String serviceNamespace, | ||
final String version, | ||
final List<InstrumenterTracerFactory> instrumenterTracerFactories | ||
); | ||
} |
106 changes: 106 additions & 0 deletions
106
...pi/src/main/java/io/gravitee/node/api/opentelemetry/http/ObservableHttpClientRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
* Copyright © 2015 The Gravitee team (http://gravitee.io) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.gravitee.node.api.opentelemetry.http; | ||
|
||
import io.vertx.core.MultiMap; | ||
import io.vertx.core.http.HttpClientRequest; | ||
import io.vertx.core.http.HttpMethod; | ||
import io.vertx.core.http.RequestOptions; | ||
import io.vertx.core.http.impl.HttpRequestHead; | ||
import io.vertx.core.http.impl.headers.HeadersMultiMap; | ||
import io.vertx.core.net.SocketAddress; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NonNull; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.experimental.Accessors; | ||
|
||
/** | ||
* @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) | ||
* @author GraviteeSource Team | ||
*/ | ||
@RequiredArgsConstructor | ||
@Getter | ||
@Setter | ||
@Accessors(fluent = true) | ||
public class ObservableHttpClientRequest implements ObservableHttpRequest { | ||
|
||
@NonNull | ||
private final RequestOptions requestOptions; | ||
|
||
private HttpClientRequest httpClientRequest; | ||
|
||
/** | ||
* Only used for internal Vertx testing; see {@link HttpRequestHead#id() } | ||
*/ | ||
@Override | ||
public int id() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public String uri() { | ||
return requestOptions.getURI(); | ||
} | ||
|
||
@Override | ||
public String absoluteURI() { | ||
return ( | ||
(Boolean.TRUE.equals(requestOptions.isSsl()) ? "https://" : "http://") + | ||
requestOptions.getHost() + | ||
':' + | ||
requestOptions.getPort() + | ||
requestOptions.getURI() | ||
); | ||
} | ||
|
||
@Override | ||
public HttpMethod method() { | ||
return requestOptions.getMethod(); | ||
} | ||
|
||
@Override | ||
public MultiMap headers() { | ||
MultiMap headers = null; | ||
if (httpClientRequest != null) { | ||
headers = httpClientRequest.headers(); | ||
} | ||
if (headers == null) { | ||
headers = requestOptions.getHeaders(); | ||
} | ||
if (headers == null) { | ||
return HeadersMultiMap.headers(); | ||
} | ||
return headers; | ||
} | ||
|
||
@Override | ||
public SocketAddress remoteAddress() { | ||
return requestOptions.getServer(); | ||
} | ||
|
||
public String traceOperation() { | ||
String traceOperation = null; | ||
if (httpClientRequest != null) { | ||
traceOperation = httpClientRequest.traceOperation(); | ||
} | ||
if (traceOperation == null) { | ||
traceOperation = requestOptions.getTraceOperation(); | ||
} | ||
return traceOperation; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...i/src/main/java/io/gravitee/node/api/opentelemetry/http/ObservableHttpClientResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright © 2015 The Gravitee team (http://gravitee.io) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.gravitee.node.api.opentelemetry.http; | ||
|
||
import io.vertx.core.MultiMap; | ||
import io.vertx.core.http.HttpClientResponse; | ||
import io.vertx.core.spi.observability.HttpResponse; | ||
|
||
/** | ||
* @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) | ||
* @author GraviteeSource Team | ||
*/ | ||
public record ObservableHttpClientResponse(HttpClientResponse httpClientResponse) implements ObservableHttpResponse { | ||
@Override | ||
public int statusCode() { | ||
return httpClientResponse.statusCode(); | ||
} | ||
|
||
@Override | ||
public MultiMap headers() { | ||
return httpClientResponse.headers(); | ||
} | ||
} |
14 changes: 7 additions & 7 deletions
14
...vitee/node/tracing/vertx/VertxTracer.java → ...telemetry/http/ObservableHttpRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
/** | ||
* Copyright (C) 2015 The Gravitee team (http://gravitee.io) | ||
/* | ||
* Copyright © 2015 The Gravitee team (http://gravitee.io) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.gravitee.node.tracing.vertx; | ||
package io.gravitee.node.api.opentelemetry.http; | ||
|
||
import io.gravitee.node.api.tracing.Tracer; | ||
import io.vertx.core.spi.observability.HttpRequest; | ||
|
||
/** | ||
* @author David BRASSELY (david.brassely at graviteesource.com) | ||
* @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com) | ||
* @author GraviteeSource Team | ||
*/ | ||
public interface VertxTracer<I, O> extends Tracer, io.vertx.core.spi.tracing.VertxTracer<I, O> {} | ||
public interface ObservableHttpRequest extends HttpRequest {} |
Oops, something went wrong.