@@ -367,10 +367,85 @@ void flb_test_otel_successful_response_code_204()
367367 flb_test_otel_successful_response_code ("204" );
368368}
369369
370+ void flb_test_otel_tag_from_uri_false ()
371+ {
372+ struct flb_lib_out_cb cb_data ;
373+ struct test_ctx * ctx ;
374+ struct flb_http_client * c ;
375+ int ret ;
376+ int num ;
377+ size_t b_sent ;
378+
379+ char * buf = TEST_MSG_OTEL_LOGS ;
380+
381+ clear_output_num ();
382+
383+ cb_data .cb = cb_check_result_json ;
384+ cb_data .data = TEST_CB_MSG_OTEL_LOGS ;
385+
386+ ctx = test_ctx_create (& cb_data );
387+ if (!TEST_CHECK (ctx != NULL )) {
388+ TEST_MSG ("test_ctx_create failed" );
389+ exit (EXIT_FAILURE );
390+ }
391+
392+ ret = flb_output_set (ctx -> flb , ctx -> o_ffd ,
393+ "match" , "not_uri" ,
394+ "format" , "json" ,
395+ NULL );
396+ TEST_CHECK (ret == 0 );
397+
398+ ret = flb_input_set (ctx -> flb , ctx -> i_ffd ,
399+ "tag_from_uri" , "false" ,
400+ "tag" , "not_uri" ,
401+ NULL );
402+ TEST_CHECK (ret == 0 );
403+
404+ /* Start the engine */
405+ ret = flb_start (ctx -> flb );
406+ TEST_CHECK (ret == 0 );
407+
408+ ctx -> httpc = http_client_ctx_create ();
409+ TEST_CHECK (ctx -> httpc != NULL );
410+
411+ c = flb_http_client (ctx -> httpc -> u_conn , FLB_HTTP_POST , V1_ENDPOINT_LOGS , buf , strlen (buf ),
412+ "127.0.0.1" , PORT_OTEL , NULL , 0 );
413+ ret = flb_http_add_header (c , FLB_HTTP_HEADER_CONTENT_TYPE , strlen (FLB_HTTP_HEADER_CONTENT_TYPE ),
414+ JSON_CONTENT_TYPE , strlen (JSON_CONTENT_TYPE ));
415+ TEST_CHECK (ret == 0 );
416+ if (!TEST_CHECK (c != NULL )) {
417+ TEST_MSG ("http_client failed" );
418+ exit (EXIT_FAILURE );
419+ }
420+
421+ ret = flb_http_do (c , & b_sent );
422+ if (!TEST_CHECK (ret == 0 )) {
423+ TEST_MSG ("ret error. ret=%d\n" , ret );
424+ }
425+ else if (!TEST_CHECK (b_sent > 0 )){
426+ TEST_MSG ("b_sent size error. b_sent = %lu\n" , b_sent );
427+ }
428+ else if (!TEST_CHECK (c -> resp .status == 201 )) {
429+ TEST_MSG ("http response code error. expect: 201, got: %d\n" , c -> resp .status );
430+ }
431+
432+ /* waiting to flush */
433+ flb_time_msleep (1500 );
434+
435+ num = get_output_num ();
436+ if (!TEST_CHECK (num > 0 )) {
437+ TEST_MSG ("no outputs" );
438+ }
439+ flb_http_client_destroy (c );
440+ flb_upstream_conn_release (ctx -> httpc -> u_conn );
441+ test_ctx_destroy (ctx );
442+ }
443+
370444TEST_LIST = {
371445 {"otel_logs" , flb_test_otel_logs },
372446 {"successful_response_code_200" , flb_test_otel_successful_response_code_200 },
373447 {"successful_response_code_204" , flb_test_otel_successful_response_code_204 },
448+ {"tag_from_uri_false" , flb_test_otel_tag_from_uri_false },
374449 {NULL , NULL }
375450};
376451
0 commit comments