Skip to content

Fix attach external config#1469

Merged
SylvainJuge merged 9 commits intoelastic:masterfrom
SylvainJuge:fix-attach-external-config
Nov 3, 2020
Merged

Fix attach external config#1469
SylvainJuge merged 9 commits intoelastic:masterfrom
SylvainJuge:fix-attach-external-config

Conversation

@SylvainJuge
Copy link
Member

@SylvainJuge SylvainJuge commented Nov 2, 2020

What does this PR do?

When using remote attach, if there is any external configuration provided through config_file option, this external configuration file is ignored.

The expected behavior here should be to:

  • load the external configuration first
  • allow to override configuration items from the external configuration file with entries in the --config provided through CLI.

Checklist

  • This is a bugfix
Copy link
Member

@felixbarny felixbarny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a minor suggestion, otherwise LGTM


private static void loadExternalProperties(Properties properties, String externalProperties) {
FileInputStream stream = null;
try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use try-with-resources

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I always forget that one !

@ghost
Copy link

ghost commented Nov 2, 2020

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #1469 updated]

  • Start Time: 2020-11-03T08:44:47.639+0000

  • Duration: 46 min 36 sec

Test stats 🧪

Test Results
Failed 0
Passed 1617
Skipped 12
Total 1629

@SylvainJuge
Copy link
Member Author

I have updated documentation for the most common case (remote attach with CLI), but in practice it will also make it possible to use elasticapm.properties either in classpath or next to agent jar to include a config_file entry, in which case we might not properly define/enforce ordering and priority.

I think it's unlikely enough that we can wait until it becomes an issue before dealing with that.

@codecov-io
Copy link

Codecov Report

Merging #1469 into master will increase coverage by 3.74%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1469      +/-   ##
============================================
+ Coverage     59.73%   63.48%   +3.74%     
- Complexity       91     3297    +3206     
============================================
  Files           391      344      -47     
  Lines         17528    16055    -1473     
  Branches       2408     2196     -212     
============================================
- Hits          10470    10192     -278     
+ Misses         6340     5173    -1167     
+ Partials        718      690      -28     
Impacted Files Coverage Δ Complexity Δ
...acing/impl/ExternalSpanContextInstrumentation.java
...t/kafka/helper/KafkaInstrumentationHelperImpl.java
...ent/kafka/KafkaProducerHeadersInstrumentation.java
...afka/ConsumerRecordsRecordListInstrumentation.java
...ic/apm/opentracing/ExternalProcessSpanContext.java
...agent/opentracing/impl/ApmSpanInstrumentation.java
...agent/kafka/helper/ConsumerRecordsListWrapper.java
...t/opentracing/impl/SpanContextInstrumentation.java
...astic/apm/opentracing/TraceContextSpanContext.java
...ent/opentracing/impl/OpenTracingTextMapBridge.java
... and 38 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 640696b...2afadfd. Read the comment docs.

@SylvainJuge
Copy link
Member Author

I've just realized that the initial implemented ordering wasn't consistent with what was documented, thus I've made config_file option have higher priority than configuration provided through runtime attach parameters.

@SylvainJuge SylvainJuge merged commit 7ff6adf into elastic:master Nov 3, 2020
@SylvainJuge SylvainJuge deleted the fix-attach-external-config branch November 3, 2020 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants