-
Notifications
You must be signed in to change notification settings - Fork 93
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
IGNITE-17443 Implement OpenTelemetry metric exporter. #4531
Open
nva
wants to merge
18
commits into
apache:main
Choose a base branch
from
gridgain:ignite-17443
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
29a3f6e
IGNITE-17443 Implement OpenTelemetry metric exporter.
nva f3fe090
IGNITE-17443 Fixed compilation.
nva c5df49c
IGNITE-17443 Fixed checkstyle.
nva ce4fc05
IGNITE-17443 Reverted unexpected changes.
nva 4d76807
IGNITE-17443 Fixed javadoc.
nva 12d7def
IGNITE-17443 Fixed javadoc.
nva 0dc355d
IGNITE-17443 Cleanup.
nva 035cc28
Merge branch 'main' of https://github.com/apache/ignite-3 into ignite…
nva 6aa8c9d
IGNITE-17443 Added test.
nva 9bdae83
IGNITE-17443 Fixed checkstyle.
nva 1c4e73f
IGNITE-17443 Added compression support.
nva fb23330
IGNITE-17443 Fixed pmd check.
nva f0bedf7
Merge branch 'main' of https://github.com/apache/ignite-3 into ignite…
nva feff182
IGNITE-17443 Apply suggestion from review notes.
nva eb90f89
Merge branch 'main' of https://github.com/apache/ignite-3 into ignite…
nva 9a2635f
IGNITE-17443 Apply suggestion from review notes.
nva 55c35f5
Merge branch 'main' of https://github.com/apache/ignite-3 into ignite…
nva 5ee9445
IGNITE-17443 Removed direct dependency on OpenTelemetry.
nva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
apply from: "$rootDir/buildscripts/java-core.gradle" | ||
apply from: "$rootDir/buildscripts/publishing.gradle" | ||
apply from: "$rootDir/buildscripts/java-junit5.gradle" | ||
|
||
dependencies { | ||
annotationProcessor project(':ignite-configuration-annotation-processor') | ||
annotationProcessor libs.auto.service | ||
|
||
implementation project(':ignite-api') | ||
implementation project(':ignite-core') | ||
implementation project(':ignite-configuration') | ||
implementation project(':ignite-configuration-root') | ||
implementation project(':ignite-network') | ||
implementation project(':ignite-metrics') | ||
implementation libs.jetbrains.annotations | ||
implementation libs.auto.service.annotations | ||
implementation(libs.opentelemetry.exporter.otlp) { | ||
// Exclude transitive dependency for exporting logs and traces. | ||
exclude group: 'io.opentelemetry', module: 'opentelemetry-sdk-logs' | ||
exclude group: 'io.opentelemetry', module: 'opentelemetry-sdk-trace' | ||
} | ||
|
||
testAnnotationProcessor project(':ignite-configuration-annotation-processor') | ||
|
||
testImplementation project(':ignite-configuration') | ||
testImplementation testFixtures(project(':ignite-core')) | ||
testImplementation testFixtures(project(':ignite-configuration')) | ||
testImplementation libs.hamcrest.core | ||
testImplementation libs.mockito.core | ||
testImplementation libs.mockito.junit | ||
testImplementation libs.awaitility | ||
} | ||
|
||
description = 'ignite-metrics-exporter-otlp' |
38 changes: 38 additions & 0 deletions
38
...rg/apache/ignite/internal/metrics/exporters/configuration/HeadersConfigurationSchema.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.ignite.internal.metrics.exporters.configuration; | ||
|
||
import org.apache.ignite.configuration.annotation.Config; | ||
import org.apache.ignite.configuration.annotation.InjectedName; | ||
import org.apache.ignite.configuration.annotation.Value; | ||
import org.apache.ignite.configuration.validation.NotBlank; | ||
|
||
/** | ||
* Connection headers configuration schema. | ||
*/ | ||
@Config | ||
public class HeadersConfigurationSchema { | ||
/** Name of the header. */ | ||
@InjectedName | ||
public String name; | ||
|
||
/** Header value. */ | ||
@NotBlank | ||
@Value | ||
public String header; | ||
} |
50 changes: 50 additions & 0 deletions
50
...ache/ignite/internal/metrics/exporters/configuration/OtlpExporterConfigurationModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.ignite.internal.metrics.exporters.configuration; | ||
|
||
import com.google.auto.service.AutoService; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Set; | ||
import org.apache.ignite.configuration.ConfigurationModule; | ||
import org.apache.ignite.configuration.annotation.ConfigurationType; | ||
import org.apache.ignite.configuration.validation.Validator; | ||
import org.apache.ignite.internal.metrics.exporters.validator.EndpointValidatorImpl; | ||
|
||
/** | ||
* {@link ConfigurationModule} for cluster-wide configuration provided by metrics-exporter-otlp. | ||
*/ | ||
@AutoService(ConfigurationModule.class) | ||
public class OtlpExporterConfigurationModule implements ConfigurationModule { | ||
@Override | ||
public ConfigurationType type() { | ||
return ConfigurationType.DISTRIBUTED; | ||
} | ||
|
||
@Override | ||
public Set<Validator<?, ?>> validators() { | ||
return Set.of(EndpointValidatorImpl.INSTANCE); | ||
} | ||
|
||
@Override | ||
public Collection<Class<?>> polymorphicSchemaExtensions() { | ||
return List.of( | ||
OtlpExporterConfigurationSchema.class | ||
); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...ache/ignite/internal/metrics/exporters/configuration/OtlpExporterConfigurationSchema.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.ignite.internal.metrics.exporters.configuration; | ||
|
||
import static io.opentelemetry.exporter.otlp.internal.OtlpConfigUtil.PROTOCOL_GRPC; | ||
import static io.opentelemetry.exporter.otlp.internal.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF; | ||
|
||
import org.apache.ignite.configuration.annotation.ConfigValue; | ||
import org.apache.ignite.configuration.annotation.NamedConfigValue; | ||
import org.apache.ignite.configuration.annotation.PolymorphicConfigInstance; | ||
import org.apache.ignite.configuration.annotation.Value; | ||
import org.apache.ignite.configuration.validation.OneOf; | ||
import org.apache.ignite.internal.metrics.exporters.otlp.OtlpPushMetricExporter; | ||
import org.apache.ignite.internal.metrics.exporters.validator.EndpointValidator; | ||
import org.apache.ignite.internal.network.configuration.SslConfigurationSchema; | ||
import org.apache.ignite.internal.network.configuration.SslConfigurationValidator; | ||
|
||
/** | ||
* Configuration for OTLP push exporter. | ||
*/ | ||
@PolymorphicConfigInstance(OtlpPushMetricExporter.EXPORTER_NAME) | ||
public class OtlpExporterConfigurationSchema extends ExporterConfigurationSchema { | ||
/** Export period, in milliseconds. */ | ||
@Value(hasDefault = true) | ||
public long period = 30_000; | ||
|
||
/** String in "host:port" format. */ | ||
@Value | ||
@EndpointValidator | ||
public String endpoint; | ||
|
||
/** OTLP protocol. */ | ||
@OneOf({PROTOCOL_GRPC, PROTOCOL_HTTP_PROTOBUF}) | ||
@Value(hasDefault = true) | ||
public String protocol = PROTOCOL_GRPC; | ||
|
||
/** Connection headers configuration schema. */ | ||
@NamedConfigValue | ||
public HeadersConfigurationSchema headers; | ||
|
||
/** SSL configuration schema. */ | ||
@ConfigValue | ||
@SslConfigurationValidator | ||
public SslConfigurationSchema ssl; | ||
|
||
/** Method used to compress payloads. */ | ||
@OneOf({"none", "gzip"}) | ||
@Value(hasDefault = true) | ||
public String compression = "gzip"; | ||
} |
150 changes: 150 additions & 0 deletions
150
.../java/org/apache/ignite/internal/metrics/exporters/otlp/IgniteDistributionMetricData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.ignite.internal.metrics.exporters.otlp; | ||
|
||
import static io.opentelemetry.sdk.metrics.data.MetricDataType.HISTOGRAM; | ||
import static java.util.Collections.emptyList; | ||
import static java.util.Collections.singletonList; | ||
|
||
import io.opentelemetry.sdk.common.InstrumentationScopeInfo; | ||
import io.opentelemetry.sdk.internal.PrimitiveLongList; | ||
import io.opentelemetry.sdk.metrics.data.AggregationTemporality; | ||
import io.opentelemetry.sdk.metrics.data.Data; | ||
import io.opentelemetry.sdk.metrics.data.DoubleExemplarData; | ||
import io.opentelemetry.sdk.metrics.data.HistogramData; | ||
import io.opentelemetry.sdk.metrics.data.HistogramPointData; | ||
import io.opentelemetry.sdk.metrics.data.MetricDataType; | ||
import io.opentelemetry.sdk.resources.Resource; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import org.apache.ignite.internal.metrics.DistributionMetric; | ||
|
||
/** | ||
* Metric data that holds distribution metric. | ||
*/ | ||
class IgniteDistributionMetricData extends IgniteMetricData<DistributionMetric> { | ||
private final HistogramData data; | ||
|
||
IgniteDistributionMetricData(Resource resource, InstrumentationScopeInfo scope, DistributionMetric metric) { | ||
super(resource, scope, metric); | ||
|
||
data = new IgniteHistogramData(new IgniteDistributionPointData(metric)); | ||
} | ||
|
||
@Override | ||
public MetricDataType getType() { | ||
return HISTOGRAM; | ||
} | ||
|
||
@Override | ||
public Data<?> getData() { | ||
return data; | ||
} | ||
|
||
static class IgniteHistogramData implements HistogramData { | ||
private final Collection<HistogramPointData> points; | ||
|
||
IgniteHistogramData(HistogramPointData data) { | ||
points = singletonList(data); | ||
} | ||
|
||
@Override | ||
public AggregationTemporality getAggregationTemporality() { | ||
return AggregationTemporality.CUMULATIVE; | ||
} | ||
|
||
@Override | ||
public Collection<HistogramPointData> getPoints() { | ||
return points; | ||
} | ||
} | ||
|
||
static class IgniteDistributionPointData extends IgnitePointData implements HistogramPointData { | ||
private final DistributionMetric metric; | ||
|
||
private final List<Double> boundaries; | ||
|
||
IgniteDistributionPointData(DistributionMetric metric) { | ||
this.metric = metric; | ||
|
||
boundaries = asDoubleList(metric.bounds()); | ||
} | ||
|
||
@Override | ||
public double getSum() { | ||
return Double.NaN; | ||
} | ||
|
||
@Override | ||
public long getCount() { | ||
long totalCount = 0; | ||
|
||
for (long c : metric.value()) { | ||
totalCount += c; | ||
} | ||
|
||
return totalCount; | ||
} | ||
|
||
@Override | ||
public boolean hasMin() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public double getMin() { | ||
return Double.NaN; | ||
} | ||
|
||
@Override | ||
public boolean hasMax() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public double getMax() { | ||
return Double.NaN; | ||
} | ||
|
||
@Override | ||
public List<Double> getBoundaries() { | ||
return boundaries; | ||
} | ||
|
||
@Override | ||
public List<Long> getCounts() { | ||
return PrimitiveLongList.wrap(metric.value()); | ||
} | ||
|
||
@Override | ||
public List<DoubleExemplarData> getExemplars() { | ||
return emptyList(); | ||
} | ||
|
||
private static List<Double> asDoubleList(long[] array) { | ||
ArrayList<Double> result = new ArrayList<>(array.length); | ||
|
||
for (long el : array) { | ||
result.add((double) el); | ||
} | ||
|
||
return result; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you pls add a javadoc with the time unit of this value?