-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
opentelemetry: add initial support for tracing (#178)
- Loading branch information
Showing
16 changed files
with
1,394 additions
and
0 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
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,34 @@ | ||
# opentelemetry | ||
|
||
A plugin for Concord runtime-v2 that adds tracing capabilities using OpenTelemetry. | ||
Process traces are collected after the process finishes and are sent to a configured collector. | ||
|
||
## Usage | ||
|
||
To use the plugin, add the following dependency to your Concord process: | ||
|
||
```yaml | ||
configuration: | ||
dependencies: | ||
- mvn://com.walmartlabs.concord.plugins:opentelemetry:<VERSION> | ||
``` | ||
The plugin is configured using `defaultTaskVariables`. For example, using | ||
[project-level configuration](https://concord.walmartlabs.com/docs/getting-started/projects.html#configuration): | ||
|
||
```yaml | ||
```json | ||
{ | ||
"defaultTaskVariables": { | ||
"opentelemetry": { | ||
"enabled": true, | ||
"endpoint": "http://localhost:4318/v1/traces" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
The `endpoint` is the address of the OpenTelemetry collector that will receive the traces. | ||
|
||
Once the plugin is configured, the traces will be sent to the collector after any process finishes (or fails). |
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,175 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.walmartlabs.concord.plugins</groupId> | ||
<artifactId>concord-plugins-parent</artifactId> | ||
<version>2.6.1-SNAPSHOT</version> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>opentelemetry</artifactId> | ||
<packaging>takari-jar</packaging> | ||
|
||
<properties> | ||
<opentelemetry.version>1.43.0</opentelemetry.version> | ||
<opentelemetry.exporter.version>1.14.0</opentelemetry.exporter.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.walmartlabs.concord</groupId> | ||
<artifactId>concord-sdk</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.walmartlabs.concord.runtime</groupId> | ||
<artifactId>concord-runtime-common</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.walmartlabs.concord.runtime.v2</groupId> | ||
<artifactId>concord-runtime-sdk-v2</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.walmartlabs.concord.runtime.v2</groupId> | ||
<artifactId>concord-runner-v2</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.walmartlabs.concord.runtime.v2</groupId> | ||
<artifactId>concord-runtime-vm-v2</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.walmartlabs.concord.runtime.v2</groupId> | ||
<artifactId>concord-runtime-model-v2</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.immutables</groupId> | ||
<artifactId>value</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.code.findbugs</groupId> | ||
<artifactId>jsr305</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.errorprone</groupId> | ||
<artifactId>error_prone_annotations</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-core</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-annotations</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.dataformat</groupId> | ||
<artifactId>jackson-dataformat-yaml</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>javax.inject</groupId> | ||
<artifactId>javax.inject</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.glassfish</groupId> | ||
<artifactId>javax.el</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.inject</groupId> | ||
<artifactId>guice</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-api</artifactId> | ||
<version>${opentelemetry.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-sdk</artifactId> | ||
<version>${opentelemetry.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-sdk-common</artifactId> | ||
<version>${opentelemetry.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-sdk-trace</artifactId> | ||
<version>${opentelemetry.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-exporter-otlp-http-trace</artifactId> | ||
<version>${opentelemetry.exporter.version}</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-stdlib-common</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.eclipse.sisu</groupId> | ||
<artifactId>sisu-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<repositories> | ||
<repository> | ||
<id>eclipse</id> | ||
<url>https://repo.eclipse.org/content/groups/releases/</url> | ||
</repository> | ||
</repositories> | ||
</project> |
94 changes: 94 additions & 0 deletions
94
...pentelemetry/src/main/java/com/walmartlabs/concord/plugins/opentelemetry/ConcordSpan.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,94 @@ | ||
package com.walmartlabs.concord.plugins.opentelemetry; | ||
|
||
/*- | ||
* ***** | ||
* Concord | ||
* ----- | ||
* Copyright (C) 2017 - 2024 Walmart Inc., Concord Authors | ||
* ----- | ||
* 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. | ||
* ===== | ||
*/ | ||
|
||
import io.opentelemetry.api.common.AttributeKey; | ||
import io.opentelemetry.api.common.Attributes; | ||
import io.opentelemetry.api.trace.SpanContext; | ||
import io.opentelemetry.sdk.common.InstrumentationLibraryInfo; | ||
import io.opentelemetry.sdk.resources.Resource; | ||
import io.opentelemetry.sdk.trace.ReadableSpan; | ||
import io.opentelemetry.sdk.trace.data.SpanData; | ||
import io.opentelemetry.sdk.trace.data.StatusData; | ||
import org.immutables.value.Value; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.Collections; | ||
|
||
@Value.Immutable | ||
@Value.Style(jdkOnly = true) | ||
public abstract class ConcordSpan implements ReadableSpan { | ||
|
||
public abstract Resource resource(); | ||
|
||
public abstract Attributes attributes(); | ||
|
||
public abstract long startEpochNanos(); | ||
public abstract long endEpochNanos(); | ||
|
||
public abstract StatusData status(); | ||
|
||
@Override | ||
public SpanData toSpanData() { | ||
return ConcordSpanData.builder() | ||
.name(getName()) | ||
.kind(getKind()) | ||
.spanContext(getSpanContext()) | ||
.parentSpanContext(getParentSpanContext()) | ||
.status(status()) | ||
.startEpochNanos(startEpochNanos()) | ||
.endEpochNanos(endEpochNanos()) | ||
.attributes(attributes()) | ||
.events(Collections.emptyList()) | ||
.links(Collections.emptyList()) | ||
.hasEnded(hasEnded()) | ||
.totalRecordedEvents(0) | ||
.totalRecordedLinks(0) | ||
.totalAttributeCount(attributes().size()) | ||
.resource(resource()) | ||
.instrumentationLibraryInfo(getInstrumentationLibraryInfo()) | ||
.build(); | ||
} | ||
|
||
@Override | ||
public InstrumentationLibraryInfo getInstrumentationLibraryInfo() { | ||
return InstrumentationLibraryInfo.empty(); | ||
} | ||
|
||
@Override | ||
public boolean hasEnded() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public long getLatencyNanos() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public <T> T getAttribute(AttributeKey<T> key) { | ||
return attributes() == null ? null : attributes().get(key); | ||
} | ||
|
||
@Override | ||
@Nullable | ||
public abstract SpanContext getParentSpanContext(); | ||
} |
Oops, something went wrong.