Commit 1fa81783 authored by ascrutae's avatar ascrutae
Browse files

change the remote address of MQ exit span to naming service address

parent bfbf7aeb
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -16,10 +16,11 @@
 * Project repository: https://github.com/OpenSkywalking/skywalking
 */

package org.apache.rocketmq.common.message;
package org.skywalking.apm.plugin.rocketMQ.v4;

import java.lang.reflect.Method;
import java.util.List;
import org.apache.rocketmq.common.message.MessageExt;
import org.skywalking.apm.agent.core.context.CarrierItem;
import org.skywalking.apm.agent.core.context.ContextCarrier;
import org.skywalking.apm.agent.core.context.ContextManager;
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@
 * Project repository: https://github.com/OpenSkywalking/skywalking
 */

package org.apache.rocketmq.common.message;
package org.skywalking.apm.plugin.rocketMQ.v4;

import java.lang.reflect.Method;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@
 * Project repository: https://github.com/OpenSkywalking/skywalking
 */

package org.apache.rocketmq.common.message;
package org.skywalking.apm.plugin.rocketMQ.v4;

import java.lang.reflect.Method;
import org.apache.rocketmq.client.consumer.listener.ConsumeOrderlyStatus;
+2 −1
Original line number Diff line number Diff line
@@ -56,7 +56,8 @@ public class MessageSendInterceptor implements InstanceMethodsAroundInterceptor
        MethodInterceptResult result) throws Throwable {
        Message message = (Message)allArguments[2];
        ContextCarrier contextCarrier = new ContextCarrier();
        AbstractSpan span = ContextManager.createExitSpan(buildOperationName(message.getTopic()), contextCarrier, (String)allArguments[0]);
        String namingServiceAddress = String.valueOf(objInst.getSkyWalkingDynamicField());
        AbstractSpan span = ContextManager.createExitSpan(buildOperationName(message.getTopic()), contextCarrier, namingServiceAddress);
        span.setComponent(ComponentsDefine.ROCKET_MQ);
        span.setLayer(SpanLayer.MQ);
        span.tag("brokerName", (String)allArguments[1]);
+43 −0
Original line number Diff line number Diff line
/*
 * Copyright 2017, OpenSkywalking Organization All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Project repository: https://github.com/OpenSkywalking/skywalking
 */

package org.skywalking.apm.plugin.rocketMQ.v4;

import java.lang.reflect.Method;
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;

public class UpdateNameServerInterceptor implements InstanceMethodsAroundInterceptor {
    @Override
    public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
        MethodInterceptResult result) throws Throwable {
        objInst.setSkyWalkingDynamicField(allArguments[0]);
    }

    @Override
    public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
        Object ret) throws Throwable {
        return ret;
    }

    @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
        Class<?>[] argumentsTypes, Throwable t) {

    }
}
Loading