@Override
    public void pre(SpanAdapter span, Exchange exchange, Endpoint endpoint) {
        String name = getComponentName(endpoint);
        span.setComponent(CAMEL_COMPONENT + name);
        String scheme = getSchemeName(endpoint);
        span.setTag(TagConstants.URL_SCHEME, scheme);

        // Including the endpoint URI provides access to any options that may
        // have been provided, for subsequent analysis
        String uri = endpoint.toString(); // toString will sanitize
        span.setTag("camel.uri", uri);
        span.setTag(TagConstants.URL_PATH, stripSchemeAndOptions(endpoint));
        String query = URISupport.extractQuery(uri);
        if (query != null) {
            span.setTag(TagConstants.URL_QUERY, query);
        }

        // enrich with server location details
        if (endpoint instanceof EndpointServiceLocation ela) {
            String adr = ela.getServiceUrl();
            if (adr != null) {
                span.setTag(TagConstants.SERVER_ADDRESS, adr);
            }
            String ap = ela.getServiceProtocol();
            if (ap != null) {
                span.setTag(TagConstants.SERVER_PROTOCOL, ap);
            }
            Map<String, String> map = ela.getServiceMetadata();
            if (map != null) {
                String un = map.get("username");
                if (un != null) {
                    span.setTag(TagConstants.USER_NAME, un);
                }
                String id = map.get("clientId");
                if (id != null) {
                    span.setTag(TagConstants.USER_ID, id);
                }
                String region = map.get("region");
                if (region != null) {
                    span.setTag(TagConstants.SERVER_REGION, region);
                }
            }
        }
    }
@Test
    public void testPre() {
        Endpoint endpoint = Mockito.mock(Endpoint.class);

        Mockito.when(endpoint.getEndpointUri()).thenReturn(TEST_URI);
        Mockito.when(endpoint.toString()).thenReturn(TEST_URI);

        SpanDecorator decorator = new AbstractSpanDecorator() {
            @Override
            public String getComponent() {
                return null;
            }

            @Override
            public String getComponentClassName() {
                return null;
            }
        };

        MockSpanAdapter span = new MockSpanAdapter();

        decorator.pre(span, null, endpoint);

        assertEquals("camel-test", span.tags().get(TagConstants.COMPONENT));
        assertEquals("test", span.tags().get(TagConstants.URL_SCHEME));
        assertEquals("uri", span.tags().get(TagConstants.URL_PATH));
        assertEquals("query=hello", span.tags().get(TagConstants.URL_QUERY));
    }