-
Notifications
You must be signed in to change notification settings - Fork 327
Drop unsampled transactions when connected to APM Server 8.0+ #2329
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3ef4af0
Drop unsampled transactions when connected to APM Server 8.0+
tobiasstadler 9f20308
Updated changelog
tobiasstadler 162c75a
Merge branch 'master' into fix-2276
tobiasstadler 497b937
Merge remote-tracking branch 'upstream/master' into fix-2276
tobiasstadler fb6e3d1
Merge remote-tracking branch 'upstream/master' into fix-2276
tobiasstadler f82d86e
Merge remote-tracking branch 'upstream/master' into fix-2276
tobiasstadler 933e24c
Merge remote-tracking branch 'upstream/master' into fix-2276
tobiasstadler 9bf3651
Merge branch 'master' into fix-2276
tobiasstadler 4d225c7
Merge branch 'master' into fix-2276
tobiasstadler fd488e6
Review by @felixbarny
tobiasstadler 94ed653
Review by @felixbarny
tobiasstadler 162e387
Try to improve tests
tobiasstadler 8e15859
Merge remote-tracking branch 'origin/master' into fix-2276
felixbarny 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 hidden or 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 hidden or 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 hidden or 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
105 changes: 105 additions & 0 deletions
105
apm-agent-core/src/test/java/co/elastic/apm/agent/impl/DropUnsampledTransactionsTest.java
This file contains hidden or 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,105 @@ | ||
| /* | ||
| * Licensed to Elasticsearch B.V. under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch B.V. 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 co.elastic.apm.agent.impl; | ||
|
|
||
| import co.elastic.apm.agent.AbstractInstrumentationTest; | ||
| import co.elastic.apm.agent.MockReporter; | ||
| import co.elastic.apm.agent.configuration.CoreConfiguration; | ||
| import co.elastic.apm.agent.configuration.SpyConfiguration; | ||
| import co.elastic.apm.agent.impl.metadata.MetaData; | ||
| import co.elastic.apm.agent.objectpool.TestObjectPoolFactory; | ||
| import co.elastic.apm.agent.report.ApmServerClient; | ||
| import org.junit.jupiter.api.AfterAll; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.BeforeAll; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.stagemonitor.configuration.ConfigurationRegistry; | ||
|
|
||
|
|
||
| import java.io.IOException; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.mockito.Mockito.mock; | ||
| import static org.mockito.Mockito.when; | ||
|
|
||
| class DropUnsampledTransactionsTest extends AbstractInstrumentationTest { | ||
|
|
||
| private static ApmServerClient apmServerClient = mock(ApmServerClient.class); | ||
|
|
||
| private static MockReporter reporter = new MockReporter(); | ||
|
|
||
| private static ElasticApmTracer tracer; | ||
|
|
||
| @BeforeAll | ||
| static void startTracer() { | ||
| ConfigurationRegistry configurationRegistry = SpyConfiguration.createSpyConfig(); | ||
| tracer = new ElasticApmTracer(configurationRegistry, reporter, new TestObjectPoolFactory(), apmServerClient, "ephemeralId", MetaData.create(configurationRegistry, "ephemeralId")); | ||
| tracer.start(false); | ||
| } | ||
|
|
||
| @AfterAll | ||
| static void stopTracer() { | ||
| tracer.stop(); | ||
| } | ||
|
|
||
| @AfterEach | ||
| void resetReporter() { | ||
| reporter.reset(); | ||
| } | ||
|
|
||
| @Test | ||
| void whenTheAPMServerSupportsKeepingUnsampledTransactionsUnsampledTransactionsShouldBeReported() throws IOException { | ||
| when(apmServerClient.supportsKeepingUnsampledTransaction()).thenReturn(true); | ||
| tracer.getConfig(CoreConfiguration.class).getSampleRate().update(0.0, SpyConfiguration.CONFIG_SOURCE_NAME); | ||
|
|
||
| tracer.startRootTransaction(null).end(); | ||
|
|
||
| assertThat(reporter.getTransactions().size()).isEqualTo(1); | ||
| } | ||
|
|
||
| @Test | ||
| void whenTheAPMServerSupportsKeepingUnsampledTransactionsSampledTransactionsShouldBeReported() throws IOException { | ||
| when(apmServerClient.supportsKeepingUnsampledTransaction()).thenReturn(true); | ||
| tracer.getConfig(CoreConfiguration.class).getSampleRate().update(1.0, SpyConfiguration.CONFIG_SOURCE_NAME); | ||
|
|
||
| tracer.startRootTransaction(null).end(); | ||
|
|
||
| assertThat(reporter.getTransactions().size()).isEqualTo(1); | ||
| } | ||
|
|
||
| @Test | ||
| void whenTheAPMServerDoesNotSupportsKeepingUnsampledTransactionsUnsampledTransactionsShouldNotBeReported() throws IOException { | ||
| when(apmServerClient.supportsKeepingUnsampledTransaction()).thenReturn(false); | ||
| tracer.getConfig(CoreConfiguration.class).getSampleRate().update(0.0, SpyConfiguration.CONFIG_SOURCE_NAME); | ||
|
|
||
| tracer.startRootTransaction(null).end(); | ||
|
|
||
| assertThat(reporter.getTransactions().size()).isEqualTo(0); | ||
| } | ||
|
|
||
| @Test | ||
| void whenTheAPMServerDoesNotSupportsKeepingUnsampledTransactionsSampledTransactionsShouldBeReported() throws IOException { | ||
| when(apmServerClient.supportsKeepingUnsampledTransaction()).thenReturn(false); | ||
| tracer.getConfig(CoreConfiguration.class).getSampleRate().update(1.0, SpyConfiguration.CONFIG_SOURCE_NAME); | ||
|
|
||
| tracer.startRootTransaction(null).end(); | ||
|
|
||
| assertThat(reporter.getTransactions().size()).isEqualTo(1); | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.