divi 0.0.1.dev7__py3-none-any.whl → 0.0.1.dev14__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- divi/__init__.py +11 -4
- divi/config/config.py +0 -0
- divi/decorators/__init__.py +4 -0
- divi/decorators/obs_openai.py +33 -0
- divi/decorators/observable.py +137 -0
- divi/proto/common/v1/common.proto +49 -0
- divi/proto/common/v1/common_pb2.py +43 -0
- divi/proto/common/v1/common_pb2.pyi +44 -0
- divi/proto/core/health/v1/health_service.proto +17 -0
- divi/proto/core/{v1/health_check_response_pb2.py → health/v1/health_service_pb2.py} +11 -7
- divi/proto/core/{v1/health_check_response_pb2.pyi → health/v1/health_service_pb2.pyi} +6 -0
- divi/proto/core/{v1/core_pb2_grpc.py → health/v1/health_service_pb2_grpc.py} +19 -20
- divi/proto/metric/v1/metric.proto +26 -0
- divi/proto/metric/v1/metric_pb2.py +40 -0
- divi/proto/metric/v1/metric_pb2.pyi +25 -0
- divi/proto/trace/v1/trace.proto +47 -0
- divi/proto/trace/v1/trace_pb2.py +44 -0
- divi/proto/trace/v1/trace_pb2.pyi +52 -0
- divi/services/__init__.py +7 -0
- divi/services/auth/__init__.py +4 -0
- divi/services/auth/auth.py +21 -0
- divi/services/auth/init.py +21 -0
- divi/services/auth/tokman.py +42 -0
- divi/services/core/__init__.py +5 -0
- divi/services/core/core.py +35 -0
- divi/{core → services/core}/finish.py +4 -4
- divi/{core → services/core}/init.py +23 -29
- divi/services/datapark/__init__.py +4 -0
- divi/services/datapark/datapark.py +63 -0
- divi/services/datapark/init.py +5 -0
- divi/services/finish.py +9 -0
- divi/services/init.py +14 -0
- divi/services/service.py +11 -0
- divi/session/__init__.py +3 -0
- divi/session/session.py +40 -0
- divi/session/setup.py +62 -0
- divi/session/teardown.py +7 -0
- divi/signals/__init__.py +3 -0
- divi/signals/trace/__init__.py +3 -0
- divi/signals/trace/trace.py +151 -0
- divi/utils.py +8 -0
- divi-0.0.1.dev14.dist-info/METADATA +17 -0
- divi-0.0.1.dev14.dist-info/RECORD +45 -0
- divi/bin/core +0 -0
- divi/core/__init__.py +0 -5
- divi/core/run.py +0 -35
- divi/proto/core/v1/core.proto +0 -13
- divi/proto/core/v1/core_pb2.py +0 -39
- divi/proto/core/v1/core_pb2.pyi +0 -6
- divi/proto/core/v1/health_check_request.proto +0 -7
- divi/proto/core/v1/health_check_request_pb2.py +0 -37
- divi/proto/core/v1/health_check_request_pb2.pyi +0 -11
- divi/proto/core/v1/health_check_request_pb2_grpc.py +0 -24
- divi/proto/core/v1/health_check_response.proto +0 -10
- divi/proto/core/v1/health_check_response_pb2_grpc.py +0 -24
- divi-0.0.1.dev7.dist-info/METADATA +0 -33
- divi-0.0.1.dev7.dist-info/RECORD +0 -23
- {divi-0.0.1.dev7.dist-info → divi-0.0.1.dev14.dist-info}/WHEEL +0 -0
- {divi-0.0.1.dev7.dist-info → divi-0.0.1.dev14.dist-info}/licenses/LICENSE +0 -0
divi/__init__.py
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
from typing import Optional
|
2
|
-
|
2
|
+
|
3
3
|
from . import proto
|
4
|
+
from .decorators import obs_openai, observable
|
5
|
+
from .services import Auth, Core, DataPark
|
6
|
+
from .session import Session
|
4
7
|
|
5
8
|
name: str = "divi"
|
6
|
-
run: Optional[Run] = None
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
+
_session: Optional[Session] = None
|
11
|
+
_core: Optional[Core] = None
|
12
|
+
_auth: Optional[Auth] = None
|
13
|
+
_datapark: Optional[DataPark] = None
|
14
|
+
|
15
|
+
__version__ = "0.0.1.dev14"
|
16
|
+
__all__ = ["proto", "obs_openai", "observable"]
|
divi/config/config.py
ADDED
File without changes
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import functools
|
2
|
+
from collections.abc import Callable
|
3
|
+
from typing import TYPE_CHECKING, TypeVar, Union
|
4
|
+
|
5
|
+
from divi.decorators.observable import observable
|
6
|
+
from divi.utils import is_async
|
7
|
+
|
8
|
+
if TYPE_CHECKING:
|
9
|
+
from openai import AsyncOpenAI, OpenAI
|
10
|
+
|
11
|
+
C = TypeVar("C", bound=Union["OpenAI", "AsyncOpenAI"])
|
12
|
+
|
13
|
+
|
14
|
+
def _get_observable_create(create: Callable) -> Callable:
|
15
|
+
@functools.wraps(create)
|
16
|
+
def observable_create(*args, stream: bool = False, **kwargs):
|
17
|
+
decorator = observable(kind="llm")
|
18
|
+
return decorator(create)(*args, stream=stream, **kwargs)
|
19
|
+
|
20
|
+
# TODO Async Observable Create
|
21
|
+
print("Is async", is_async(create))
|
22
|
+
return observable_create if not is_async(create) else create
|
23
|
+
|
24
|
+
|
25
|
+
def obs_openai(client: C) -> C:
|
26
|
+
"""Make OpenAI client observable."""
|
27
|
+
client.chat.completions.create = _get_observable_create(
|
28
|
+
client.chat.completions.create
|
29
|
+
)
|
30
|
+
client.completions.create = _get_observable_create(
|
31
|
+
client.completions.create
|
32
|
+
)
|
33
|
+
return client
|
@@ -0,0 +1,137 @@
|
|
1
|
+
import contextvars
|
2
|
+
import functools
|
3
|
+
import inspect
|
4
|
+
from typing import (
|
5
|
+
Any,
|
6
|
+
Callable,
|
7
|
+
Generic,
|
8
|
+
List,
|
9
|
+
Mapping,
|
10
|
+
Optional,
|
11
|
+
ParamSpec,
|
12
|
+
Protocol,
|
13
|
+
TypeVar,
|
14
|
+
Union,
|
15
|
+
overload,
|
16
|
+
runtime_checkable,
|
17
|
+
)
|
18
|
+
|
19
|
+
from openai.types.chat import ChatCompletion
|
20
|
+
|
21
|
+
import divi
|
22
|
+
from divi.proto.trace.v1.trace_pb2 import ScopeSpans
|
23
|
+
from divi.session import SessionExtra
|
24
|
+
from divi.session.setup import setup
|
25
|
+
from divi.signals.trace import Span
|
26
|
+
|
27
|
+
R = TypeVar("R", covariant=True)
|
28
|
+
P = ParamSpec("P")
|
29
|
+
|
30
|
+
# ContextVar to store the extra information
|
31
|
+
# from the Session and parent Span
|
32
|
+
_SESSION_EXTRA = contextvars.ContextVar[Optional[SessionExtra]](
|
33
|
+
"_SESSION_EXTRA", default=None
|
34
|
+
)
|
35
|
+
|
36
|
+
|
37
|
+
@runtime_checkable
|
38
|
+
class WithSessionExtra(Protocol, Generic[P, R]):
|
39
|
+
def __call__(
|
40
|
+
self,
|
41
|
+
*args: P.args,
|
42
|
+
session_extra: Optional[SessionExtra] = None, # type: ignore[valid-type]
|
43
|
+
**kwargs: P.kwargs,
|
44
|
+
) -> R: ...
|
45
|
+
|
46
|
+
|
47
|
+
@overload
|
48
|
+
def observable(func: Callable[P, R]) -> WithSessionExtra[P, R]: ...
|
49
|
+
|
50
|
+
|
51
|
+
@overload
|
52
|
+
def observable(
|
53
|
+
kind: str = "function",
|
54
|
+
*,
|
55
|
+
name: Optional[str] = None,
|
56
|
+
metadata: Optional[Mapping[str, Any]] = None,
|
57
|
+
) -> Callable[[Callable[P, R]], WithSessionExtra[P, R]]: ...
|
58
|
+
|
59
|
+
|
60
|
+
def observable(
|
61
|
+
*args, **kwargs
|
62
|
+
) -> Union[Callable, Callable[[Callable], Callable]]:
|
63
|
+
"""Observable decorator factory."""
|
64
|
+
|
65
|
+
kind = kwargs.pop("kind", "function")
|
66
|
+
name = kwargs.pop("name", None)
|
67
|
+
metadata = kwargs.pop("metadata", None)
|
68
|
+
|
69
|
+
def decorator(func):
|
70
|
+
@functools.wraps(func)
|
71
|
+
def wrapper(
|
72
|
+
*args, session_extra: Optional[SessionExtra] = None, **kwargs
|
73
|
+
):
|
74
|
+
span = Span(
|
75
|
+
kind=kind, name=name or func.__name__, metadata=metadata
|
76
|
+
)
|
77
|
+
session_extra = setup(span, _SESSION_EXTRA.get() or session_extra)
|
78
|
+
# set current context
|
79
|
+
token = _SESSION_EXTRA.set(session_extra)
|
80
|
+
# execute the function
|
81
|
+
span.start()
|
82
|
+
result = func(*args, **kwargs)
|
83
|
+
span.end()
|
84
|
+
# recover parent context
|
85
|
+
_SESSION_EXTRA.reset(token)
|
86
|
+
|
87
|
+
# TODO: collect result
|
88
|
+
# create the span if it is the root span
|
89
|
+
if divi._datapark and span.trace_id:
|
90
|
+
divi._datapark.create_spans(
|
91
|
+
span.trace_id, ScopeSpans(spans=[span.signal])
|
92
|
+
)
|
93
|
+
# end the trace if it is the root span
|
94
|
+
if divi._datapark and not span.parent_span_id:
|
95
|
+
trace = session_extra.get("trace")
|
96
|
+
if trace:
|
97
|
+
trace.end()
|
98
|
+
divi._datapark.upsert_traces(
|
99
|
+
session_id=trace.session_id, traces=[trace.signal]
|
100
|
+
)
|
101
|
+
if divi._datapark and isinstance(result, ChatCompletion):
|
102
|
+
divi._datapark.create_chat_completion(
|
103
|
+
span_id=span.span_id, completion=result
|
104
|
+
)
|
105
|
+
return result
|
106
|
+
|
107
|
+
@functools.wraps(func)
|
108
|
+
def generator_wrapper(
|
109
|
+
*args, session_extra: Optional[SessionExtra] = None, **kwargs
|
110
|
+
):
|
111
|
+
span = Span(
|
112
|
+
kind=kind, name=name or func.__name__, metadata=metadata
|
113
|
+
)
|
114
|
+
session_extra = setup(span, _SESSION_EXTRA.get() or session_extra)
|
115
|
+
# set current context
|
116
|
+
token = _SESSION_EXTRA.set(session_extra)
|
117
|
+
# execute the function
|
118
|
+
results: List[Any] = []
|
119
|
+
span.start()
|
120
|
+
for item in func(*args, **kwargs):
|
121
|
+
results.append(item)
|
122
|
+
yield item
|
123
|
+
span.end()
|
124
|
+
|
125
|
+
# recover parent context
|
126
|
+
_SESSION_EXTRA.reset(token)
|
127
|
+
# TODO: collect results
|
128
|
+
|
129
|
+
if inspect.isgeneratorfunction(func):
|
130
|
+
return generator_wrapper
|
131
|
+
return wrapper
|
132
|
+
|
133
|
+
# Function Decorator
|
134
|
+
if len(args) == 1 and callable(args[0]) and not kwargs:
|
135
|
+
return decorator(args[0])
|
136
|
+
# Factory Decorator
|
137
|
+
return decorator
|
@@ -0,0 +1,49 @@
|
|
1
|
+
syntax = "proto3";
|
2
|
+
|
3
|
+
package divi.proto.common.v1;
|
4
|
+
|
5
|
+
option go_package = "services/pb";
|
6
|
+
|
7
|
+
// AnyValue is used to represent any type of attribute value. AnyValue may contain a
|
8
|
+
// primitive value such as a string or integer or it may contain an arbitrary nested
|
9
|
+
// object containing arrays, key-value lists and primitives.
|
10
|
+
message AnyValue {
|
11
|
+
// The value is one of the listed fields. It is valid for all values to be unspecified
|
12
|
+
// in which case this AnyValue is considered to be "empty".
|
13
|
+
oneof value {
|
14
|
+
string string_value = 1;
|
15
|
+
bool bool_value = 2;
|
16
|
+
int64 int_value = 3;
|
17
|
+
double double_value = 4;
|
18
|
+
ArrayValue array_value = 5;
|
19
|
+
KeyValueList kvlist_value = 6;
|
20
|
+
bytes bytes_value = 7;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
// ArrayValue is a list of AnyValue messages. We need ArrayValue as a message
|
25
|
+
// since oneof in AnyValue does not allow repeated fields.
|
26
|
+
message ArrayValue {
|
27
|
+
// Array of values. The array may be empty (contain 0 elements).
|
28
|
+
repeated AnyValue values = 1;
|
29
|
+
}
|
30
|
+
|
31
|
+
// KeyValueList is a list of KeyValue messages. We need KeyValueList as a message
|
32
|
+
// since `oneof` in AnyValue does not allow repeated fields. Everywhere else where we need
|
33
|
+
// a list of KeyValue messages (e.g. in Span) we use `repeated KeyValue` directly to
|
34
|
+
// avoid unnecessary extra wrapping (which slows down the protocol). The 2 approaches
|
35
|
+
// are semantically equivalent.
|
36
|
+
message KeyValueList {
|
37
|
+
// A collection of key/value pairs of key-value pairs. The list may be empty (may
|
38
|
+
// contain 0 elements).
|
39
|
+
// The keys MUST be unique (it is not allowed to have more than one
|
40
|
+
// value with the same key).
|
41
|
+
repeated KeyValue values = 1;
|
42
|
+
}
|
43
|
+
|
44
|
+
// KeyValue is a key-value pair that is used to store Span attributes, Link
|
45
|
+
// attributes, etc.
|
46
|
+
message KeyValue {
|
47
|
+
string key = 1;
|
48
|
+
AnyValue value = 2;
|
49
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
3
|
+
# NO CHECKED-IN PROTOBUF GENCODE
|
4
|
+
# source: divi/proto/common/v1/common.proto
|
5
|
+
# Protobuf Python Version: 5.29.0
|
6
|
+
"""Generated protocol buffer code."""
|
7
|
+
from google.protobuf import descriptor as _descriptor
|
8
|
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
9
|
+
from google.protobuf import runtime_version as _runtime_version
|
10
|
+
from google.protobuf import symbol_database as _symbol_database
|
11
|
+
from google.protobuf.internal import builder as _builder
|
12
|
+
_runtime_version.ValidateProtobufRuntimeVersion(
|
13
|
+
_runtime_version.Domain.PUBLIC,
|
14
|
+
5,
|
15
|
+
29,
|
16
|
+
0,
|
17
|
+
'',
|
18
|
+
'divi/proto/common/v1/common.proto'
|
19
|
+
)
|
20
|
+
# @@protoc_insertion_point(imports)
|
21
|
+
|
22
|
+
_sym_db = _symbol_database.Default()
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n!divi/proto/common/v1/common.proto\x12\x14\x64ivi.proto.common.v1\"\xfa\x01\n\x08\x41nyValue\x12\x16\n\x0cstring_value\x18\x01 \x01(\tH\x00\x12\x14\n\nbool_value\x18\x02 \x01(\x08H\x00\x12\x13\n\tint_value\x18\x03 \x01(\x03H\x00\x12\x16\n\x0c\x64ouble_value\x18\x04 \x01(\x01H\x00\x12\x37\n\x0b\x61rray_value\x18\x05 \x01(\x0b\x32 .divi.proto.common.v1.ArrayValueH\x00\x12:\n\x0ckvlist_value\x18\x06 \x01(\x0b\x32\".divi.proto.common.v1.KeyValueListH\x00\x12\x15\n\x0b\x62ytes_value\x18\x07 \x01(\x0cH\x00\x42\x07\n\x05value\"<\n\nArrayValue\x12.\n\x06values\x18\x01 \x03(\x0b\x32\x1e.divi.proto.common.v1.AnyValue\">\n\x0cKeyValueList\x12.\n\x06values\x18\x01 \x03(\x0b\x32\x1e.divi.proto.common.v1.KeyValue\"F\n\x08KeyValue\x12\x0b\n\x03key\x18\x01 \x01(\t\x12-\n\x05value\x18\x02 \x01(\x0b\x32\x1e.divi.proto.common.v1.AnyValueB\rZ\x0bservices/pbb\x06proto3')
|
28
|
+
|
29
|
+
_globals = globals()
|
30
|
+
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
31
|
+
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'divi.proto.common.v1.common_pb2', _globals)
|
32
|
+
if not _descriptor._USE_C_DESCRIPTORS:
|
33
|
+
_globals['DESCRIPTOR']._loaded_options = None
|
34
|
+
_globals['DESCRIPTOR']._serialized_options = b'Z\013services/pb'
|
35
|
+
_globals['_ANYVALUE']._serialized_start=60
|
36
|
+
_globals['_ANYVALUE']._serialized_end=310
|
37
|
+
_globals['_ARRAYVALUE']._serialized_start=312
|
38
|
+
_globals['_ARRAYVALUE']._serialized_end=372
|
39
|
+
_globals['_KEYVALUELIST']._serialized_start=374
|
40
|
+
_globals['_KEYVALUELIST']._serialized_end=436
|
41
|
+
_globals['_KEYVALUE']._serialized_start=438
|
42
|
+
_globals['_KEYVALUE']._serialized_end=508
|
43
|
+
# @@protoc_insertion_point(module_scope)
|
@@ -0,0 +1,44 @@
|
|
1
|
+
from google.protobuf.internal import containers as _containers
|
2
|
+
from google.protobuf import descriptor as _descriptor
|
3
|
+
from google.protobuf import message as _message
|
4
|
+
from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union
|
5
|
+
|
6
|
+
DESCRIPTOR: _descriptor.FileDescriptor
|
7
|
+
|
8
|
+
class AnyValue(_message.Message):
|
9
|
+
__slots__ = ("string_value", "bool_value", "int_value", "double_value", "array_value", "kvlist_value", "bytes_value")
|
10
|
+
STRING_VALUE_FIELD_NUMBER: _ClassVar[int]
|
11
|
+
BOOL_VALUE_FIELD_NUMBER: _ClassVar[int]
|
12
|
+
INT_VALUE_FIELD_NUMBER: _ClassVar[int]
|
13
|
+
DOUBLE_VALUE_FIELD_NUMBER: _ClassVar[int]
|
14
|
+
ARRAY_VALUE_FIELD_NUMBER: _ClassVar[int]
|
15
|
+
KVLIST_VALUE_FIELD_NUMBER: _ClassVar[int]
|
16
|
+
BYTES_VALUE_FIELD_NUMBER: _ClassVar[int]
|
17
|
+
string_value: str
|
18
|
+
bool_value: bool
|
19
|
+
int_value: int
|
20
|
+
double_value: float
|
21
|
+
array_value: ArrayValue
|
22
|
+
kvlist_value: KeyValueList
|
23
|
+
bytes_value: bytes
|
24
|
+
def __init__(self, string_value: _Optional[str] = ..., bool_value: bool = ..., int_value: _Optional[int] = ..., double_value: _Optional[float] = ..., array_value: _Optional[_Union[ArrayValue, _Mapping]] = ..., kvlist_value: _Optional[_Union[KeyValueList, _Mapping]] = ..., bytes_value: _Optional[bytes] = ...) -> None: ...
|
25
|
+
|
26
|
+
class ArrayValue(_message.Message):
|
27
|
+
__slots__ = ("values",)
|
28
|
+
VALUES_FIELD_NUMBER: _ClassVar[int]
|
29
|
+
values: _containers.RepeatedCompositeFieldContainer[AnyValue]
|
30
|
+
def __init__(self, values: _Optional[_Iterable[_Union[AnyValue, _Mapping]]] = ...) -> None: ...
|
31
|
+
|
32
|
+
class KeyValueList(_message.Message):
|
33
|
+
__slots__ = ("values",)
|
34
|
+
VALUES_FIELD_NUMBER: _ClassVar[int]
|
35
|
+
values: _containers.RepeatedCompositeFieldContainer[KeyValue]
|
36
|
+
def __init__(self, values: _Optional[_Iterable[_Union[KeyValue, _Mapping]]] = ...) -> None: ...
|
37
|
+
|
38
|
+
class KeyValue(_message.Message):
|
39
|
+
__slots__ = ("key", "value")
|
40
|
+
KEY_FIELD_NUMBER: _ClassVar[int]
|
41
|
+
VALUE_FIELD_NUMBER: _ClassVar[int]
|
42
|
+
key: str
|
43
|
+
value: AnyValue
|
44
|
+
def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[AnyValue, _Mapping]] = ...) -> None: ...
|
@@ -0,0 +1,17 @@
|
|
1
|
+
syntax = "proto3";
|
2
|
+
|
3
|
+
package divi.proto.core.health.v1;
|
4
|
+
|
5
|
+
option go_package = "services/pb";
|
6
|
+
|
7
|
+
// HealthService is a service that implements health check.
|
8
|
+
service HealthService {
|
9
|
+
rpc Check(HealthCheckRequest) returns (HealthCheckResponse) {}
|
10
|
+
}
|
11
|
+
|
12
|
+
message HealthCheckRequest { string version = 1; }
|
13
|
+
|
14
|
+
message HealthCheckResponse {
|
15
|
+
bool status = 1;
|
16
|
+
string message = 2;
|
17
|
+
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
3
3
|
# NO CHECKED-IN PROTOBUF GENCODE
|
4
|
-
# source: divi/proto/core/v1/
|
4
|
+
# source: divi/proto/core/health/v1/health_service.proto
|
5
5
|
# Protobuf Python Version: 5.29.0
|
6
6
|
"""Generated protocol buffer code."""
|
7
7
|
from google.protobuf import descriptor as _descriptor
|
@@ -15,7 +15,7 @@ _runtime_version.ValidateProtobufRuntimeVersion(
|
|
15
15
|
29,
|
16
16
|
0,
|
17
17
|
'',
|
18
|
-
'divi/proto/core/v1/
|
18
|
+
'divi/proto/core/health/v1/health_service.proto'
|
19
19
|
)
|
20
20
|
# @@protoc_insertion_point(imports)
|
21
21
|
|
@@ -24,14 +24,18 @@ _sym_db = _symbol_database.Default()
|
|
24
24
|
|
25
25
|
|
26
26
|
|
27
|
-
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n.divi/proto/core/v1/
|
27
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n.divi/proto/core/health/v1/health_service.proto\x12\x19\x64ivi.proto.core.health.v1\"%\n\x12HealthCheckRequest\x12\x0f\n\x07version\x18\x01 \x01(\t\"6\n\x13HealthCheckResponse\x12\x0e\n\x06status\x18\x01 \x01(\x08\x12\x0f\n\x07message\x18\x02 \x01(\t2y\n\rHealthService\x12h\n\x05\x43heck\x12-.divi.proto.core.health.v1.HealthCheckRequest\x1a..divi.proto.core.health.v1.HealthCheckResponse\"\x00\x42\rZ\x0bservices/pbb\x06proto3')
|
28
28
|
|
29
29
|
_globals = globals()
|
30
30
|
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
31
|
-
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'divi.proto.core.v1.
|
31
|
+
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'divi.proto.core.health.v1.health_service_pb2', _globals)
|
32
32
|
if not _descriptor._USE_C_DESCRIPTORS:
|
33
33
|
_globals['DESCRIPTOR']._loaded_options = None
|
34
|
-
_globals['DESCRIPTOR']._serialized_options = b'
|
35
|
-
_globals['
|
36
|
-
_globals['
|
34
|
+
_globals['DESCRIPTOR']._serialized_options = b'Z\013services/pb'
|
35
|
+
_globals['_HEALTHCHECKREQUEST']._serialized_start=77
|
36
|
+
_globals['_HEALTHCHECKREQUEST']._serialized_end=114
|
37
|
+
_globals['_HEALTHCHECKRESPONSE']._serialized_start=116
|
38
|
+
_globals['_HEALTHCHECKRESPONSE']._serialized_end=170
|
39
|
+
_globals['_HEALTHSERVICE']._serialized_start=172
|
40
|
+
_globals['_HEALTHSERVICE']._serialized_end=293
|
37
41
|
# @@protoc_insertion_point(module_scope)
|
@@ -4,6 +4,12 @@ from typing import ClassVar as _ClassVar, Optional as _Optional
|
|
4
4
|
|
5
5
|
DESCRIPTOR: _descriptor.FileDescriptor
|
6
6
|
|
7
|
+
class HealthCheckRequest(_message.Message):
|
8
|
+
__slots__ = ("version",)
|
9
|
+
VERSION_FIELD_NUMBER: _ClassVar[int]
|
10
|
+
version: str
|
11
|
+
def __init__(self, version: _Optional[str] = ...) -> None: ...
|
12
|
+
|
7
13
|
class HealthCheckResponse(_message.Message):
|
8
14
|
__slots__ = ("status", "message")
|
9
15
|
STATUS_FIELD_NUMBER: _ClassVar[int]
|
@@ -3,8 +3,7 @@
|
|
3
3
|
import grpc
|
4
4
|
import warnings
|
5
5
|
|
6
|
-
from divi.proto.core.v1 import
|
7
|
-
from divi.proto.core.v1 import health_check_response_pb2 as divi_dot_proto_dot_core_dot_v1_dot_health__check__response__pb2
|
6
|
+
from divi.proto.core.health.v1 import health_service_pb2 as divi_dot_proto_dot_core_dot_health_dot_v1_dot_health__service__pb2
|
8
7
|
|
9
8
|
GRPC_GENERATED_VERSION = '1.69.0'
|
10
9
|
GRPC_VERSION = grpc.__version__
|
@@ -19,15 +18,15 @@ except ImportError:
|
|
19
18
|
if _version_not_supported:
|
20
19
|
raise RuntimeError(
|
21
20
|
f'The grpc package installed is at version {GRPC_VERSION},'
|
22
|
-
+ f' but the generated code in divi/proto/core/v1/
|
21
|
+
+ f' but the generated code in divi/proto/core/health/v1/health_service_pb2_grpc.py depends on'
|
23
22
|
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
|
24
23
|
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
|
25
24
|
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
|
26
25
|
)
|
27
26
|
|
28
27
|
|
29
|
-
class
|
30
|
-
"""
|
28
|
+
class HealthServiceStub(object):
|
29
|
+
"""HealthService is a service that implements health check.
|
31
30
|
"""
|
32
31
|
|
33
32
|
def __init__(self, channel):
|
@@ -37,14 +36,14 @@ class CoreStub(object):
|
|
37
36
|
channel: A grpc.Channel.
|
38
37
|
"""
|
39
38
|
self.Check = channel.unary_unary(
|
40
|
-
'/core.v1.
|
41
|
-
request_serializer=
|
42
|
-
response_deserializer=
|
39
|
+
'/divi.proto.core.health.v1.HealthService/Check',
|
40
|
+
request_serializer=divi_dot_proto_dot_core_dot_health_dot_v1_dot_health__service__pb2.HealthCheckRequest.SerializeToString,
|
41
|
+
response_deserializer=divi_dot_proto_dot_core_dot_health_dot_v1_dot_health__service__pb2.HealthCheckResponse.FromString,
|
43
42
|
_registered_method=True)
|
44
43
|
|
45
44
|
|
46
|
-
class
|
47
|
-
"""
|
45
|
+
class HealthServiceServicer(object):
|
46
|
+
"""HealthService is a service that implements health check.
|
48
47
|
"""
|
49
48
|
|
50
49
|
def Check(self, request, context):
|
@@ -54,23 +53,23 @@ class CoreServicer(object):
|
|
54
53
|
raise NotImplementedError('Method not implemented!')
|
55
54
|
|
56
55
|
|
57
|
-
def
|
56
|
+
def add_HealthServiceServicer_to_server(servicer, server):
|
58
57
|
rpc_method_handlers = {
|
59
58
|
'Check': grpc.unary_unary_rpc_method_handler(
|
60
59
|
servicer.Check,
|
61
|
-
request_deserializer=
|
62
|
-
response_serializer=
|
60
|
+
request_deserializer=divi_dot_proto_dot_core_dot_health_dot_v1_dot_health__service__pb2.HealthCheckRequest.FromString,
|
61
|
+
response_serializer=divi_dot_proto_dot_core_dot_health_dot_v1_dot_health__service__pb2.HealthCheckResponse.SerializeToString,
|
63
62
|
),
|
64
63
|
}
|
65
64
|
generic_handler = grpc.method_handlers_generic_handler(
|
66
|
-
'core.v1.
|
65
|
+
'divi.proto.core.health.v1.HealthService', rpc_method_handlers)
|
67
66
|
server.add_generic_rpc_handlers((generic_handler,))
|
68
|
-
server.add_registered_method_handlers('core.v1.
|
67
|
+
server.add_registered_method_handlers('divi.proto.core.health.v1.HealthService', rpc_method_handlers)
|
69
68
|
|
70
69
|
|
71
70
|
# This class is part of an EXPERIMENTAL API.
|
72
|
-
class
|
73
|
-
"""
|
71
|
+
class HealthService(object):
|
72
|
+
"""HealthService is a service that implements health check.
|
74
73
|
"""
|
75
74
|
|
76
75
|
@staticmethod
|
@@ -87,9 +86,9 @@ class Core(object):
|
|
87
86
|
return grpc.experimental.unary_unary(
|
88
87
|
request,
|
89
88
|
target,
|
90
|
-
'/core.v1.
|
91
|
-
|
92
|
-
|
89
|
+
'/divi.proto.core.health.v1.HealthService/Check',
|
90
|
+
divi_dot_proto_dot_core_dot_health_dot_v1_dot_health__service__pb2.HealthCheckRequest.SerializeToString,
|
91
|
+
divi_dot_proto_dot_core_dot_health_dot_v1_dot_health__service__pb2.HealthCheckResponse.FromString,
|
93
92
|
options,
|
94
93
|
channel_credentials,
|
95
94
|
insecure,
|
@@ -0,0 +1,26 @@
|
|
1
|
+
syntax = "proto3";
|
2
|
+
|
3
|
+
package divi.proto.metric.v1;
|
4
|
+
|
5
|
+
import "divi/proto/common/v1/common.proto";
|
6
|
+
|
7
|
+
option go_package = "services/pb";
|
8
|
+
|
9
|
+
message ScopeMetrics {
|
10
|
+
// A list of spans that originate from a resource.
|
11
|
+
repeated Metric metrics = 2;
|
12
|
+
}
|
13
|
+
|
14
|
+
message Metric {
|
15
|
+
// The name of the metric.
|
16
|
+
string name = 1;
|
17
|
+
|
18
|
+
// The description of the metric.
|
19
|
+
string description = 2;
|
20
|
+
|
21
|
+
// The data of the metric.
|
22
|
+
divi.proto.common.v1.AnyValue data = 3;
|
23
|
+
|
24
|
+
// The metadata is a set of attributes that describe the span.
|
25
|
+
repeated divi.proto.common.v1.KeyValue metadata = 4;
|
26
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
3
|
+
# NO CHECKED-IN PROTOBUF GENCODE
|
4
|
+
# source: divi/proto/metric/v1/metric.proto
|
5
|
+
# Protobuf Python Version: 5.29.0
|
6
|
+
"""Generated protocol buffer code."""
|
7
|
+
from google.protobuf import descriptor as _descriptor
|
8
|
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
9
|
+
from google.protobuf import runtime_version as _runtime_version
|
10
|
+
from google.protobuf import symbol_database as _symbol_database
|
11
|
+
from google.protobuf.internal import builder as _builder
|
12
|
+
_runtime_version.ValidateProtobufRuntimeVersion(
|
13
|
+
_runtime_version.Domain.PUBLIC,
|
14
|
+
5,
|
15
|
+
29,
|
16
|
+
0,
|
17
|
+
'',
|
18
|
+
'divi/proto/metric/v1/metric.proto'
|
19
|
+
)
|
20
|
+
# @@protoc_insertion_point(imports)
|
21
|
+
|
22
|
+
_sym_db = _symbol_database.Default()
|
23
|
+
|
24
|
+
|
25
|
+
from divi.proto.common.v1 import common_pb2 as divi_dot_proto_dot_common_dot_v1_dot_common__pb2
|
26
|
+
|
27
|
+
|
28
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n!divi/proto/metric/v1/metric.proto\x12\x14\x64ivi.proto.metric.v1\x1a!divi/proto/common/v1/common.proto\"=\n\x0cScopeMetrics\x12-\n\x07metrics\x18\x02 \x03(\x0b\x32\x1c.divi.proto.metric.v1.Metric\"\x8b\x01\n\x06Metric\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x02 \x01(\t\x12,\n\x04\x64\x61ta\x18\x03 \x01(\x0b\x32\x1e.divi.proto.common.v1.AnyValue\x12\x30\n\x08metadata\x18\x04 \x03(\x0b\x32\x1e.divi.proto.common.v1.KeyValueB\rZ\x0bservices/pbb\x06proto3')
|
29
|
+
|
30
|
+
_globals = globals()
|
31
|
+
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
32
|
+
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'divi.proto.metric.v1.metric_pb2', _globals)
|
33
|
+
if not _descriptor._USE_C_DESCRIPTORS:
|
34
|
+
_globals['DESCRIPTOR']._loaded_options = None
|
35
|
+
_globals['DESCRIPTOR']._serialized_options = b'Z\013services/pb'
|
36
|
+
_globals['_SCOPEMETRICS']._serialized_start=94
|
37
|
+
_globals['_SCOPEMETRICS']._serialized_end=155
|
38
|
+
_globals['_METRIC']._serialized_start=158
|
39
|
+
_globals['_METRIC']._serialized_end=297
|
40
|
+
# @@protoc_insertion_point(module_scope)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
from divi.proto.common.v1 import common_pb2 as _common_pb2
|
2
|
+
from google.protobuf.internal import containers as _containers
|
3
|
+
from google.protobuf import descriptor as _descriptor
|
4
|
+
from google.protobuf import message as _message
|
5
|
+
from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union
|
6
|
+
|
7
|
+
DESCRIPTOR: _descriptor.FileDescriptor
|
8
|
+
|
9
|
+
class ScopeMetrics(_message.Message):
|
10
|
+
__slots__ = ("metrics",)
|
11
|
+
METRICS_FIELD_NUMBER: _ClassVar[int]
|
12
|
+
metrics: _containers.RepeatedCompositeFieldContainer[Metric]
|
13
|
+
def __init__(self, metrics: _Optional[_Iterable[_Union[Metric, _Mapping]]] = ...) -> None: ...
|
14
|
+
|
15
|
+
class Metric(_message.Message):
|
16
|
+
__slots__ = ("name", "description", "data", "metadata")
|
17
|
+
NAME_FIELD_NUMBER: _ClassVar[int]
|
18
|
+
DESCRIPTION_FIELD_NUMBER: _ClassVar[int]
|
19
|
+
DATA_FIELD_NUMBER: _ClassVar[int]
|
20
|
+
METADATA_FIELD_NUMBER: _ClassVar[int]
|
21
|
+
name: str
|
22
|
+
description: str
|
23
|
+
data: _common_pb2.AnyValue
|
24
|
+
metadata: _containers.RepeatedCompositeFieldContainer[_common_pb2.KeyValue]
|
25
|
+
def __init__(self, name: _Optional[str] = ..., description: _Optional[str] = ..., data: _Optional[_Union[_common_pb2.AnyValue, _Mapping]] = ..., metadata: _Optional[_Iterable[_Union[_common_pb2.KeyValue, _Mapping]]] = ...) -> None: ...
|
@@ -0,0 +1,47 @@
|
|
1
|
+
syntax = "proto3";
|
2
|
+
|
3
|
+
package divi.proto.trace.v1;
|
4
|
+
|
5
|
+
import "divi/proto/common/v1/common.proto";
|
6
|
+
|
7
|
+
option go_package = "services/pb";
|
8
|
+
|
9
|
+
message ScopeSpans {
|
10
|
+
// A list of spans that originate from a resource.
|
11
|
+
repeated Span spans = 2;
|
12
|
+
}
|
13
|
+
|
14
|
+
message Span {
|
15
|
+
// The trace_id is a unique identifier that represents a trace. It is a 16-byte array.
|
16
|
+
bytes trace_id = 1;
|
17
|
+
|
18
|
+
// The span_id is a unique identifier that represents a span. It is an 8-byte array.
|
19
|
+
bytes span_id = 2;
|
20
|
+
|
21
|
+
// The parent_span_id is the span_id of the parent span. It is an 8-byte array.
|
22
|
+
bytes parent_span_id = 3;
|
23
|
+
|
24
|
+
// The name of the span.
|
25
|
+
string name = 4;
|
26
|
+
|
27
|
+
// SpanKind is the type of the span.
|
28
|
+
enum SpanKind {
|
29
|
+
// Function represents a function call.
|
30
|
+
SPAN_KIND_FUNCTION = 0;
|
31
|
+
|
32
|
+
// LLM represents a llm api call.
|
33
|
+
SPAN_KIND_LLM = 1;
|
34
|
+
}
|
35
|
+
|
36
|
+
// The kind of the span.
|
37
|
+
SpanKind kind = 5;
|
38
|
+
|
39
|
+
// The start_time_unix_nano is the start time of the span in Unix nanoseconds.
|
40
|
+
fixed64 start_time_unix_nano = 6;
|
41
|
+
|
42
|
+
// The end_time_unix_nano is the end time of the span in Unix nanoseconds.
|
43
|
+
fixed64 end_time_unix_nano = 7;
|
44
|
+
|
45
|
+
// The metadata is a set of attributes that describe the span.
|
46
|
+
repeated divi.proto.common.v1.KeyValue metadata = 8;
|
47
|
+
}
|