Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/on_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ jobs:
- name: Build and Release
run: mvn -s .ci-settings.xml clean deploy -DskipTests -P release-ossrh -B -U -pl agent,deep --also-make

- name: Get release
id: get_release
uses: bruceadams/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Upload release binary
uses: actions/[email protected]
env:
Expand Down Expand Up @@ -64,6 +70,12 @@ jobs:
- name: Zip Site
run: tar -czf site.tar.gz target/staging

- name: Get release
id: get_release
uses: bruceadams/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}

- uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
Expand Down
4 changes: 4 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .sdkman

This file was deleted.

1 change: 1 addition & 0 deletions .sdkmanrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=13.0.2-open
maven=3.9.6
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 1.2.0 (xx/xx/2023)
- **[CHANGE]**: update: Update deep proto to 1.0.3 [#74](https://github.com/intergral/deep/pull/74) [@Umaaz](https://github.com/Umaaz)
- **[CHANGE]**: plugin: Change the plugins to use SPI to load [#77](https://github.com/intergral/deep/pull/77) [@Umaaz](https://github.com/Umaaz)
- **[FEATURE]**: metrics: Add support for metrics from tracepoints [#74](https://github.com/intergral/deep/pull/74) [@Umaaz](https://github.com/Umaaz)

# 1.1.2 (29/09/2023)
- **[CHANGE]**: version: Override grpc-netty dependencies to remove CVE [#44](https://github.com/intergral/deep/pull/44) [@LMarkie](https://github.com/LMarkie)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package com.intergral.deep.agent.api;

import com.intergral.deep.agent.api.plugin.MetricDefinition;
import com.intergral.deep.agent.api.tracepoint.ITracepoint.ITracepointRegistration;
import java.util.Collection;
import java.util.Map;
Expand Down Expand Up @@ -70,8 +71,9 @@ public interface IDeep {
* @param line the line number
* @param args the key value pairs that further define the tracepoint
* @param watches the list of watch expressions
* @param metrics the list of metric expressions
* @return a {@link ITracepointRegistration} that can be used to remove the tracepoint
*/
ITracepointRegistration registerTracepoint(final String path, final int line, final Map<String, String> args,
final Collection<String> watches);
final Collection<String> watches, final Collection<MetricDefinition> metrics);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright (C) 2023 Intergral GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.intergral.deep.agent.api.plugin;

import java.util.Map;

/**
* This type defines a processor for metrics. This type can be added to plugins to allow metric generated by tracepoints to be attached to
* various metric engines.
*/
public interface IMetricProcessor {

/**
* Process a counter type metric.
*
* @param name the name of the metric
* @param labels the labels attached to the metric
* @param namespace the namespace the metric should be in
* @param help the help statement for the metric
* @param unit the unit for the metric
* @param value the value to post to the metric
*/
void counter(final String name, final Map<String, Object> labels, final String namespace, final String help, final String unit,
final Double value);

/**
* Process a gauge type metric.
*
* @param name the name of the metric
* @param labels the labels attached to the metric
* @param namespace the namespace the metric should be in
* @param help the help statement for the metric
* @param unit the unit for the metric
* @param value the value to post to the metric
*/
void gauge(final String name, final Map<String, Object> labels, final String namespace, final String help, final String unit,
final Double value);

/**
* Process a histogram type metric.
*
* @param name the name of the metric
* @param labels the labels attached to the metric
* @param namespace the namespace the metric should be in
* @param help the help statement for the metric
* @param unit the unit for the metric
* @param value the value to post to the metric
*/
void histogram(final String name, final Map<String, Object> labels, final String namespace, final String help, final String unit,
final Double value);

/**
* Process a summary type metric.
*
* @param name the name of the metric
* @param labels the labels attached to the metric
* @param namespace the namespace the metric should be in
* @param help the help statement for the metric
* @param unit the unit for the metric
* @param value the value to post to the metric
*/
void summary(final String name, final Map<String, Object> labels, final String namespace, final String help, final String unit,
final Double value);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
/*
* Copyright (C) 2023 Intergral GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.intergral.deep.agent.api.plugin;

import java.util.List;
import java.util.Objects;

/**
* This type defines a metric that is attached to a tracepoint.
*/
public class MetricDefinition {

private final String name;
private final List<Label> labels;
private final String type;
private final String expression;
private final String namespace;
private final String help;
private final String unit;

/**
* Create a new MetricDefinition.
*
* @param name the name of the metric
* @param labels the labels attached to the metric
* @param type the type of the metric
* @param expression the expression used to calculate the value for this metric
* @param namespace the namespace the metric should be in
* @param help the help statement for the metric
* @param unit the unit for the metric
*/
public MetricDefinition(
final String name,
final List<Label> labels,
final String type,
final String expression,
final String namespace,
final String help,
final String unit) {

this.name = name;
this.labels = labels;
this.type = type;
this.expression = expression;
this.namespace = namespace;
this.help = help;
this.unit = unit;
}

public String getName() {
return name;
}

public List<Label> getLabels() {
return labels;
}

public String getType() {
return type;
}

public String getExpression() {
return expression;
}

public String getNamespace() {
return namespace;
}

public String getHelp() {
return help;
}

public String getUnit() {
return unit;
}

@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final MetricDefinition that = (MetricDefinition) o;
return Objects.equals(name, that.name) && Objects.equals(labels, that.labels) && Objects.equals(type, that.type)
&& Objects.equals(expression, that.expression) && Objects.equals(namespace, that.namespace)
&& Objects.equals(help, that.help) && Objects.equals(unit, that.unit);
}

@Override
public int hashCode() {
return Objects.hash(name, labels, type, expression, namespace, help, unit);
}

@Override
public String toString() {
return "MetricDefinition{"
+ "name='" + name + '\''
+ ", tags=" + labels
+ ", type='" + type + '\''
+ ", expression='" + expression + '\''
+ ", namespace='" + namespace + '\''
+ ", help='" + help + '\''
+ ", unit='" + unit + '\''
+ '}';
}

/**
* This type is used to represent a label that is attached to a metric.
* <p>
* Labels can have either a static value or an expression. If the value is an expression then this is evaluated as a watcher and the
* result is used as the label value.
*/
public static class Label {

final String key;
final Object value;
final String expression;

/**
* Create a new label for a metric.
*
* @param key the label key
* @param value the label value if a fixed value
* @param expression the label expression if we should evaluate the label value
*/
public Label(final String key, final Object value, final String expression) {
this.key = key;
this.value = value;
this.expression = expression;
}

public String getKey() {
return key;
}

public Object getValue() {
return value;
}

public String getExpression() {
return expression;
}

@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final Label label = (Label) o;
return Objects.equals(key, label.key) && Objects.equals(value, label.value) && Objects.equals(expression,
label.expression);
}

@Override
public int hashCode() {
return Objects.hash(key, value, expression);
}

@Override
public String toString() {
return "Label{"
+ "key='" + key + '\''
+ ", value=" + value
+ ", expression='" + expression + '\''
+ '}';
}
}
}
Loading