avioconsulting/mule-opentelemetry-module

Having some issues building - maybe XSD related

StephenGoodall opened this issue · 5 comments

Hi,
Thanks for your work on this - it looks like it should be a great tool to use!

I've tried adding some of the Open Telemetry config to my mule config file but it is failing the build. It is complaining about:
Invalid content was found starting with element '{"http://www.mulesoft.org/schema/mule/opentelemetry":resource-attributes}'. One of '{"http://www.mulesoft.org/schema/mule/opentelemetry":ignore-mule-components}' is expected.

Could this be because the XSD in the file is giving a 404? I used the following, based on your example (https://github.com/avioconsulting/mule-opentelemetry-module/blob/main/examples/mule-opentelemetry-app-1/src/main/mule/mule-opentelemetry-app-1.xml):

xmlns:opentelemetry="http://www.mulesoft.org/schema/mule/opentelemetry"

http://www.mulesoft.org/schema/mule/opentelemetry http://www.mulesoft.org/schema/mule/opentelemetry/current/mule-opentelemetry.xsd

I'm not particularly familiar with Mulesoft config files to be honest, so I might be looking at the wrong thing here, but does the below look OK?
If it has any effect, I have most of those values defined in a separate properties files, and the env value is declared as a global property in this file.
The otlp_traces_enabled value is "otlp" for production and "none" for nn-production so it should only send traces from production.....or at least that was my theory here. The header is due to me trying to set this up to send the traces to Dynatrace.

	<opentelemetry:config name="OpenTelemetry_Config" doc:name="OpenTelemetry Config" doc:id="91477cb5-36f7-48ad-90b7-c339af87b408" serviceName="SERVICE_NAME">
		<opentelemetry:exporter >
			<opentelemetry:otlp-exporter collectorEndpoint="${otlp_trace_endpoint}" protocol="HTTP_PROTOBUF" >
 				<opentelemetry:headers >
					<opentelemetry:header key="Authorization" value="Api-Token ${otlp_trace_token}" />
				</opentelemetry:headers>
				<opentelemetry:config-properties >
					<opentelemetry:config-property key="otel.traces.exporter" value="${otlp_traces_enabled}" />
				</opentelemetry:config-properties>
			</opentelemetry:otlp-exporter>
		</opentelemetry:exporter>
		<opentelemetry:resource-attributes >
			<opentelemetry:attribute key="mule.env" value="${env}" />
		</opentelemetry:resource-attributes>
	</opentelemetry:config>
</mule>

Am I doing anything obviously wrong here?

Thanks!

Thanks for reaching out @StephenGoodall and sharing your thoughts. XSD declaration looks fine.

Could you try switching the sequence of exporter and resource-attributes?

<opentelemetry:config name="OpenTelemetry_Config" doc:name="OpenTelemetry Config" doc:id="91477cb5-36f7-48ad-90b7-c339af87b408" serviceName="SERVICE_NAME">
		<opentelemetry:resource-attributes >
			<opentelemetry:attribute key="mule.env" value="${env}" />
		</opentelemetry:resource-attributes>
		<opentelemetry:exporter >
			<opentelemetry:otlp-exporter collectorEndpoint="${otlp_trace_endpoint}" protocol="HTTP_PROTOBUF" >
 				<opentelemetry:headers >
					<opentelemetry:header key="Authorization" value="Api-Token ${otlp_trace_token}" />
				</opentelemetry:headers>
				<opentelemetry:config-properties >
					<opentelemetry:config-property key="otel.traces.exporter" value="${otlp_traces_enabled}" />
				</opentelemetry:config-properties>
			</opentelemetry:otlp-exporter>
		</opentelemetry:exporter>
	</opentelemetry:config>

I know it doesn't make sense but see if that helps.

hey @manikmagar thanks for the quick reply!
I tried that and it didn't seem to make a difference, is there a specific mule-maven version I should be using? Currently it's using 3.8.0:

[Step 1/5] Failed to execute goal org.mule.tools.maven:mule-maven-plugin:3.8.0:process-classes (default-process-classes) on project *************: Execution default-process-classes of goal org.mule.tools.maven:mule-maven-plugin:3.8.0:process-classes failed: There was '1' error while parsing the given file '00.config/001.global_config.xml'.
Full list:
org.xml.sax.SAXParseException; lineNumber: 121; columnNumber: 42; cvc-complex-type.2.4.a: Invalid content was found starting with element '{"http://www.mulesoft.org/schema/mule/opentelemetry":resource-attributes}'. One of '{"http://www.mulesoft.org/schema/mule/opentelemetry":abstract-open-telemetry-exporter, "http://www.mulesoft.org/schema/mule/opentelemetry":global-abstract-open-telemetry-exporter}' is expected.

Sorry, probably should have just put that whole message in the first post.

Is the XSD definitely not an issue if the URL is getting a 404?

I commented out the resource-attribute elements:

                <!--
                <opentelemetry:resource-attributes >
			<opentelemetry:attribute key="mule.env" value="${env}" />
		</opentelemetry:resource-attributes>
                -->

And the build was able to complete - how essential is it to include the attributes? 🤔

I think the re-ordering did work - I just didn't pay enough attention and accidentally put the resource-attribute inside the <opentelemetry:exporter > element 🤦‍♂️

I put in the following and it built successfully - thanks again for your help!

<opentelemetry:config name="OpenTelemetry_Config" doc:name="OpenTelemetry Config" doc:id="91477cb5-36f7-48ad-90b7-c339af87b408" serviceName="SERVICE_NAME">
		<opentelemetry:resource-attributes>
		    <opentelemetry:attribute key="mule.env" value="${env}" />
		</opentelemetry:resource-attributes>
		<opentelemetry:exporter >
		    <opentelemetry:otlp-exporter collectorEndpoint="${otlp_trace_endpoint}" protocol="HTTP_PROTOBUF" >
 				<opentelemetry:headers >
					<opentelemetry:header key="Authorization" value="Api-Token ${otlp_trace_token}" />
				</opentelemetry:headers>
				<opentelemetry:config-properties >
					<opentelemetry:config-property key="otel.traces.exporter" value="${otlp_traces_enabled}" />
				</opentelemetry:config-properties>
			</opentelemetry:otlp-exporter>
		</opentelemetry:exporter>
	</opentelemetry:config>

Glad it worked! Thanks for updating back here.