mantisdk 0.1.1__py3-none-any.whl → 0.1.3__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.
mantisdk/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) Microsoft. All rights reserved.
2
2
 
3
- __version__ = "0.1.1"
3
+ __version__ = "0.1.3"
4
4
 
5
5
  from .adapter import *
6
6
  from .algorithm import *
@@ -0,0 +1,66 @@
1
+ # Copyright (c) Metis. All rights reserved.
2
+
3
+ """Standalone tracing module for MantisDK.
4
+
5
+ This module provides a "one-liner" entry point for instrumenting applications
6
+ with OpenTelemetry, compatible with OpenInference ecosystem,
7
+ while natively supporting export to Mantis Insight.
8
+
9
+ Example usage::
10
+
11
+ import mantisdk.tracing as tracing
12
+
13
+ # Auto-detect Insight from environment variables
14
+ tracing.init()
15
+
16
+ # Use as a decorator (auto-captures input/output)
17
+ @tracing.trace
18
+ def my_function(query: str) -> dict:
19
+ return {"result": query.upper()}
20
+
21
+ # Use as a context manager (explicit input/output)
22
+ with tracing.trace("my-workflow", input=query) as span:
23
+ result = do_work()
24
+ span.set_attribute(tracing.semconv.TRACE_OUTPUT, result)
25
+
26
+ # Use semantic conventions for rich metadata
27
+ span.set_attribute(tracing.semconv.USER_ID, "user-123")
28
+ span.set_attribute(tracing.semconv.SESSION_ID, "session-456")
29
+
30
+ # Ensure spans are flushed on shutdown
31
+ tracing.shutdown()
32
+
33
+ Environment variables for Insight auto-detect:
34
+ - INSIGHT_HOST: The Insight server URL (e.g., "https://insight.withmetis.ai")
35
+ - INSIGHT_PUBLIC_KEY: The public key for authentication (pk-lf-...)
36
+ - INSIGHT_SECRET_KEY: The secret key for authentication (sk-lf-...)
37
+ - INSIGHT_OTLP_ENDPOINT: Optional override for the OTLP endpoint
38
+ """
39
+
40
+ from .init import init, instrument, shutdown, flush
41
+ from .api import trace, span, tool, atrace, aspan, get_current_span
42
+ from . import semconv
43
+
44
+ # Re-export exporter factory for explicit configuration
45
+ from .exporters.insight import insight as insight_exporter
46
+
47
+ __all__ = [
48
+ # Initialization
49
+ "init",
50
+ "instrument",
51
+ "shutdown",
52
+ "flush",
53
+ # Context managers / decorators (sync)
54
+ "trace",
55
+ "span",
56
+ "tool",
57
+ # Context managers (async)
58
+ "atrace",
59
+ "aspan",
60
+ # Span utilities
61
+ "get_current_span",
62
+ # Semantic conventions
63
+ "semconv",
64
+ # Exporter factory
65
+ "insight_exporter",
66
+ ]