Unify MQ related plugins' tags for virtual MQ (#351)

This commit is contained in:
pg.yang 2022-10-18 10:11:05 +08:00 committed by GitHub
parent 54e3542406
commit 23b3c2d35e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 241 additions and 138 deletions

View File

@ -15,12 +15,14 @@ Release Notes.
* Add plugin to support [brpc-java-3.x](https://github.com/baidu/starlight/tree/brpc-java-v3)
* Update `compose-start-script.template` to make compatible with new version docker compose
* Bump up grpc to 1.50.0 to fix CVE-2022-3171
* Polish up nats plugin to unify MQ related tags
#### Documentation
* Update `configuration` doc about overriding default value as empty map/list accordingly.
* Update plugin dev tags for cache relative tags.
* Add plugin dev docs for virtual database tags.
* Add plugin dev docs for virtual MQ tags.
All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/150?closed=1)

View File

@ -24,7 +24,6 @@ import java.util.Iterator;
public class ConnectionSendCmdInterceptor extends AbstractConnectionInterceptor {
//public void sendCommand(final CommandArguments args)
@Override
protected Iterator<Rawable> getCommands(Object[] allArguments) {
CommandArguments commandArguments = (CommandArguments) allArguments[0];

View File

@ -17,6 +17,7 @@
package org.apache.skywalking.apm.plugin.nats.client;
import io.nats.client.Connection;
import io.nats.client.MessageHandler;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
@ -24,13 +25,14 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInt
import java.lang.reflect.Method;
import static org.apache.skywalking.apm.plugin.nats.client.NatsCommons.buildServers;
import static org.apache.skywalking.apm.plugin.nats.client.NatsCommons.buildTraceMsgHandler;
public class CreateDispatcherInterceptor implements InstanceMethodsAroundInterceptor {
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
allArguments[0] = buildTraceMsgHandler((MessageHandler) allArguments[0]);
allArguments[0] = buildTraceMsgHandler(buildServers((Connection) objInst), (MessageHandler) allArguments[0]);
}
@Override

View File

@ -29,7 +29,9 @@ import static org.apache.skywalking.apm.plugin.nats.client.NatsCommons.buildTrac
public class CreateSubInterceptor implements InstanceMethodsAroundInterceptor {
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
allArguments[3] = buildTraceMsgHandler((MessageHandler) allArguments[3]);
//set by NatsJetStreamConstructorInterceptor
final String servers = (String) objInst.getSkyWalkingDynamicField();
allArguments[3] = buildTraceMsgHandler(servers , (MessageHandler) allArguments[3]);
}
@Override

View File

@ -17,8 +17,10 @@
package org.apache.skywalking.apm.plugin.nats.client;
import io.nats.client.Connection;
import io.nats.client.Message;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
@ -26,13 +28,15 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInt
import java.lang.reflect.Method;
import static org.apache.skywalking.apm.plugin.nats.client.NatsCommons.buildServers;
import static org.apache.skywalking.apm.plugin.nats.client.NatsCommons.createEntrySpan;
public class DeliverReplyInterceptor implements InstanceMethodsAroundInterceptor {
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
createEntrySpan((Message) allArguments[0]);
final AbstractSpan entrySpan = createEntrySpan((Message) allArguments[0]);
Tags.MQ_BROKER.set(entrySpan, buildServers((Connection) objInst));
}
@Override
@ -45,6 +49,5 @@ public class DeliverReplyInterceptor implements InstanceMethodsAroundInterceptor
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Throwable t) {
AbstractSpan span = ContextManager.activeSpan();
span.log(t).errorOccurred();
ContextManager.stopSpan(span);
}
}

View File

@ -17,6 +17,7 @@
package org.apache.skywalking.apm.plugin.nats.client;
import io.nats.client.Connection;
import io.nats.client.Message;
import io.nats.client.MessageHandler;
import org.apache.skywalking.apm.agent.core.context.CarrierItem;
@ -24,6 +25,7 @@ import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.tag.IntegerTag;
import org.apache.skywalking.apm.agent.core.context.tag.StringTag;
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
@ -37,6 +39,7 @@ public class NatsCommons {
private static final String REPLY_TO = "reply_to";
private static final String MSG_STATE = "state";
private static final String MSG = "message";
private static final String UNKNOWN_SERVER = "unknown_server";
static boolean skipTrace(Object msg) {
// include null
@ -64,11 +67,12 @@ public class NatsCommons {
static void injectCarrier(Message message) {
ContextCarrier contextCarrier = new ContextCarrier();
ContextManager.inject(contextCarrier);
contextCarrier.extensionInjector().injectSendingTimestamp();
CarrierItem next = contextCarrier.items();
while (next.hasNext()) {
next = next.next();
if (StringUtil.isNotEmpty(next.getHeadKey())
&& StringUtil.isNotEmpty(next.getHeadValue())) {
&& StringUtil.isNotEmpty(next.getHeadValue())) {
message.getHeaders().add(next.getHeadKey(), next.getHeadValue());
}
}
@ -77,6 +81,7 @@ public class NatsCommons {
static void addCommonTag(AbstractSpan span, Message message) {
Optional.ofNullable(message.getReplyTo()).ifPresent(v -> span.tag(new StringTag(REPLY_TO), v));
Optional.ofNullable(message.getSID()).ifPresent(v -> span.tag(new StringTag(SID), v));
Tags.MQ_QUEUE.set(span, message.getSubject());
span.setComponent(ComponentsDefine.NATS);
SpanLayer.asMQ(span);
if (message.getStatus() != null) {
@ -92,7 +97,7 @@ public class NatsCommons {
}
}
static MessageHandler buildTraceMsgHandler(MessageHandler msgHandler) {
static MessageHandler buildTraceMsgHandler(String servers, MessageHandler msgHandler) {
if (msgHandler == null) {
return null;
}
@ -102,6 +107,7 @@ public class NatsCommons {
return;
}
AbstractSpan span = NatsCommons.createEntrySpan(msg);
Tags.MQ_BROKER.set(span, servers);
try {
msgHandler.onMessage(msg);
} catch (Exception e) {
@ -113,4 +119,9 @@ public class NatsCommons {
};
}
static String buildServers(Connection connection) {
return connection.getServers().stream().reduce((a, b) -> a + "," + b).orElse(UNKNOWN_SERVER);
}
}

View File

@ -17,27 +17,17 @@
package org.apache.skywalking.apm.plugin.nats.client;
import io.nats.client.Connection;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
import java.lang.reflect.Method;
import static org.apache.skywalking.apm.plugin.nats.client.NatsCommons.buildServers;
public class SocketDataPortConnectInterceptor implements InstanceMethodsAroundInterceptor {
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
}
public class NatsConnectionWriterConstructorInterceptor implements InstanceConstructorInterceptor {
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
//Hold current serverURI
objInst.setSkyWalkingDynamicField(allArguments[0]);
return ret;
}
@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Throwable t) {
public void onConstruct(final EnhancedInstance objInst, final Object[] allArguments) throws Throwable {
Connection connection = (Connection) allArguments[0];
objInst.setSkyWalkingDynamicField(buildServers(connection));
}
}

View File

@ -0,0 +1,32 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
package org.apache.skywalking.apm.plugin.nats.client;
import io.nats.client.Connection;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
import static org.apache.skywalking.apm.plugin.nats.client.NatsCommons.buildServers;
public class NatsJetStreamConstructorInterceptor implements InstanceConstructorInterceptor {
@Override
public void onConstruct(final EnhancedInstance objInst, final Object[] allArguments) throws Throwable {
final Connection connection = (Connection) allArguments[0];
objInst.setSkyWalkingDynamicField(buildServers(connection));
}
}

View File

@ -0,0 +1,32 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
package org.apache.skywalking.apm.plugin.nats.client;
import io.nats.client.Connection;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
import static org.apache.skywalking.apm.plugin.nats.client.NatsCommons.buildServers;
public class NatsSubscriptionConstructorInterceptor implements InstanceConstructorInterceptor {
@Override
public void onConstruct(final EnhancedInstance objInst, final Object[] allArguments) throws Throwable {
Connection connection = (Connection) allArguments[3];
objInst.setSkyWalkingDynamicField(buildServers(connection));
}
}

View File

@ -19,6 +19,7 @@ package org.apache.skywalking.apm.plugin.nats.client;
import io.nats.client.Message;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
@ -39,9 +40,11 @@ public class SubscriptionNextMsgInterceptor implements InstanceMethodsAroundInte
if (ret == null) {
return null;
}
// set by NatsSubscriptionConstructorInterceptor
String servers = (String) objInst.getSkyWalkingDynamicField();
Message msg = (Message) ret;
AbstractSpan span = createEntrySpan(msg);
Tags.MQ_BROKER.set(span , servers);
// Close the span immediately , as no chance to trace what user want to do
ContextManager.stopSpan(span);
return ret;

View File

@ -62,7 +62,6 @@ public class WriterQueueInterceptor implements InstanceMethodsAroundInterceptor
@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Throwable t) {
AbstractSpan span = ContextManager.activeSpan().errorOccurred().log(t);
ContextManager.stopSpan(span);
ContextManager.activeSpan().errorOccurred().log(t);
}
}

View File

@ -21,6 +21,7 @@ import io.nats.client.Message;
import io.nats.client.impl.NatsMessage;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.apache.skywalking.apm.agent.core.plugin.PluginException;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
@ -53,13 +54,15 @@ public class WriterSendMessageBatchInterceptor implements InstanceMethodsAroundI
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
Object next = allArguments[0];
String serverURI = (String) ((EnhancedInstance) allArguments[1]).getSkyWalkingDynamicField();
// set by NatsConnectionWriterConstructorInterceptor
final String services = (String) objInst.getSkyWalkingDynamicField();
while (next != null) {
if (!skipTrace(next)) {
Message message = (Message) next;
EnhancedInstance enhanced = (EnhancedInstance) next;
AbstractSpan span = ContextManager.createExitSpan("Nats/Pub/" + message.getSubject(), serverURI);
AbstractSpan span = ContextManager.createExitSpan("Nats/Pub/" + message.getSubject(), services);
addCommonTag(span, message);
Tags.MQ_BROKER.set(span, services);
Optional.ofNullable(enhanced.getSkyWalkingDynamicField())
.ifPresent(snapshot -> ContextManager.continued((ContextSnapshot) snapshot));
injectCarrier(message);

View File

@ -33,6 +33,7 @@ public class NatsConnectionWriterInstrumentation extends ClassInstanceMethodsEnh
private static final String ENHANCE_CLASS = "io.nats.client.impl.NatsConnectionWriter";
private static final String PUBLISH_INTERCEPTOR_CLASS_NAME = "org.apache.skywalking.apm.plugin.nats.client.WriterSendMessageBatchInterceptor";
private static final String QUEUE_INTERCEPTOR_CLASS_NAME = "org.apache.skywalking.apm.plugin.nats.client.WriterQueueInterceptor";
private static final String CONSTRUCTOR_INTERCEPTOR_CLASS_NAME = "org.apache.skywalking.apm.plugin.nats.client.NatsConnectionWriterConstructorInterceptor";
@Override
protected ClassMatch enhanceClass() {
@ -41,7 +42,19 @@ public class NatsConnectionWriterInstrumentation extends ClassInstanceMethodsEnh
@Override
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[0];
return new ConstructorInterceptPoint[] {
new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return takesArguments(1);
}
@Override
public String getConstructorInterceptor() {
return CONSTRUCTOR_INTERCEPTOR_CLASS_NAME;
}
}
};
}
@Override

View File

@ -32,6 +32,7 @@ public class NatsJetStreamInstrumentation extends ClassInstanceMethodsEnhancePlu
private static final String ENHANCE_CLASS = "io.nats.client.impl.NatsJetStream";
private static final String CREATE_SUB_INTERCEPTOR = "org.apache.skywalking.apm.plugin.nats.client.CreateSubInterceptor";
private static final String CONSTRUCTOR_INTERCEPTOR = "org.apache.skywalking.apm.plugin.nats.client.NatsJetStreamConstructorInterceptor";
@Override
protected ClassMatch enhanceClass() {
@ -40,7 +41,19 @@ public class NatsJetStreamInstrumentation extends ClassInstanceMethodsEnhancePlu
@Override
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[0];
return new ConstructorInterceptPoint[] {
new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return takesArguments(2);
}
@Override
public String getConstructorInterceptor() {
return CONSTRUCTOR_INTERCEPTOR;
}
}
};
}
@Override

View File

@ -32,6 +32,7 @@ public class NatsSubscriptionInstrumentation extends ClassInstanceMethodsEnhance
private static final String ENHANCE_CLASS = "io.nats.client.impl.NatsSubscription";
private static final String NEXT_MSG_INTERCEPTOR = "org.apache.skywalking.apm.plugin.nats.client.SubscriptionNextMsgInterceptor";
private static final String CONSTRUCTOR_INTERCEPTOR = "org.apache.skywalking.apm.plugin.nats.client.NatsSubscriptionConstructorInterceptor";
@Override
protected ClassMatch enhanceClass() {
@ -40,7 +41,19 @@ public class NatsSubscriptionInstrumentation extends ClassInstanceMethodsEnhance
@Override
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[0];
return new ConstructorInterceptPoint[] {
new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return takesArguments(5);
}
@Override
public String getConstructorInterceptor() {
return CONSTRUCTOR_INTERCEPTOR;
}
}
};
}
@Override

View File

@ -1,67 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
package org.apache.skywalking.apm.plugin.nats.client.define;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
public class SocketDataPortInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
private static final String ENHANCE_CLASS = "io.nats.client.impl.SocketDataPort";
private static final String CONSTRUCTOR_INTERCEPTOR = "org.apache.skywalking.apm.plugin.nats.client.SocketDataPortConnectInterceptor";
@Override
protected ClassMatch enhanceClass() {
return byName(ENHANCE_CLASS);
}
@Override
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[0];
}
@Override
public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[]{
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named("connect").and(takesArguments(3));
}
@Override
public String getMethodsInterceptor() {
return CONSTRUCTOR_INTERCEPTOR;
}
@Override
public boolean isOverrideArgs() {
return false;
}
}
};
}
}

View File

@ -18,5 +18,4 @@ nats-client-2.14.x-2.15.x=org.apache.skywalking.apm.plugin.nats.client.define.Na
nats-client-2.14.x-2.15.x=org.apache.skywalking.apm.plugin.nats.client.define.NatsConnectionInstrumentation
nats-client-2.14.x-2.15.x=org.apache.skywalking.apm.plugin.nats.client.define.NatsConnectionWriterInstrumentation
nats-client-2.14.x-2.15.x=org.apache.skywalking.apm.plugin.nats.client.define.NatsSubscriptionInstrumentation
nats-client-2.14.x-2.15.x=org.apache.skywalking.apm.plugin.nats.client.define.NatsJetStreamInstrumentation
nats-client-2.14.x-2.15.x=org.apache.skywalking.apm.plugin.nats.client.define.SocketDataPortInstrumentation
nats-client-2.14.x-2.15.x=org.apache.skywalking.apm.plugin.nats.client.define.NatsJetStreamInstrumentation

View File

@ -186,7 +186,7 @@ The value of `x-le` should be in JSON format. There are two options:
}
```
#### Vitural Database Relative Tags
#### Virtual Database Relative Tags
SkyWalking analysis Database(SQL-like) performance metrics through the following tags.
```java
@ -199,8 +199,8 @@ SkyWalking analysis Database(SQL-like) performance metrics through the following
Read [backend's virtual database doc](https://skywalking.apache.org/docs/main/next/en/setup/service-agent/virtual-database/) for more details.
#### Vitural Cache Relative Tags
Skywalking analysis cache performance related metrics through the following tags.
#### Virtual Cache Relative Tags
SkyWalking analysis cache performance related metrics through the following tags.
```java
public static final StringTag CACHE_TYPE = new StringTag(15, "cache.type");
@ -209,7 +209,7 @@ Skywalking analysis cache performance related metrics through the following tags
public static final StringTag CACHE_KEY = new StringTag(18, "cache.key");
```
* `cache.type` indicates the cache type , usually it's cache client library name (e.g. Jedis)
* `cache.type` indicates the cache type , usually it's official name of cache (e.g. Redis)
* `cache.cmd` indicates the cache command that would be sent to cache server (e.g. setnx)
* `cache.op` indicates the command is used for `write` or `read` operation , usually the value is converting from `command`
* `cache.key` indicates the cache key that would be sent to cache server , this tag maybe null , as string type key would be collected usually.
@ -217,6 +217,22 @@ Skywalking analysis cache performance related metrics through the following tags
In order to decide which `op` should be converted to flexibly , It's better that providing config property .
Reference [Jedis-4.x-plugin](https://github.com/apache/skywalking-java/blob/main/apm-sniffer/apm-sdk-plugin/jedis-plugins/jedis-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jedis/v4/JedisPluginConfig.java)
#### Virtual Message Queue (MQ) Relative Tags
SkyWalking analysis MQ performance related metrics through the following tags.
```java
public static final StringTag MQ_QUEUE = new StringTag(7, "mq.queue");
public static final StringTag MQ_BROKER = new StringTag(8, "mq.broker");
public static final StringTag MQ_TOPIC = new StringTag(9, "mq.topic");
public static final StringTag TRANSMISSION_LATENCY = new StringTag(15, "transmission.latency", false);
```
* `mq.brokers` indicates MQ address ,SkyWalking organize the value as service . Both of consumer , producer must record the tag , and ensure the value is consistent .
* `mq.queue` indicates MQ queue name
* `mq.topic` indicates MQ topic name , It's optional as some MQ don't hava concept of `topic`
* `transmission.latency` The transmission latency from consumer to producer. Usually you needn't to record this tag manually, instead to call `contextCarrier.extensionInjector().injectSendingTimestamp();` to record tag `sendingTimestamp` on producer side , and SkyWalking would record this tag on consumer side if `sw8-x` context carrier(from producer side) contains `sendingTimestamp`
### Advanced APIs
#### Async Span APIs

View File

@ -33,7 +33,7 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- segmentId: not null
spans:
- operationName: Nats/Pub/$JS.API.STREAM.INFO.scenario-8080-test-stream-3
@ -50,7 +50,9 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: Nats/Pub/Enqueue/$JS.API.STREAM.INFO.scenario-8080-test-stream-3,
networkAddress: '', refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null,
@ -72,7 +74,7 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- segmentId: not null
spans:
- operationName: Nats/Pub/$JS.API.STREAM.CREATE.scenario-8080-test-stream-3
@ -89,7 +91,8 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: Nats/Pub/Enqueue/$JS.API.STREAM.CREATE.scenario-8080-test-stream-3,
networkAddress: '', refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null,
@ -111,7 +114,7 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- segmentId: not null
spans:
- operationName: Nats/Pub/$JS.API.CONSUMER.CREATE.scenario-8080-test-stream-3
@ -128,7 +131,8 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: Nats/Pub/Enqueue/$JS.API.CONSUMER.CREATE.scenario-8080-test-stream-3,
networkAddress: '', refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null,
@ -150,7 +154,7 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- segmentId: not null
spans:
- operationName: Nats/Pub/$JS.API.STREAM.INFO.scenario-8080-test-stream-4
@ -167,7 +171,8 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: Nats/Pub/Enqueue/$JS.API.STREAM.INFO.scenario-8080-test-stream-4,
networkAddress: '', refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null,
@ -189,7 +194,7 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- segmentId: not null
spans:
- operationName: Nats/Pub/$JS.API.STREAM.CREATE.scenario-8080-test-stream-4
@ -206,7 +211,8 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: Nats/Pub/Enqueue/$JS.API.STREAM.CREATE.scenario-8080-test-stream-4,
networkAddress: '', refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null,
@ -228,7 +234,8 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: Nats/Pub/Enqueue/$JS.API.STREAM.NAMES, networkAddress: '',
refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null,
@ -250,7 +257,7 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- segmentId: not null
spans:
- operationName: Nats/Pub/Enqueue/$JS.API.STREAM.NAMES
@ -267,7 +274,7 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- segmentId: not null
spans:
- operationName: Nats/Pub/$JS.API.CONSUMER.INFO.scenario-8080-test-stream-4.scenario-8080-test-stream-4-durable
@ -284,7 +291,8 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: Nats/Pub/Enqueue/$JS.API.CONSUMER.INFO.scenario-8080-test-stream-4.scenario-8080-test-stream-4-durable,
networkAddress: '', refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null,
@ -306,6 +314,7 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- segmentId: not null
spans:
- operationName: Nats/Pub/$JS.API.CONSUMER.DURABLE.CREATE.scenario-8080-test-stream-4.scenario-8080-test-stream-4-durable
@ -322,7 +331,8 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: Nats/Pub/Enqueue/$JS.API.CONSUMER.DURABLE.CREATE.scenario-8080-test-stream-4.scenario-8080-test-stream-4-durable,
networkAddress: '', refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null,
@ -344,7 +354,8 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: Nats/Pub/Enqueue/$JS.API.CONSUMER.MSG.NEXT.scenario-8080-test-stream-4.scenario-8080-test-stream-4-durable,
networkAddress: '', refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null,
@ -366,7 +377,7 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- segmentId: not null
spans:
- operationName: HEAD:/nats/check
@ -400,7 +411,8 @@ segmentItems:
peer: nats://nats-server:4222
skipAnalysis: false
tags:
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: 'GET:/nats/start', networkAddress: '', refType: CrossThread,
parentSpanId: 1, parentTraceSegmentId: not null,
@ -421,7 +433,10 @@ segmentItems:
peer: ''
skipAnalysis: false
tags:
- {key: transmission.latency, value: not null}
- {key: sid, value: '1'}
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: Nats/Pub/scenario-8080-subject-1, networkAddress: 'nats://nats-server:4222',
refType: CrossProcess, parentSpanId: 0, parentTraceSegmentId: not null,
@ -443,7 +458,8 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: 'GET:/nats/start', networkAddress: '', refType: CrossThread,
parentSpanId: 2, parentTraceSegmentId: not null,
@ -464,7 +480,8 @@ segmentItems:
peer: nats://nats-server:4222
skipAnalysis: false
tags:
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: Nats/Sub/scenario-8080-subject-2, networkAddress: '', refType: CrossThread,
parentSpanId: 1, parentTraceSegmentId: not null,
@ -485,7 +502,8 @@ segmentItems:
peer: ''
skipAnalysis: false
tags:
- {key: mq.queue, value: not null}
- operationName: Nats/Sub/scenario-8080-subject-2
operationId: 0
parentSpanId: -1
@ -499,8 +517,11 @@ segmentItems:
peer: ''
skipAnalysis: false
tags:
- {key: transmission.latency, value: not null}
- {key: reply_to, value: not null}
- {key: sid, value: '1'}
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: Nats/Pub/scenario-8080-subject-2, networkAddress: 'nats://nats-server:4222',
refType: CrossProcess, parentSpanId: 0, parentTraceSegmentId: not null,
@ -521,7 +542,10 @@ segmentItems:
peer: ''
skipAnalysis: false
tags:
- {key: transmission.latency, value: not null}
- {key: sid, value: '1'}
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: not null,
networkAddress: 'nats://nats-server:4222', refType: CrossProcess, parentSpanId: 0,
@ -544,7 +568,8 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: 'GET:/nats/start', networkAddress: '', refType: CrossThread,
parentSpanId: 3, parentTraceSegmentId: not null,
@ -565,7 +590,8 @@ segmentItems:
peer: ''
skipAnalysis: false
tags:
- {key: mq.queue, value: not null}
- operationName: Nats/Sub/scenario-8080-subject-3
operationId: 0
parentSpanId: -1
@ -579,8 +605,12 @@ segmentItems:
peer: ''
skipAnalysis: false
tags:
- {key: transmission.latency, value: not null}
- {key: reply_to, value: not null}
- {key: sid, value: '2'}
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: Nats/Pub/scenario-8080-subject-3, networkAddress: 'nats://nats-server:4222',
refType: CrossProcess, parentSpanId: 0, parentTraceSegmentId: not null,
@ -601,7 +631,8 @@ segmentItems:
peer: nats://nats-server:4222
skipAnalysis: false
tags:
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: Nats/Sub/scenario-8080-subject-3, networkAddress: '', refType: CrossThread,
parentSpanId: 1, parentTraceSegmentId: not null,
@ -623,7 +654,8 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: 'GET:/nats/start', networkAddress: '', refType: CrossThread,
parentSpanId: 4, parentTraceSegmentId: not null,
@ -645,7 +677,8 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: 'GET:/nats/start', networkAddress: '', refType: CrossThread,
parentSpanId: 6, parentTraceSegmentId: not null,
@ -666,8 +699,11 @@ segmentItems:
peer: ''
skipAnalysis: false
tags:
- {key: transmission.latency, value: not null}
- {key: reply_to, value: not null}
- {key: sid, value: '2'}
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: Nats/Pub/scenario-8080-subject-4, networkAddress: 'nats://nats-server:4222',
refType: CrossProcess, parentSpanId: 0, parentTraceSegmentId: not null,
@ -688,7 +724,7 @@ segmentItems:
peer: ''
skipAnalysis: false
tags:
- {key: mq.queue, value: not null}
- operationName: Nats/Pub/Enqueue/scenario-8080-subject-2
operationId: 0
parentSpanId: 0
@ -703,7 +739,8 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- operationName: Nats/Pub/Enqueue/$JS.API.STREAM.INFO.scenario-8080-test-stream-3
operationId: 0
parentSpanId: 0
@ -718,7 +755,7 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- operationName: Nats/Pub/Enqueue/scenario-8080-subject-3
operationId: 0
parentSpanId: 0
@ -733,7 +770,7 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- operationName: Nats/Pub/Enqueue/$JS.API.STREAM.INFO.scenario-8080-test-stream-4
operationId: 0
parentSpanId: 0
@ -748,7 +785,7 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- operationName: Nats/Pub/Enqueue/scenario-8080-subject-4
operationId: 0
parentSpanId: 0
@ -763,7 +800,7 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- operationName: GET:/nats/start
operationId: 0
parentSpanId: -1
@ -796,7 +833,8 @@ segmentItems:
skipAnalysis: false
tags:
- {key: reply_to, value: not null}
- {key: mq.queue, value: not null}
- {key: mq.broker, value: 'nats://nats-server:4222'}
refs:
- {parentEndpoint: 'GET:/nats/start', networkAddress: '', refType: CrossThread,
parentSpanId: 5, parentTraceSegmentId: not null,