-
Notifications
You must be signed in to change notification settings - Fork 801
feat(milvus): Add error.type attribute from OpenTelemetry Semantic Conventions #3009
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
8c168fc
updated milvus search instrumentation
divyapathak24 aabbb9e
modified instrumentation for events attributes
divyapathak24 1ce0f8f
bug fix
divyapathak24 d65594e
bug fix
divyapathak24 068a102
Merge branch 'traceloop:main' into main
divyapathak24 3418467
Merge branch 'traceloop:main' into main
divyapathak24 ea93730
Merge branch 'traceloop:main' into main
divyapathak24 a17b6d9
Add error type from otel semconv
divyapathak24 3cd7c18
remove print
divyapathak24 1c11863
add error code functionality
divyapathak24 d112361
fix lint issues
divyapathak24 06750a0
fix lint issues
divyapathak24 07d6e40
Update packages/opentelemetry-instrumentation-milvus/opentelemetry/in…
divyapathak24 f5f6d16
fix dynamic code mapping
divyapathak24 941ee1d
Merge branch 'main' into test-error_type
nirga 0013439
test span status error
divyapathak24 d8fb108
Merge branch 'main' into test-error_type
divyapathak24 872b52c
Merge branch 'main' into test-error_type
nirga ade54fa
Merge branch 'main' into test-error_type
nirga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
packages/opentelemetry-instrumentation-milvus/tests/test_error.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import os | ||
import random | ||
|
||
import pymilvus | ||
import pytest | ||
from opentelemetry.semconv_ai import Events, SpanAttributes, EventAttributes | ||
|
||
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "milvus.db") | ||
milvus = pymilvus.MilvusClient(uri=path) | ||
|
||
|
||
@pytest.fixture | ||
def collection(): | ||
collection_name = "Colors" | ||
milvus.create_collection(collection_name=collection_name, dimension=5) | ||
yield collection_name | ||
milvus.drop_collection(collection_name=collection_name) | ||
|
||
|
||
def insert_data(collection): | ||
colors = [ | ||
"green", | ||
"blue", | ||
"yellow", | ||
"red", | ||
"black", | ||
"white", | ||
"purple", | ||
"pink", | ||
"orange", | ||
"grey", | ||
] | ||
data = [ | ||
{ | ||
"id": i, | ||
"vector": [random.uniform(-1, 1) for _ in range(5)], | ||
"color": random.choice(colors), | ||
"tag": random.randint(1000, 9999), | ||
} | ||
for i in range(1000) | ||
] | ||
data += [ | ||
{ | ||
"id": 1000, | ||
"vector": [random.uniform(-1, 1) for _ in range(5)], | ||
"color": "brown", | ||
"tag": 1234, | ||
}, | ||
{ | ||
"id": 1001, | ||
"vector": [random.uniform(-1, 1) for _ in range(5)], | ||
"color": "brown", | ||
"tag": 5678, | ||
}, | ||
{ | ||
"id": 1002, | ||
"vector": [random.uniform(-1, 1) for _ in range(5)], | ||
"color": "brown", | ||
"tag": 9101, | ||
}, | ||
] | ||
for i in data: | ||
i["color_tag"] = "{}_{}".format(i["color"], i["tag"]) | ||
milvus.insert(collection_name=collection, data=data) | ||
|
||
|
||
def test_milvus_single_vector_search(exporter, collection): | ||
insert_data(collection) | ||
|
||
bad_query_vector = [random.uniform(-1, 1) for _ in range(2)] | ||
search_params = {"radius": 0.5, "metric_type": "COSINE", "index_type": "IVF_FLAT"} | ||
with pytest.raises(Exception) as exc_info: | ||
milvus.search( | ||
collection_name=collection, | ||
data=[bad_query_vector], | ||
anns_field="vector", | ||
search_params=search_params, | ||
output_fields=["color_tag"], | ||
limit=3, | ||
timeout=10, | ||
) | ||
|
||
# Get finished spans | ||
spans = exporter.get_finished_spans() | ||
span = next(span for span in spans if span.name == "milvus.search") | ||
|
||
# Check the span attributes related to search | ||
assert span.attributes.get("error.type") == "internal_error" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
you should also set the span status as error
Uh oh!
There was an error while loading. Please reload this page.
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.
@nirga I have raised the exception at
line 85 in wrapper.py
, which automatically sets the span status to "error"—as shown in the attached screenshot as well.I have also added a test to verify that the span status is correctly set to "error"
line 88 in test_error.py