Skip to content

Commit 215d7e6

Browse files
committed
more cleanup
1 parent 77861de commit 215d7e6

File tree

11 files changed

+127
-356
lines changed

11 files changed

+127
-356
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,5 @@ replay_pid*
6060

6161
!java-agent/benchmark/releases/*.jar
6262

63+
**/.telemetry/
64+

instrumentation-docs/readme.md

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ Prior to running the DocGeneratorApplication, run the following command to colle
2323
* Run the doc generator
2424
* `./gradlew :instrumentation-docs:generateDocs`
2525

26+
You can also use an environment variable to set it for the entire suite:
27+
28+
`COLLECT_METADATA=true ./gradlew test`
29+
2630
or use the helper script that will run only the currently supported tests:
2731

2832
```bash

instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/InstrumentationAnalyzer.java

-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import static io.opentelemetry.instrumentation.docs.GradleParser.parseGradleFile;
99

10-
import io.opentelemetry.instrumentation.docs.internal.EmittedScope;
1110
import io.opentelemetry.instrumentation.docs.internal.InstrumentationEntity;
1211
import io.opentelemetry.instrumentation.docs.internal.InstrumentationType;
1312
import io.opentelemetry.instrumentation.docs.utils.FileManager;
@@ -76,14 +75,6 @@ List<InstrumentationEntity> analyze() {
7675
if (metadataFile != null) {
7776
entity.setMetadata(YamlHelper.metaDataParser(metadataFile));
7877
}
79-
80-
String emittedScope = fileSearch.getScope(entity.getSrcPath());
81-
if (emittedScope != null) {
82-
EmittedScope scope = YamlHelper.emittedScopeParser(emittedScope);
83-
if (scope != null && scope.getScope() != null) {
84-
entity.setScope(scope.getScope());
85-
}
86-
}
8778
}
8879
return entities;
8980
}
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,85 @@
1-
/*
2-
* Copyright The OpenTelemetry Authors
3-
* SPDX-License-Identifier: Apache-2.0
4-
*/
5-
6-
package io.opentelemetry.instrumentation.docs.internal;
7-
8-
import io.opentelemetry.api.common.Attributes;
9-
10-
/**
11-
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
12-
* any time.
13-
*/
14-
public class EmittedScope {
15-
private Scope scope;
16-
17-
public EmittedScope() {}
18-
19-
public EmittedScope(Scope scope) {
20-
this.scope = scope;
21-
}
22-
23-
public Scope getScope() {
24-
return scope;
25-
}
26-
27-
public void setScope(Scope scope) {
28-
this.scope = scope;
29-
}
30-
31-
/**
32-
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
33-
* any time.
34-
*/
35-
public static class Scope {
36-
private String name;
37-
private String version;
38-
private String schemaUrl;
39-
private Attributes attributes;
40-
41-
public Scope() {}
42-
43-
public Scope(String name, String version, String schemaUrl, Attributes attributes) {
44-
this.name = name;
45-
this.version = version;
46-
this.schemaUrl = schemaUrl;
47-
this.attributes = attributes;
48-
}
49-
50-
public String getName() {
51-
return name;
52-
}
53-
54-
public void setName(String name) {
55-
this.name = name;
56-
}
57-
58-
public String getVersion() {
59-
return version;
60-
}
61-
62-
public void setVersion(String version) {
63-
this.version = version;
64-
}
65-
66-
public String getSchemaUrl() {
67-
return schemaUrl;
68-
}
69-
70-
public void setSchemaUrl(String schemaUrl) {
71-
this.schemaUrl = schemaUrl;
72-
}
73-
74-
public Attributes getAttributes() {
75-
return attributes;
76-
}
77-
78-
public void setAttributes(Attributes attributes) {
79-
this.attributes = attributes;
80-
}
81-
}
82-
}
1+
///*
2+
// * Copyright The OpenTelemetry Authors
3+
// * SPDX-License-Identifier: Apache-2.0
4+
// */
5+
//
6+
//package io.opentelemetry.instrumentation.docs.internal;
7+
//
8+
//import io.opentelemetry.api.common.Attributes;
9+
//
10+
///**
11+
// * This class is internal and is hence not for public use. Its APIs are unstable and can change at
12+
// * any time.
13+
// */
14+
//public class EmittedScope {
15+
// private Scope scope;
16+
//
17+
// public EmittedScope() {}
18+
//
19+
// public EmittedScope(Scope scope) {
20+
// this.scope = scope;
21+
// }
22+
//
23+
// public Scope getScope() {
24+
// return scope;
25+
// }
26+
//
27+
// public void setScope(Scope scope) {
28+
// this.scope = scope;
29+
// }
30+
//
31+
// /**
32+
// * This class is internal and is hence not for public use. Its APIs are unstable and can change at
33+
// * any time.
34+
// */
35+
// public static class Scope {
36+
// private String name;
37+
// private String version;
38+
// private String schemaUrl;
39+
// private Attributes attributes;
40+
//
41+
// public Scope() {}
42+
//
43+
// public Scope(String name, String version, String schemaUrl, Attributes attributes) {
44+
// this.name = name;
45+
// this.version = version;
46+
// this.schemaUrl = schemaUrl;
47+
// this.attributes = attributes;
48+
// }
49+
//
50+
// public String getName() {
51+
// return name;
52+
// }
53+
//
54+
// public void setName(String name) {
55+
// this.name = name;
56+
// }
57+
//
58+
// public String getVersion() {
59+
// return version;
60+
// }
61+
//
62+
// public void setVersion(String version) {
63+
// this.version = version;
64+
// }
65+
//
66+
// public String getSchemaUrl() {
67+
// if (schemaUrl == null || schemaUrl.equals("null")) {
68+
// return null;
69+
// }
70+
// return schemaUrl;
71+
// }
72+
//
73+
// public void setSchemaUrl(String schemaUrl) {
74+
// this.schemaUrl = schemaUrl;
75+
// }
76+
//
77+
// public Attributes getAttributes() {
78+
// return attributes;
79+
// }
80+
//
81+
// public void setAttributes(Attributes attributes) {
82+
// this.attributes = attributes;
83+
// }
84+
// }
85+
//}

instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/internal/InstrumentationEntity.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package io.opentelemetry.instrumentation.docs.internal;
77

8+
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
89
import java.util.Map;
910
import java.util.Set;
1011

@@ -28,7 +29,7 @@ public void setMetadata(InstrumentationMetaData metadata) {
2829
}
2930

3031
private InstrumentationMetaData metadata;
31-
private EmittedScope.Scope scope;
32+
private InstrumentationScopeInfo scope;
3233

3334
/**
3435
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
@@ -44,7 +45,7 @@ public InstrumentationEntity(Builder builder) {
4445
this.scope = builder.scope;
4546
}
4647

47-
public void setScope(EmittedScope.Scope scope) {
48+
public void setScope(InstrumentationScopeInfo scope) {
4849
this.scope = scope;
4950
}
5051

@@ -72,7 +73,7 @@ public Map<InstrumentationType, Set<String>> getTargetVersions() {
7273
return targetVersions;
7374
}
7475

75-
public EmittedScope.Scope getScope() {
76+
public InstrumentationScopeInfo getScope() {
7677
return scope;
7778
}
7879

@@ -88,7 +89,7 @@ public static class Builder {
8889
private String group;
8990
private InstrumentationMetaData metadata;
9091
private Map<InstrumentationType, Set<String>> targetVersions;
91-
private EmittedScope.Scope scope;
92+
private InstrumentationScopeInfo scope;
9293

9394
public Builder srcPath(String srcPath) {
9495
this.srcPath = srcPath;
@@ -120,7 +121,7 @@ public Builder targetVersions(Map<InstrumentationType, Set<String>> targetVersio
120121
return this;
121122
}
122123

123-
public Builder scope(EmittedScope.Scope scope) {
124+
public Builder scope(InstrumentationScopeInfo scope) {
124125
this.scope = scope;
125126
return this;
126127
}

instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/utils/FileManager.java

-54
Original file line numberDiff line numberDiff line change
@@ -111,60 +111,6 @@ public String getMetaDataFile(String instrumentationDirectory) {
111111
return null;
112112
}
113113

114-
public String getScope(String instrumentationDirectory) {
115-
String scopeYaml = instrumentationDirectory + "/.telemetry/scope.yaml";
116-
if (Files.exists(Paths.get(scopeYaml))) {
117-
return readFileToString(scopeYaml);
118-
}
119-
return null;
120-
}
121-
122-
public String getMetrics(String instrumentationDirectory) {
123-
StringBuilder metricsContent = new StringBuilder();
124-
Path telemetryDir = Paths.get(instrumentationDirectory, ".telemetry");
125-
126-
if (Files.exists(telemetryDir) && Files.isDirectory(telemetryDir)) {
127-
try (Stream<Path> files = Files.list(telemetryDir)) {
128-
files
129-
.filter(path -> path.getFileName().toString().startsWith("metrics-"))
130-
.forEach(
131-
path -> {
132-
String content = readFileToString(path.toString());
133-
if (content != null) {
134-
metricsContent.append(content).append("\n");
135-
}
136-
});
137-
} catch (IOException e) {
138-
logger.severe("Error reading metrics files: " + e.getMessage());
139-
}
140-
}
141-
142-
return metricsContent.toString();
143-
}
144-
145-
public String getSpans(String instrumentationDirectory) {
146-
StringBuilder spansContent = new StringBuilder();
147-
Path telemetryDir = Paths.get(instrumentationDirectory, ".telemetry");
148-
149-
if (Files.exists(telemetryDir) && Files.isDirectory(telemetryDir)) {
150-
try (Stream<Path> files = Files.list(telemetryDir)) {
151-
files
152-
.filter(path -> path.getFileName().toString().startsWith("spans-"))
153-
.forEach(
154-
path -> {
155-
String content = readFileToString(path.toString());
156-
if (content != null) {
157-
spansContent.append(content).append("\n");
158-
}
159-
});
160-
} catch (IOException e) {
161-
logger.severe("Error reading spans files: " + e.getMessage());
162-
}
163-
}
164-
165-
return spansContent.toString();
166-
}
167-
168114
public String readFileToString(String filePath) {
169115
try {
170116
return Files.readString(Paths.get(filePath));

instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/utils/YamlHelper.java

+3-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
package io.opentelemetry.instrumentation.docs.utils;
77

8-
import io.opentelemetry.instrumentation.docs.internal.EmittedScope;
98
import io.opentelemetry.instrumentation.docs.internal.InstrumentationEntity;
109
import io.opentelemetry.instrumentation.docs.internal.InstrumentationMetaData;
1110
import java.io.BufferedWriter;
@@ -74,8 +73,9 @@ public static void printInstrumentationList(
7473
private static Map<String, Object> getScopeMap(InstrumentationEntity entity) {
7574
Map<String, Object> scopeMap = new LinkedHashMap<>();
7675
scopeMap.put("name", entity.getScope().getName());
77-
scopeMap.put("version", entity.getScope().getVersion());
78-
scopeMap.put("schemaUrl", entity.getScope().getSchemaUrl());
76+
if (entity.getScope().getSchemaUrl() != null) {
77+
scopeMap.put("schemaUrl", entity.getScope().getSchemaUrl());
78+
}
7979

8080
if (entity.getScope().getAttributes() != null && !entity.getScope().getAttributes().isEmpty()) {
8181

@@ -93,9 +93,5 @@ public static InstrumentationMetaData metaDataParser(String input) {
9393
return new Yaml().loadAs(input, InstrumentationMetaData.class);
9494
}
9595

96-
public static EmittedScope emittedScopeParser(String input) {
97-
return new Yaml().loadAs(input, EmittedScope.class);
98-
}
99-
10096
private YamlHelper() {}
10197
}

0 commit comments

Comments
 (0)