-
Notifications
You must be signed in to change notification settings - Fork 1k
Intercept metrics in test runner #13891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
0956fd7
5b71e52
275b5d5
22a06ce
1630e8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,7 @@ derby.log | |
hs_err_pid* | ||
replay_pid* | ||
.attach_pid* | ||
**/.telemetry* | ||
|
||
!java-agent/benchmark/releases/*.jar | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
plugins { | ||
id("otel.java-conventions") | ||
id("otel.nullaway-conventions") | ||
} | ||
|
||
otelJava { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
|
||
instrumentations=( | ||
"alibaba-druid-1.0:javaagent:test" | ||
) | ||
|
||
# Initialize an empty string to hold the Gradle tasks | ||
gradle_tasks="" | ||
|
||
# Iterate over each instrumentation | ||
for instrumentation in "${instrumentations[@]}"; do | ||
# Extract the parts of the instrumentation | ||
IFS=':' read -r -a parts <<< "$instrumentation" | ||
module="${parts[0]}" | ||
version="${parts[1]}" | ||
type="${parts[2]}" | ||
suffix="${parts[3]}" | ||
|
||
# Assemble the path to the instrumentation | ||
path="instrumentation/$module/$version" | ||
|
||
# Remove any occurrence of /javaagent/ or /library/ from the path | ||
path=$(echo "$path" | sed -e 's/\/javaagent//g' -e 's/\/library//g') | ||
|
||
# Debugging: Print the path being checked | ||
echo "Checking path: $path/.telemetry" | ||
|
||
# Check if the .telemetry directory exists and remove it if it does | ||
if [ -d "$path/.telemetry" ]; then | ||
echo "Removing directory: $path/.telemetry" | ||
rm -rf "$path/.telemetry" | ||
else | ||
echo "Directory does not exist: $path/.telemetry" | ||
fi | ||
|
||
# Append the Gradle task to the gradle_tasks string with a colon between type and suffix if suffix is non-empty | ||
if [ -n "$suffix" ]; then | ||
gradle_tasks+=":instrumentation:$module:$version:$type:$suffix" | ||
else | ||
gradle_tasks+=":instrumentation:$module:$version:$type" | ||
fi | ||
done | ||
|
||
# rerun-tasks is used to force re-running tests that might be cached | ||
echo Running: ./gradlew "$gradle_tasks" -PcollectMetadata=true --rerun-tasks | ||
./gradlew "$gradle_tasks" -PcollectMetadata=true --rerun-tasks | ||
./gradlew :instrumentation-docs:runAnalysis | ||
|
||
# Remove all .telemetry directories recursively from the project root | ||
echo "Searching for and removing all .telemetry directories..." | ||
find . -type d -name ".telemetry" -exec rm -rf {} + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @trask - from your question during the SIG meeting:
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.docs.internal; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
* any time. | ||
*/ | ||
public class EmittedMetrics { | ||
private List<Metric> metrics; | ||
|
||
public EmittedMetrics() { | ||
this.metrics = new ArrayList<>(); | ||
} | ||
|
||
public EmittedMetrics(List<Metric> metrics) { | ||
this.metrics = metrics; | ||
} | ||
|
||
public List<Metric> getMetrics() { | ||
return metrics; | ||
} | ||
|
||
public void setMetrics(List<Metric> metrics) { | ||
this.metrics = metrics; | ||
} | ||
|
||
/** | ||
* This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
* any time. | ||
*/ | ||
public static class Metric { | ||
private String name; | ||
private String description; | ||
private String type; | ||
private String unit; | ||
private List<Attribute> attributes; | ||
|
||
public Metric( | ||
String name, String description, String type, String unit, List<Attribute> attributes) { | ||
this.name = name; | ||
this.description = description; | ||
this.type = type; | ||
this.unit = unit; | ||
this.attributes = attributes; | ||
} | ||
|
||
public Metric() { | ||
this.name = ""; | ||
this.description = ""; | ||
this.type = ""; | ||
this.unit = ""; | ||
this.attributes = new ArrayList<>(); | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
|
||
public String getUnit() { | ||
return unit; | ||
} | ||
|
||
public void setUnit(String unit) { | ||
this.unit = unit; | ||
} | ||
|
||
public List<Attribute> getAttributes() { | ||
return attributes; | ||
} | ||
|
||
public void setAttributes(List<Attribute> attributes) { | ||
this.attributes = attributes; | ||
} | ||
} | ||
|
||
/** | ||
* This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
* any time. | ||
*/ | ||
public static class Attribute { | ||
private String name; | ||
private String type; | ||
|
||
public Attribute() { | ||
this.name = ""; | ||
this.type = ""; | ||
} | ||
|
||
public Attribute(String name, String type) { | ||
this.name = name; | ||
this.type = type; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a directory generated per instrumentation module
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should work
if you only want to ignore it in the root, it would be different: