Skip to content

Commit c76ab35

Browse files
committed
OpenTracing module is implemented
Issue temporalio#258
1 parent ba691a2 commit c76ab35

18 files changed

+1792
-0
lines changed

settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ include 'temporal-sdk'
44
include 'temporal-testing'
55
include 'temporal-testing-junit4'
66
include 'temporal-testing-junit5'
7+
include 'temporal-opentracing'

temporal-opentracing/LICENSE.txt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Temporal Java SDK
2+
3+
Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
4+
5+
Copyright (c) 2017 Uber Technologies, Inc. All Rights Reserved
6+
7+
AWS Simple Workflow Flow Library
8+
Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved
9+
10+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
11+
file except in compliance with the License. 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 distributed under
16+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
17+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations under the License.

temporal-opentracing/build.gradle

+177
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
// Run 'gradle checkUpdates' to find out which dependencies have newer versions
2+
plugins {
3+
id 'java-library'
4+
id 'net.ltgt.errorprone' version '1.3.0'
5+
id 'net.minecrell.licenser' version '0.4.1'
6+
id 'com.palantir.git-version' version '0.12.3'
7+
id 'maven-publish'
8+
id 'signing'
9+
id 'de.marcphilipp.nexus-publish' version '0.4.0'
10+
id 'name.remal.check-updates' version '1.2.2'
11+
}
12+
13+
apply plugin: 'maven-publish'
14+
apply plugin: 'de.marcphilipp.nexus-publish'
15+
apply plugin: 'java'
16+
17+
if (hasProperty('signing.keyId')) {
18+
apply plugin: 'signing'
19+
signing {
20+
sign configurations.archives
21+
}
22+
}
23+
24+
group = 'io.temporal'
25+
version = getVersionName()
26+
archivesBaseName = "temporal-opentracing"
27+
28+
description = '''Temporal Java SDK OpenTracing Support Module'''
29+
30+
java {
31+
sourceCompatibility = JavaVersion.VERSION_1_8
32+
targetCompatibility = JavaVersion.VERSION_1_8
33+
withJavadocJar()
34+
withSourcesJar()
35+
}
36+
37+
ext {
38+
opentracingVersion = '0.33.0'
39+
}
40+
41+
dependencies {
42+
errorproneJavac('com.google.errorprone:javac:9+181-r4173-1')
43+
errorprone('com.google.errorprone:error_prone_core:2.5.1')
44+
45+
api project(':temporal-sdk')
46+
api group: 'io.opentracing', name: 'opentracing-api', version: "$opentracingVersion"
47+
48+
implementation group: 'io.opentracing', name: 'opentracing-util', version: "$opentracingVersion"
49+
50+
testImplementation project(":temporal-testing")
51+
testImplementation project(':temporal-testing-junit4')
52+
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
53+
testImplementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
54+
testImplementation group: 'org.mockito', name: 'mockito-core', version: '3.8.0'
55+
testImplementation group: 'io.opentracing', name: 'opentracing-mock', version: "$opentracingVersion"
56+
}
57+
58+
license {
59+
header rootProject.file('license-header.txt')
60+
exclude '**/*.puml'
61+
}
62+
63+
compileJava {
64+
dependsOn 'googleJavaFormat'
65+
options.encoding = 'UTF-8'
66+
options.compilerArgs << '-Xlint:none' << '-Xlint:deprecation' << '-Werror'
67+
}
68+
69+
compileTestJava {
70+
options.encoding = 'UTF-8'
71+
options.compilerArgs << '-Xlint:none' << '-Xlint:deprecation' << '-Werror'
72+
}
73+
74+
if (JavaVersion.current().isJava8Compatible()) {
75+
allprojects {
76+
tasks.withType(Javadoc) {
77+
options.addStringOption('Xdoclint:none', '-quiet')
78+
}
79+
}
80+
}
81+
82+
javadoc {
83+
options.encoding = 'UTF-8'
84+
if (JavaVersion.current().isJava9Compatible()) {
85+
options.addBooleanOption('html5', true)
86+
}
87+
}
88+
89+
task sourceJar(type: Jar) {
90+
from sourceSets.main.allSource
91+
classifier "sources"
92+
}
93+
94+
test {
95+
dependsOn 'checkLicenseMain'
96+
testLogging {
97+
events 'passed', 'skipped', 'failed'
98+
exceptionFormat 'full'
99+
// Uncomment the following line if you want to see test logs in gradlew run.
100+
showStandardStreams true
101+
}
102+
forkEvery = 1
103+
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
104+
}
105+
106+
publishing {
107+
publications {
108+
mavenJava(MavenPublication) {
109+
from components.java
110+
versionMapping {
111+
usage('java-api') {
112+
fromResolutionOf('runtimeClasspath')
113+
}
114+
usage('java-runtime') {
115+
fromResolutionResult()
116+
}
117+
}
118+
pom {
119+
name = 'Temporal Java SDK OpenTracing Support Module'
120+
packaging = 'jar'
121+
// optionally artifactId can be defined here
122+
description = 'Contains a set of classes that adds OpenTracing support to Temporal'
123+
url = 'https://github.com/temporalio/temporal-java-sdk'
124+
125+
scm {
126+
connection = 'scm:[email protected]:temporalio/temporal-java-sdk.git'
127+
developerConnection = 'scm:[email protected]:temporalio/temporal-java-sdk.git'
128+
url = 'https://github.com/temporalio/temporal-java-sdk.git'
129+
}
130+
131+
licenses {
132+
license {
133+
name = 'The Apache License, Version 2.0'
134+
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
135+
}
136+
}
137+
138+
developers {
139+
developer {
140+
id = 'mfateev'
141+
name = 'Maxim Fateev'
142+
143+
}
144+
developer {
145+
id = 'samarabbas'
146+
name = 'Samar Abbas'
147+
148+
}
149+
}
150+
}
151+
}
152+
153+
}
154+
155+
signing {
156+
sign publishing.publications.mavenJava
157+
}
158+
159+
// Uncomment to test local publishing and comment nexusPublishing
160+
// repositories {
161+
// maven {
162+
// def releasesRepoUrl = "$System.env.HOME/repos/releases"
163+
// def snapshotsRepoUrl = "$System.env.HOME/repos/snapshots"
164+
// url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
165+
// }
166+
// }
167+
168+
}
169+
170+
nexusPublishing {
171+
repositories {
172+
sonatype {
173+
username = project.hasProperty('ossrhUsername') ? project.property('ossrhUsername') : ''
174+
password = project.hasProperty('ossrhPassword') ? project.property('ossrhPassword') : ''
175+
}
176+
}
177+
}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Copyright (C) 2020 Temporal Technologies, Inc. All Rights Reserved.
2+
3+
Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
5+
Modifications copyright (C) 2017 Uber Technologies, Inc.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License"). You may not
8+
use this file except in compliance with the License. A copy of the License is
9+
located at
10+
11+
http://aws.amazon.com/apache2.0
12+
13+
or in the "license" file accompanying this file. This file is distributed on
14+
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
15+
express or implied. See the License for the specific language governing
16+
permissions and limitations under the License.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (C) 2020 Temporal Technologies, Inc. All Rights Reserved.
3+
*
4+
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5+
*
6+
* Modifications copyright (C) 2017 Uber Technologies, Inc.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not
9+
* use this file except in compliance with the License. A copy of the License is
10+
* located at
11+
*
12+
* http://aws.amazon.com/apache2.0
13+
*
14+
* or in the "license" file accompanying this file. This file is distributed on
15+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
16+
* express or implied. See the License for the specific language governing
17+
* permissions and limitations under the License.
18+
*/
19+
20+
package io.temporal.opentracing;
21+
22+
import io.temporal.common.interceptors.WorkflowClientCallsInterceptor;
23+
import io.temporal.common.interceptors.WorkflowClientInterceptorBase;
24+
import io.temporal.opentracing.internal.OpenTracingWorkflowClientCallsInterceptor;
25+
26+
public class OpenTracingClientInterceptor extends WorkflowClientInterceptorBase {
27+
28+
@Override
29+
public WorkflowClientCallsInterceptor workflowClientCallsInterceptor(
30+
WorkflowClientCallsInterceptor next) {
31+
return new OpenTracingWorkflowClientCallsInterceptor(next);
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/*
2+
* Copyright (C) 2020 Temporal Technologies, Inc. All Rights Reserved.
3+
*
4+
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5+
*
6+
* Modifications copyright (C) 2017 Uber Technologies, Inc.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not
9+
* use this file except in compliance with the License. A copy of the License is
10+
* located at
11+
*
12+
* http://aws.amazon.com/apache2.0
13+
*
14+
* or in the "license" file accompanying this file. This file is distributed on
15+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
16+
* express or implied. See the License for the specific language governing
17+
* permissions and limitations under the License.
18+
*/
19+
20+
package io.temporal.opentracing;
21+
22+
public class OpenTracingConfig {
23+
private final String workflowStartOperationNamePrefix;
24+
private final String workflowStartWithSignalOperationNamePrefix;
25+
private final String workflowRunOperationNamePrefix;
26+
private final String childWorkflowStartOperationNamePrefix;
27+
private final String activityStartOperationNamePrefix;
28+
private final String activityRunOperationNamePrefix;
29+
30+
private OpenTracingConfig(
31+
String workflowStartOperationNamePrefix,
32+
String workflowStartWithSignalOperationNamePrefix,
33+
String workflowRunOperationNamePrefix,
34+
String childWorkflowStartOperationNamePrefix,
35+
String activityStartOperationNamePrefix,
36+
String activityRunOperationNamePrefix) {
37+
this.workflowStartOperationNamePrefix = workflowStartOperationNamePrefix;
38+
this.workflowStartWithSignalOperationNamePrefix = workflowStartWithSignalOperationNamePrefix;
39+
this.workflowRunOperationNamePrefix = workflowRunOperationNamePrefix;
40+
this.childWorkflowStartOperationNamePrefix = childWorkflowStartOperationNamePrefix;
41+
this.activityStartOperationNamePrefix = activityStartOperationNamePrefix;
42+
this.activityRunOperationNamePrefix = activityRunOperationNamePrefix;
43+
}
44+
45+
public String getWorkflowStartOperationNamePrefix() {
46+
return workflowStartOperationNamePrefix;
47+
}
48+
49+
public String getWorkflowStartWithSignalOperationNamePrefix() {
50+
return workflowStartWithSignalOperationNamePrefix;
51+
}
52+
53+
public String getWorkflowRunOperationNamePrefix() {
54+
return workflowRunOperationNamePrefix;
55+
}
56+
57+
public String getChildWorkflowStartOperationNamePrefix() {
58+
return childWorkflowStartOperationNamePrefix;
59+
}
60+
61+
public String getActivityStartOperationNamePrefix() {
62+
return activityStartOperationNamePrefix;
63+
}
64+
65+
public String getActivityRunOperationNamePrefix() {
66+
return activityRunOperationNamePrefix;
67+
}
68+
69+
public static Builder newBuilder() {
70+
return new Builder();
71+
}
72+
73+
public static final class Builder {
74+
private String workflowStartOperationNamePrefix = "StartWorkflow";
75+
private String workflowStartWithSignalOperationNamePrefix = "SignalWithStartWorkflow";
76+
private String workflowRunOperationNamePrefix = "RunWorkflow";
77+
private String childWorkflowStartOperationNamePrefix = "StartChildWorkflow";
78+
private String activityStartOperationNamePrefix = "StartActivity";
79+
private String activityRunOperationNamePrefix = "RunActivity";
80+
81+
private Builder() {}
82+
83+
public Builder setWorkflowStartOperationNamePrefix(String workflowStartOperationNamePrefix) {
84+
this.workflowStartOperationNamePrefix = workflowStartOperationNamePrefix;
85+
return this;
86+
}
87+
88+
public Builder setWorkflowStartWithSignalOperationNamePrefix(
89+
String workflowStartWithSignalOperationNamePrefix) {
90+
this.workflowStartWithSignalOperationNamePrefix = workflowStartWithSignalOperationNamePrefix;
91+
return this;
92+
}
93+
94+
public Builder setWorkflowRunOperationNamePrefix(String workflowRunOperationNamePrefix) {
95+
this.workflowRunOperationNamePrefix = workflowRunOperationNamePrefix;
96+
return this;
97+
}
98+
99+
public Builder setChildWorkflowStartOperationNamePrefix(
100+
String childWorkflowStartOperationNamePrefix) {
101+
this.childWorkflowStartOperationNamePrefix = childWorkflowStartOperationNamePrefix;
102+
return this;
103+
}
104+
105+
public Builder setActivityStartOperationNamePrefix(String activityStartOperationNamePrefix) {
106+
this.activityStartOperationNamePrefix = activityStartOperationNamePrefix;
107+
return this;
108+
}
109+
110+
public Builder setActivityRunOperationNamePrefix(String activityRunOperationNamePrefix) {
111+
this.activityRunOperationNamePrefix = activityRunOperationNamePrefix;
112+
return this;
113+
}
114+
115+
public OpenTracingConfig build() {
116+
return new OpenTracingConfig(
117+
workflowStartOperationNamePrefix,
118+
workflowStartWithSignalOperationNamePrefix,
119+
workflowRunOperationNamePrefix,
120+
childWorkflowStartOperationNamePrefix,
121+
activityStartOperationNamePrefix,
122+
activityRunOperationNamePrefix);
123+
}
124+
}
125+
}

0 commit comments

Comments
 (0)