Trying to ingore OPTIONS http method

Kibana version: 8.6.2

Elasticsearch version: 8.6.2

APM Server version: 8.6.2

APM Agent language and version: Java Agent v1.52.1

Hello Folks.

I'd like to know, if it's possible in java agent arguments, remove the preflight OPTIONS calls to API. I mean, the browser preflight OPTIONS call.

Some application has many 'OPTIONS unknown route' calls in you trace and this calls mask the APM values. I tried to use de transaction_ignore_urls with regex, only to test, but as I thought, it didn't work.

My question is: is it possible to ignore OPTIONS methods with a config in the Java agent? Do I need to change the APM query to ignore them?

The goal here is to ignore them in the Java agent to avoid code changes.

Regards.

It's not clear to me where these transactions are coming from, could you explain the scenario here?

Sure!

I'm experiencing "an issue" with CORS preflight requests from our frontend to the backend API. The browser sends an OPTIONS request before the actual API call.

For reasons I have not yet determined, we are seeing a very high volume of these OPTIONS requests, as I described in the previous thread.

My concern is about the 'OPTIONS unknown route' trace. I don't understand why these calls appear in APM and what the source of the problem might be (if it is, in fact, a problem).

A direct consequence is that these requests are triggering false positive high-throughput alerts in our monitoring system.

I'm trying to replicate and solve this on a legacy application running on an older JVM. Below is the full configuration I'm using for the Elastic APM Java agent.

    -Delastic.apm.service_name=api
    -Delastic.apm.server_urls=https://apm.local
    -Delastic.apm.secret_token=nonononono
    -Delastic.apm.environment=production
    -Delastic.apm.application_packages=com.myself
    -Delastic.apm.include_process_args=false
    -Delastic.apm.start_async=true
    -Delastic.apm.delay_agent_premain_ms=240000
    -Delastic.apm.capture_headers=true
    -Delastic.apm.use_path_as_transaction_name=false
    -Delastic.apm.transaction_ignore_urls=/metrics,/prometheus,*/metrics,*/health,*/health/*,*/prometheus,*/prometheus/*,*/actuator,*/actuator/*,*/alive,*/alive/*,.*/OPTIONS.*,.*_method=OPTIONS.*,.*\?.*OPTIONS.*
    -Delastic.apm.use_jaxrs_path_as_transaction_name=true
    -Delastic.apm.circuit_breaker_enabled=true
    -Delastic.apm.max_queue_size=128
    -Delastic.apm.api_request_time=10s
    -Delastic.apm.server_timeout=5s
    -Delastic.apm.classes_excluded_from_instrumentation=org.jboss.*,org.wildfly.*,io.undertow.*,com.fasterxml.jackson.*,org.hibernate.validator.*,javax.validation.*
    -Delastic.apm.disable_instrumentations=reactor,spring-webflux,spring-webclient,springwebclient
    -Delastic.apm.span_compression_enabled=true
    -Delastic.apm.enable_type_pool_cache=true
    -Delastic.apm.central_config=false
    -Delastic.apm.log_level=ERROR
    -Delastic.apm.span_stack_trace_min_duration=5000ms
    -Delastic.apm.stack_trace_limit=25
    -Delastic.apm.transaction_max_spans=300
    -Delastic.apm.transaction_sample_rate=1.0
    -Delastic.apm.span_min_duration=100ms
    -Delastic.apm.exit_span_min_duration=100ms
    -Delastic.apm.trace_methods_duration_threshold=150ms
    -Delastic.apm.use_elastic_traceparent_header=false
    -Delastic.apm.disable_outgoing_tracecontext_headers=true

This is the browser call:

What is causing the traces to appear as 'OPTIONS unknown route'? Is there a way to fix this? For example, is there a specific setting in the agent configuration that can prevent these traces from being captured?

what do you get when you set use_path_as_transaction_name=true

Hello Jack, Sorry for the delay.

I'll test this argument and get back to you with the results as soon as possible.

Hello Jack, sorry for the delay.

I ran into some issues that kept me from doing the test earlier. Everything is working fine now.

Thanks again for your help.

Have a nice week.