-
Notifications
You must be signed in to change notification settings - Fork 1k
Add server address and port for Spymemcached #15242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
...pentelemetry/javaagent/instrumentation/spymemcached/SpymemcachedNetworkAttributesGetter.java
Outdated
Show resolved
Hide resolved
| private static MemcachedNode getRepresentativeNodeFromConnection(MemcachedConnection connection) { | ||
| try { | ||
| // Strategy: Get the "most representative" node for bulk operations | ||
| // We choose the last active node in the list, which often represents | ||
| // the most recently added or most stable node in the cluster | ||
| Collection<MemcachedNode> allNodes = connection.getLocator().getAll(); | ||
|
|
||
| MemcachedNode lastActiveNode = null; | ||
| MemcachedNode fallbackNode = null; | ||
|
|
||
| for (MemcachedNode node : allNodes) { | ||
| if (fallbackNode == null) { | ||
| fallbackNode = node; | ||
| } | ||
|
|
||
| if (node.isActive()) { | ||
| lastActiveNode = node; | ||
| } | ||
| } | ||
|
|
||
| // Return the last active node, or fallback to the first node | ||
| return lastActiveNode != null ? lastActiveNode : fallbackNode; | ||
| } catch (RuntimeException e) { | ||
| return null; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For bulk operations like asyncGetBulk() https://github.com/couchbase/spymemcached/blob/eb5d6eeaf5b3b6f74eda3e3cf709e70f7bb4c4ad/src/main/java/net/spy/memcached/MemcachedClient.java#L1274-L1316, spymemcached distributes keys across multiple Memcached nodes based on consistent hashing. Each key may be handled by a different MemcachedNode, meaning a single bulk operation can involve multiple servers.
Currently, the implementation uses a representative node approach - it iterates through connection.getLocator().getAll() and select the last active node to populate server.address and server.port attributes.
According to the SenConv, I couldn't find specific guidance on how to handle network attributes when a single database operation involves multiple servers/nodes. I am not sure it is correct. Do we have any guidance to help deal with this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@trask do you have any guidance on how to handle the situation where a database clients connects to multiple servers for a single operation.
I believe that this will require clarification in the semconv. Our current stance in this project is that if we can not fill an attribute with the correct value then we don't fill it.
No description provided.