Skip to content

Commit 3f0b236

Browse files
authored
opentelemetry: add initial support for tracing (#178)
1 parent bfc7c0b commit 3f0b236

File tree

16 files changed

+1394
-0
lines changed

16 files changed

+1394
-0
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
<module>tasks/terraform</module>
5353
<module>tasks/xml</module>
5454
<module>tasks/zoom</module>
55+
<module>runtime/opentelemetry</module>
5556
</modules>
5657

5758
<properties>

runtime/opentelemetry/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# opentelemetry
2+
3+
A plugin for Concord runtime-v2 that adds tracing capabilities using OpenTelemetry.
4+
Process traces are collected after the process finishes and are sent to a configured collector.
5+
6+
## Usage
7+
8+
To use the plugin, add the following dependency to your Concord process:
9+
10+
```yaml
11+
configuration:
12+
dependencies:
13+
- mvn://com.walmartlabs.concord.plugins:opentelemetry:<VERSION>
14+
```
15+
16+
The plugin is configured using `defaultTaskVariables`. For example, using
17+
[project-level configuration](https://concord.walmartlabs.com/docs/getting-started/projects.html#configuration):
18+
19+
```yaml
20+
21+
```json
22+
{
23+
"defaultTaskVariables": {
24+
"opentelemetry": {
25+
"enabled": true,
26+
"endpoint": "http://localhost:4318/v1/traces"
27+
}
28+
}
29+
}
30+
```
31+
32+
The `endpoint` is the address of the OpenTelemetry collector that will receive the traces.
33+
34+
Once the plugin is configured, the traces will be sent to the collector after any process finishes (or fails).

runtime/opentelemetry/pom.xml

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<groupId>com.walmartlabs.concord.plugins</groupId>
8+
<artifactId>concord-plugins-parent</artifactId>
9+
<version>2.6.1-SNAPSHOT</version>
10+
<relativePath>../../pom.xml</relativePath>
11+
</parent>
12+
13+
<artifactId>opentelemetry</artifactId>
14+
<packaging>takari-jar</packaging>
15+
16+
<properties>
17+
<opentelemetry.version>1.43.0</opentelemetry.version>
18+
<opentelemetry.exporter.version>1.14.0</opentelemetry.exporter.version>
19+
</properties>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>com.walmartlabs.concord</groupId>
24+
<artifactId>concord-sdk</artifactId>
25+
<scope>provided</scope>
26+
</dependency>
27+
<dependency>
28+
<groupId>com.walmartlabs.concord.runtime</groupId>
29+
<artifactId>concord-runtime-common</artifactId>
30+
<scope>provided</scope>
31+
</dependency>
32+
<dependency>
33+
<groupId>com.walmartlabs.concord.runtime.v2</groupId>
34+
<artifactId>concord-runtime-sdk-v2</artifactId>
35+
<scope>provided</scope>
36+
</dependency>
37+
<dependency>
38+
<groupId>com.walmartlabs.concord.runtime.v2</groupId>
39+
<artifactId>concord-runner-v2</artifactId>
40+
<scope>provided</scope>
41+
</dependency>
42+
<dependency>
43+
<groupId>com.walmartlabs.concord.runtime.v2</groupId>
44+
<artifactId>concord-runtime-vm-v2</artifactId>
45+
<scope>provided</scope>
46+
</dependency>
47+
<dependency>
48+
<groupId>com.walmartlabs.concord.runtime.v2</groupId>
49+
<artifactId>concord-runtime-model-v2</artifactId>
50+
<scope>provided</scope>
51+
</dependency>
52+
53+
<dependency>
54+
<groupId>org.immutables</groupId>
55+
<artifactId>value</artifactId>
56+
<scope>provided</scope>
57+
</dependency>
58+
<dependency>
59+
<groupId>com.google.code.findbugs</groupId>
60+
<artifactId>jsr305</artifactId>
61+
<scope>provided</scope>
62+
</dependency>
63+
<dependency>
64+
<groupId>com.google.errorprone</groupId>
65+
<artifactId>error_prone_annotations</artifactId>
66+
<scope>provided</scope>
67+
</dependency>
68+
69+
<dependency>
70+
<groupId>org.slf4j</groupId>
71+
<artifactId>slf4j-api</artifactId>
72+
<scope>provided</scope>
73+
</dependency>
74+
75+
<dependency>
76+
<groupId>com.fasterxml.jackson.core</groupId>
77+
<artifactId>jackson-core</artifactId>
78+
<scope>provided</scope>
79+
</dependency>
80+
<dependency>
81+
<groupId>com.fasterxml.jackson.core</groupId>
82+
<artifactId>jackson-annotations</artifactId>
83+
<scope>provided</scope>
84+
</dependency>
85+
<dependency>
86+
<groupId>com.fasterxml.jackson.core</groupId>
87+
<artifactId>jackson-databind</artifactId>
88+
<scope>provided</scope>
89+
</dependency>
90+
<dependency>
91+
<groupId>com.fasterxml.jackson.dataformat</groupId>
92+
<artifactId>jackson-dataformat-yaml</artifactId>
93+
<scope>provided</scope>
94+
</dependency>
95+
96+
<dependency>
97+
<groupId>javax.inject</groupId>
98+
<artifactId>javax.inject</artifactId>
99+
<scope>provided</scope>
100+
</dependency>
101+
<dependency>
102+
<groupId>org.glassfish</groupId>
103+
<artifactId>javax.el</artifactId>
104+
<scope>provided</scope>
105+
</dependency>
106+
<dependency>
107+
<groupId>com.google.inject</groupId>
108+
<artifactId>guice</artifactId>
109+
<scope>provided</scope>
110+
</dependency>
111+
112+
<dependency>
113+
<groupId>io.opentelemetry</groupId>
114+
<artifactId>opentelemetry-api</artifactId>
115+
<version>${opentelemetry.version}</version>
116+
</dependency>
117+
<dependency>
118+
<groupId>io.opentelemetry</groupId>
119+
<artifactId>opentelemetry-sdk</artifactId>
120+
<version>${opentelemetry.version}</version>
121+
</dependency>
122+
<dependency>
123+
<groupId>io.opentelemetry</groupId>
124+
<artifactId>opentelemetry-sdk-common</artifactId>
125+
<version>${opentelemetry.version}</version>
126+
</dependency>
127+
<dependency>
128+
<groupId>io.opentelemetry</groupId>
129+
<artifactId>opentelemetry-sdk-trace</artifactId>
130+
<version>${opentelemetry.version}</version>
131+
</dependency>
132+
<dependency>
133+
<groupId>io.opentelemetry</groupId>
134+
<artifactId>opentelemetry-exporter-otlp-http-trace</artifactId>
135+
<version>${opentelemetry.exporter.version}</version>
136+
<exclusions>
137+
<exclusion>
138+
<groupId>org.jetbrains.kotlin</groupId>
139+
<artifactId>kotlin-stdlib-common</artifactId>
140+
</exclusion>
141+
</exclusions>
142+
</dependency>
143+
144+
<dependency>
145+
<groupId>org.junit.jupiter</groupId>
146+
<artifactId>junit-jupiter-api</artifactId>
147+
<scope>test</scope>
148+
</dependency>
149+
<dependency>
150+
<groupId>org.junit.jupiter</groupId>
151+
<artifactId>junit-jupiter-engine</artifactId>
152+
<scope>test</scope>
153+
</dependency>
154+
</dependencies>
155+
156+
<build>
157+
<plugins>
158+
<plugin>
159+
<groupId>org.eclipse.sisu</groupId>
160+
<artifactId>sisu-maven-plugin</artifactId>
161+
</plugin>
162+
<plugin>
163+
<groupId>org.apache.maven.plugins</groupId>
164+
<artifactId>maven-surefire-plugin</artifactId>
165+
</plugin>
166+
</plugins>
167+
</build>
168+
169+
<repositories>
170+
<repository>
171+
<id>eclipse</id>
172+
<url>https://repo.eclipse.org/content/groups/releases/</url>
173+
</repository>
174+
</repositories>
175+
</project>
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
package com.walmartlabs.concord.plugins.opentelemetry;
2+
3+
/*-
4+
* *****
5+
* Concord
6+
* -----
7+
* Copyright (C) 2017 - 2024 Walmart Inc., Concord Authors
8+
* -----
9+
* Licensed under the Apache License, Version 2.0 (the "License");
10+
* you may not use this file except in compliance with the License.
11+
* You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS,
17+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* See the License for the specific language governing permissions and
19+
* limitations under the License.
20+
* =====
21+
*/
22+
23+
import io.opentelemetry.api.common.AttributeKey;
24+
import io.opentelemetry.api.common.Attributes;
25+
import io.opentelemetry.api.trace.SpanContext;
26+
import io.opentelemetry.sdk.common.InstrumentationLibraryInfo;
27+
import io.opentelemetry.sdk.resources.Resource;
28+
import io.opentelemetry.sdk.trace.ReadableSpan;
29+
import io.opentelemetry.sdk.trace.data.SpanData;
30+
import io.opentelemetry.sdk.trace.data.StatusData;
31+
import org.immutables.value.Value;
32+
33+
import javax.annotation.Nullable;
34+
import java.util.Collections;
35+
36+
@Value.Immutable
37+
@Value.Style(jdkOnly = true)
38+
public abstract class ConcordSpan implements ReadableSpan {
39+
40+
public abstract Resource resource();
41+
42+
public abstract Attributes attributes();
43+
44+
public abstract long startEpochNanos();
45+
public abstract long endEpochNanos();
46+
47+
public abstract StatusData status();
48+
49+
@Override
50+
public SpanData toSpanData() {
51+
return ConcordSpanData.builder()
52+
.name(getName())
53+
.kind(getKind())
54+
.spanContext(getSpanContext())
55+
.parentSpanContext(getParentSpanContext())
56+
.status(status())
57+
.startEpochNanos(startEpochNanos())
58+
.endEpochNanos(endEpochNanos())
59+
.attributes(attributes())
60+
.events(Collections.emptyList())
61+
.links(Collections.emptyList())
62+
.hasEnded(hasEnded())
63+
.totalRecordedEvents(0)
64+
.totalRecordedLinks(0)
65+
.totalAttributeCount(attributes().size())
66+
.resource(resource())
67+
.instrumentationLibraryInfo(getInstrumentationLibraryInfo())
68+
.build();
69+
}
70+
71+
@Override
72+
public InstrumentationLibraryInfo getInstrumentationLibraryInfo() {
73+
return InstrumentationLibraryInfo.empty();
74+
}
75+
76+
@Override
77+
public boolean hasEnded() {
78+
return true;
79+
}
80+
81+
@Override
82+
public long getLatencyNanos() {
83+
return 0;
84+
}
85+
86+
@Override
87+
public <T> T getAttribute(AttributeKey<T> key) {
88+
return attributes() == null ? null : attributes().get(key);
89+
}
90+
91+
@Override
92+
@Nullable
93+
public abstract SpanContext getParentSpanContext();
94+
}

0 commit comments

Comments
 (0)