-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Metering API Implementation #99723
Metering API Implementation #99723
Changes from 11 commits
a47afbc
d73297c
92edce8
65bfb4d
3422c75
bd3b9b3
cfdf63c
227df6e
2057be4
8b90b04
a1674dc
aeed9b4
4bda06b
4f2d8c3
2dbac8c
d2f2c59
7b3f3b6
74dffd4
ad70756
4fd5978
15fd6d1
1dcb599
6f3f458
7c3c13a
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 |
---|---|---|
|
@@ -50,10 +50,12 @@ class APMJvmOptions { | |
// by the agent. Don't disable writing to a log file, as the agent will then | ||
// require extra Security Manager permissions when it tries to do something | ||
// else, and it's just painful. | ||
"log_file", "_AGENT_HOME_/../../logs/apm.log", | ||
|
||
"log_file", "/Users/przemyslawgomulka/workspace/pgomulka/apm.log", | ||
"log_level", "debug", | ||
// ES does not use auto-instrumentation. | ||
"instrument", "false" | ||
"instrument", "false", | ||
"experimental", "true", | ||
"enable_experimental_instrumentations", "true" | ||
); | ||
|
||
/** | ||
|
@@ -82,7 +84,7 @@ class APMJvmOptions { | |
// is doing, leave this value alone. | ||
"log_level", "error", | ||
"application_packages", "org.elasticsearch,org.apache.lucene", | ||
"metrics_interval", "120s", | ||
"metrics_interval", "5s", | ||
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. 5 seconds seems pretty aggressive. Do we really need metric resolution at that granularity? |
||
"breakdown_metrics", "false", | ||
"central_config", "false" | ||
); | ||
|
@@ -316,9 +318,7 @@ static Path findAgentJar(String installDir) throws IOException, UserException { | |
} | ||
|
||
try (var apmStream = Files.list(apmModule)) { | ||
final List<Path> paths = apmStream.filter( | ||
path -> path.getFileName().toString().matches("elastic-apm-agent-\\d+\\.\\d+\\.\\d+\\.jar") | ||
).toList(); | ||
final List<Path> paths = apmStream.filter(path -> path.getFileName().toString().matches("elastic-apm-agent-.*.jar")).toList(); | ||
|
||
if (paths.size() > 1) { | ||
throw new UserException( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,11 +14,17 @@ esplugin { | |
|
||
def otelVersion = '1.17.0' | ||
|
||
repositories { | ||
maven { | ||
name "sonatype-nexus-snapshots" | ||
url "https://oss.sonatype.org/content/repositories/snapshots" | ||
} | ||
} | ||
dependencies { | ||
implementation "io.opentelemetry:opentelemetry-api:${otelVersion}" | ||
implementation "io.opentelemetry:opentelemetry-context:${otelVersion}" | ||
implementation "io.opentelemetry:opentelemetry-semconv:${otelVersion}-alpha" | ||
runtimeOnly "co.elastic.apm:elastic-apm-agent:1.36.0" | ||
implementation "co.elastic.apm:elastic-apm-agent:1.42.1-SNAPSHOT" | ||
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. We should not commit a snapshot dependency, we'll need to wait until this is released. 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. Sounds good. |
||
} | ||
|
||
tasks.named("dependencyLicenses").configure { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,12 +21,12 @@ | |
import org.elasticsearch.indices.IndicesService; | ||
import org.elasticsearch.plugins.NetworkPlugin; | ||
import org.elasticsearch.plugins.Plugin; | ||
import org.elasticsearch.plugins.TracerPlugin; | ||
import org.elasticsearch.plugins.TelemetryPlugin; | ||
import org.elasticsearch.repositories.RepositoriesService; | ||
import org.elasticsearch.script.ScriptService; | ||
import org.elasticsearch.telemetry.TelemetryProvider; | ||
import org.elasticsearch.telemetry.apm.settings.APMAgentSettings; | ||
import org.elasticsearch.telemetry.apm.tracing.APMTracer; | ||
import org.elasticsearch.telemetry.tracing.Tracer; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.watcher.ResourceWatcherService; | ||
import org.elasticsearch.xcontent.NamedXContentRegistry; | ||
|
@@ -55,19 +55,19 @@ | |
* be passed via system properties to the Java agent, which periodically checks for changes | ||
* and applies the new settings values, provided those settings can be dynamically updated. | ||
*/ | ||
public class APM extends Plugin implements NetworkPlugin, TracerPlugin { | ||
private final SetOnce<APMTracer> tracer = new SetOnce<>(); | ||
public class APM extends Plugin implements NetworkPlugin, TelemetryPlugin { | ||
private final SetOnce<APMTelemetryProvider> telemetryProvider = new SetOnce<>(); | ||
private final Settings settings; | ||
|
||
public APM(Settings settings) { | ||
this.settings = settings; | ||
} | ||
|
||
@Override | ||
public Tracer getTracer(Settings settings) { | ||
final APMTracer apmTracer = new APMTracer(settings); | ||
tracer.set(apmTracer); | ||
return apmTracer; | ||
public TelemetryProvider getTelemetryProvider(Settings settings) { | ||
final APMTelemetryProvider apmTelemetryProvider = new APMTelemetryProvider(settings); | ||
telemetryProvider.set(apmTelemetryProvider); | ||
return apmTelemetryProvider; | ||
} | ||
|
||
@Override | ||
|
@@ -83,20 +83,22 @@ public Collection<Object> createComponents( | |
NamedWriteableRegistry namedWriteableRegistry, | ||
IndexNameExpressionResolver indexNameExpressionResolver, | ||
Supplier<RepositoriesService> repositoriesServiceSupplier, | ||
Tracer unused, | ||
TelemetryProvider unused, | ||
AllocationService allocationService, | ||
IndicesService indicesService | ||
) { | ||
final APMTracer apmTracer = tracer.get(); | ||
final APMTracer apmTracer = telemetryProvider.get().getTracer(); | ||
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. Why is the provider captured, when it is already passed in? It should be the exact same, so we could avoid the SetOnce? |
||
|
||
apmTracer.setClusterName(clusterService.getClusterName().value()); | ||
apmTracer.setNodeName(clusterService.getNodeName()); | ||
|
||
final APMAgentSettings apmAgentSettings = new APMAgentSettings(); | ||
apmAgentSettings.syncAgentSystemProperties(settings); | ||
apmAgentSettings.addClusterSettingsListeners(clusterService, apmTracer); | ||
apmAgentSettings.addClusterSettingsListeners(clusterService, telemetryProvider.get()); | ||
|
||
return List.of(apmTracer); | ||
final APMMetric apmMetric = telemetryProvider.get().getMetric(); | ||
|
||
return List.of(apmTracer, apmMetric); | ||
} | ||
|
||
@Override | ||
|
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.
The log file and level need to be reset back to their original levels.