Class OpenTelemetryCollectorContainer
java.lang.Object
org.testcontainers.containers.FailureDetectingExternalResource
org.testcontainers.containers.GenericContainer<SELF>
org.jboss.as.test.shared.observability.containers.BaseContainer<OpenTelemetryCollectorContainer>
org.jboss.as.test.shared.observability.containers.OpenTelemetryCollectorContainer
- All Implemented Interfaces:
AutoCloseable,org.junit.rules.TestRule,org.testcontainers.containers.Container<OpenTelemetryCollectorContainer>,org.testcontainers.containers.ContainerState,org.testcontainers.containers.traits.LinkableContainer,org.testcontainers.containers.wait.strategy.WaitStrategyTarget,org.testcontainers.lifecycle.Startable
- Author:
- Jason Lee, Radoslav Husar
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.testcontainers.containers.Container
org.testcontainers.containers.Container.ExecResult -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final Stringstatic final Stringstatic final Stringstatic final intstatic final intstatic final intFields inherited from class org.jboss.as.test.shared.observability.containers.BaseContainer
loggingEnabledFields inherited from class org.testcontainers.containers.GenericContainer
CONTAINER_RUNNING_TIMEOUT_SEC, dependencies, dockerClient, INTERNAL_HOST_HOSTNAME, waitStrategyFields inherited from interface org.testcontainers.containers.ContainerState
STATE_HEALTHY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionassertMetrics(Consumer<List<PrometheusMetric>> assertionConsumer) Continually evaluates assertions provided in a consumer until the state obtained from the Prometheus endpoint matches the expected state or until a timeout elapses.assertMetrics(Consumer<List<PrometheusMetric>> assertionConsumer, Duration timeout) Variant ofassertMetrics(Consumer)that can be configured with a timeout duration.assertTraces(String serviceName, Consumer<List<JaegerTrace>> assertionConsumer) Continually evaluates assertions provided in a consumer until the state obtained from the Jaeger endpoint matches the expected state or until a timeout elapses.assertTraces(String serviceName, Consumer<List<JaegerTrace>> assertionConsumer, Duration timeout) Variant ofassertTraces(String, Consumer)that can be configured with a timeout duration.Fetches a current snapshot of the metrics from the Prometheus endpoint.fetchMetrics(String nameToMonitor) Deprecated.getMetricsByName(List<PrometheusMetric> metrics, String key) Given a list ofPrometheusMetricinstances, return a sublist whose key matcheskey.voidstart()voidstop()Methods inherited from class org.jboss.as.test.shared.observability.containers.BaseContainer
debugLog, debugLogMethods inherited from class org.testcontainers.containers.GenericContainer
addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, apply, canBeReused, configure, containerIsCreated, containerIsStarted, containerIsStarted, containerIsStarting, containerIsStarting, containerIsStopped, containerIsStopping, copyFileFromContainer, createVolumeDirectory, dependsOn, dependsOn, dependsOn, doStart, equals, failed, finished, getBinds, getCommandParts, getContainerId, getContainerInfo, getContainerName, getCopyToFileContainerPathMap, getCreateContainerCmdModifiers, getDependencies, getDockerClient, getDockerImageName, getEnv, getEnvMap, getExposedPorts, getExtraHosts, getImage, getIpAddress, getLabels, getLinkedContainers, getLivenessCheckPort, getLivenessCheckPortNumbers, getLivenessCheckPorts, getLogConsumers, getNetwork, getNetworkAliases, getNetworkMode, getPortBindings, getShmSize, getStartupAttempts, getStartupCheckStrategy, getTestHostIpAddress, getTmpFsMapping, getVolumesFroms, getWaitStrategy, getWorkingDirectory, hashCode, isHostAccessible, isPrivilegedMode, isShouldBeReused, logger, setBinds, setCommand, setCommand, setCommandParts, setContainerDef, setCopyToFileContainerPathMap, setDockerImageName, setEnv, setExposedPorts, setExtraHosts, setHostAccessible, setImage, setLabels, setLinkedContainers, setLogConsumers, setNetwork, setNetworkAliases, setNetworkMode, setPortBindings, setPrivilegedMode, setShmSize, setStartupAttempts, setStartupCheckStrategy, setTmpFsMapping, setVolumesFroms, setWaitStrategy, setWorkingDirectory, starting, succeeded, toString, waitingFor, waitUntilContainerStarted, withAccessToHost, withClasspathResourceMapping, withClasspathResourceMapping, withCommand, withCommand, withCopyFileToContainer, withCopyToContainer, withCreateContainerCmdModifier, withEnv, withEnv, withExposedPorts, withExtraHost, withFileSystemBind, withImagePullPolicy, withLabel, withLabels, withLogConsumer, withMinimumRunningDuration, withNetwork, withNetworkAliases, withNetworkMode, withPrivilegedMode, withReuse, withSharedMemorySize, withStartupAttempts, withStartupCheckStrategy, withStartupTimeout, withTmpFs, withVolumesFrom, withWorkingDirectoryMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.testcontainers.containers.Container
addFileSystemBind, followOutput, followOutput, self, withEnv, withFileSystemBindMethods inherited from interface org.testcontainers.containers.ContainerState
copyFileFromContainer, copyFileToContainer, copyFileToContainer, execInContainer, execInContainer, execInContainer, execInContainer, execInContainerWithUser, execInContainerWithUser, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunningMethods inherited from interface org.testcontainers.lifecycle.Startable
close
-
Field Details
-
IMAGE_NAME
- See Also:
-
IMAGE_VERSION
- See Also:
-
OTLP_GRPC_PORT
public static final int OTLP_GRPC_PORT- See Also:
-
OTLP_HTTP_PORT
public static final int OTLP_HTTP_PORT- See Also:
-
PROMETHEUS_PORT
public static final int PROMETHEUS_PORT- See Also:
-
HEALTH_CHECK_PORT
public static final int HEALTH_CHECK_PORT- See Also:
-
OTEL_COLLECTOR_CONFIG_YAML
- See Also:
-
-
Constructor Details
-
OpenTelemetryCollectorContainer
public OpenTelemetryCollectorContainer()
-
-
Method Details
-
start
public void start()- Specified by:
startin interfaceorg.testcontainers.lifecycle.Startable- Overrides:
startin classorg.testcontainers.containers.GenericContainer<OpenTelemetryCollectorContainer>
-
stop
public void stop()- Specified by:
stopin interfaceorg.testcontainers.lifecycle.Startable- Overrides:
stopin classorg.testcontainers.containers.GenericContainer<OpenTelemetryCollectorContainer>
-
getOtlpGrpcEndpoint
-
getOtlpHttpEndpoint
-
getPrometheusUrl
-
getTraces
- Throws:
InterruptedException
-
getMetricsByName
Given a list ofPrometheusMetricinstances, return a sublist whose key matcheskey. Note that the key name must match the Prometheus conventions (see here for details.- Parameters:
metrics- List of PrometheusMetrics to filter.key- The name of the metric to find- Returns:
- a sublist of
metricsthat matcheskey
-
assertTraces
public List<JaegerTrace> assertTraces(String serviceName, Consumer<List<JaegerTrace>> assertionConsumer) throws InterruptedException Continually evaluates assertions provided in a consumer until the state obtained from the Jaeger endpoint matches the expected state or until a timeout elapses. By default, polls the collector every second for 30 seconds. Returns snapshot of the Jaeger traces that passed the assertions; typically ignored.- Parameters:
assertionConsumer- consumer implementation that containsAssertions throwingAssertionError()s if the state obtained from the Jaeger endpoint does not match the expected state- Returns:
- list of Jaeger traces; typically ignored.
- Throws:
AssertionError- lastAssertionErrorthrown by the providedassertionConsumerbefore timeout elapsedInterruptedException- if interrupted
-
assertTraces
public List<JaegerTrace> assertTraces(String serviceName, Consumer<List<JaegerTrace>> assertionConsumer, Duration timeout) throws InterruptedException Variant ofassertTraces(String, Consumer)that can be configured with a timeout duration.- Throws:
InterruptedException
-
assertMetrics
public List<PrometheusMetric> assertMetrics(Consumer<List<PrometheusMetric>> assertionConsumer) throws AssertionError, InterruptedException Continually evaluates assertions provided in a consumer until the state obtained from the Prometheus endpoint matches the expected state or until a timeout elapses. By default, polls the collector every second for 30 seconds. Typicallyotel.metric.export.intervalmust be adjusted to lower values since the default is attempting to push every 60 seconds, which is well above the default timeout of this method. Returns snapshot of the prometheus registry that passed the assertions; typically ignored.- Parameters:
assertionConsumer- consumer implementation that containsAssertions throwingAssertionError()s if the state obtained from the Prometheus endpoint does not match the expected state- Returns:
- list of prometheus metrics; typically ignored.
- Throws:
AssertionError- lastAssertionErrorthrown by the providedassertionConsumerbefore timeout elapsedInterruptedException- if interrupted
-
assertMetrics
public List<PrometheusMetric> assertMetrics(Consumer<List<PrometheusMetric>> assertionConsumer, Duration timeout) throws AssertionError, InterruptedException Variant ofassertMetrics(Consumer)that can be configured with a timeout duration.- Throws:
AssertionErrorInterruptedException
-
fetchMetrics
Fetches a current snapshot of the metrics from the Prometheus endpoint.- Returns:
- list of prometheus metrics
-
fetchMetrics
@Deprecated public List<PrometheusMetric> fetchMetrics(String nameToMonitor) throws InterruptedException Deprecated.UseassertMetrics(Consumer)instead.- Throws:
InterruptedException
-
assertMetrics(Consumer)instead.