Skip to content

Commit

Permalink
opentelemetry plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
brig committed Oct 16, 2024
1 parent bfc7c0b commit 682fc6b
Show file tree
Hide file tree
Showing 15 changed files with 1,356 additions and 0 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<module>tasks/terraform</module>
<module>tasks/xml</module>
<module>tasks/zoom</module>
<module>tasks/opentelemetry</module>
</modules>

<properties>
Expand Down
171 changes: 171 additions & 0 deletions tasks/opentelemetry/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<?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.39.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>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
</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>
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();
}
Loading

0 comments on commit 682fc6b

Please sign in to comment.