michaelhyatt / elastic-apm-mule4-agent

APM agent for tracing Mule 4 applications using Elastic APM
18 stars 9 forks source link

config_file system property not working #17

Open fate-cheryl opened 2 years ago

fate-cheryl commented 2 years ago

Hello, I was able to get my Mulesoft project working with system properties but when I am trying to use the elastic.apm.config_file property and reference all the configs in that file, I ran into two issues where it either cannot find the file or it cannot read from the file at all.

For the first issue, I first tried to add the property file in my resource file. In the system property I referenced it as a relative path but it couldn't find it. Then, I put it in the root of the project and it looks like it can find that file because i got a different error that it cannot find the localhost server_url. In my file, I have it referenced to Elastic Cloud server_url.

Do you have a sample project where you got the config_file working? Also, does it need to be called elasticapm.properties? I read in the Elastic documentation that it was expecting that. Secondly, I had my other config files in yaml. Can it point to a yaml file instead of.properties?

Lastly, thank you sooo much for developing this custom agent!!! It has been very useful for my company :)

michaelhyatt commented 2 years ago

Hi @fate-cheryl

Thanks for the compliment, glad the agent is useful.

As for the properties, the examples in this repo use system properties, as per defined here:

https://docs.mulesoft.com/mule-runtime/4.4/configuring-properties#system-properties

Can you try and load the property file using the configuration-properties element in your flow file?

<configuration-properties file="smtp.yaml"/>

The example page above says it should be possible.

If it doesn't work, I'll try to put together an example project for you.

fate-cheryl commented 2 years ago

hi @michaelhyatt, I've definitely tried that:

YAML: yaml1

yaml2

Properties: properties1

properties2

Note that I have these dependencies in my pom:

image

I actually did manage to get this to work by storing the properties file locally on my C: drive and referencing the full path. This was what I read in the elastic documentation:

image

I don't think the config_file system property can be supported in Mulesoft then, correct?

michaelhyatt commented 2 years ago

Had another look at it and indeed the only way to configure the properties with v0.4.0 is to use the Java system properties in the studio through -M-D flag, as described in the README. It seems to be a bug in how the Mule agent initialises the properties looking only at system properties overriding all other settings.

Will look into fixing it.

fate-cheryl commented 2 years ago

Thanks for the confirmation, @michaelhyatt