netra-sdk 0.1.0__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.
Potentially problematic release.
This version of netra-sdk might be problematic. Click here for more details.
- netra/__init__.py +148 -0
- netra/anonymizer/__init__.py +7 -0
- netra/anonymizer/anonymizer.py +79 -0
- netra/anonymizer/base.py +159 -0
- netra/anonymizer/fp_anonymizer.py +182 -0
- netra/config.py +111 -0
- netra/decorators.py +167 -0
- netra/exceptions/__init__.py +6 -0
- netra/exceptions/injection.py +33 -0
- netra/exceptions/pii.py +46 -0
- netra/input_scanner.py +142 -0
- netra/instrumentation/__init__.py +257 -0
- netra/instrumentation/aiohttp/__init__.py +378 -0
- netra/instrumentation/aiohttp/version.py +1 -0
- netra/instrumentation/cohere/__init__.py +446 -0
- netra/instrumentation/cohere/version.py +1 -0
- netra/instrumentation/google_genai/__init__.py +506 -0
- netra/instrumentation/google_genai/config.py +5 -0
- netra/instrumentation/google_genai/utils.py +31 -0
- netra/instrumentation/google_genai/version.py +1 -0
- netra/instrumentation/httpx/__init__.py +545 -0
- netra/instrumentation/httpx/version.py +1 -0
- netra/instrumentation/instruments.py +78 -0
- netra/instrumentation/mistralai/__init__.py +545 -0
- netra/instrumentation/mistralai/config.py +5 -0
- netra/instrumentation/mistralai/utils.py +30 -0
- netra/instrumentation/mistralai/version.py +1 -0
- netra/instrumentation/weaviate/__init__.py +121 -0
- netra/instrumentation/weaviate/version.py +1 -0
- netra/pii.py +757 -0
- netra/processors/__init__.py +4 -0
- netra/processors/session_span_processor.py +55 -0
- netra/processors/span_aggregation_processor.py +365 -0
- netra/scanner.py +104 -0
- netra/session.py +185 -0
- netra/session_manager.py +96 -0
- netra/tracer.py +99 -0
- netra/version.py +1 -0
- netra_sdk-0.1.0.dist-info/LICENCE +201 -0
- netra_sdk-0.1.0.dist-info/METADATA +573 -0
- netra_sdk-0.1.0.dist-info/RECORD +42 -0
- netra_sdk-0.1.0.dist-info/WHEEL +4 -0
netra/session.py
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import time
|
|
3
|
+
from typing import Any, Dict, Literal, Optional
|
|
4
|
+
|
|
5
|
+
from opentelemetry import context as context_api
|
|
6
|
+
from opentelemetry import trace
|
|
7
|
+
from opentelemetry.trace import SpanKind, Status, StatusCode
|
|
8
|
+
from opentelemetry.trace.propagation import set_span_in_context
|
|
9
|
+
|
|
10
|
+
# Configure logging
|
|
11
|
+
logging.basicConfig(level=logging.INFO)
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ATTRIBUTE:
|
|
16
|
+
LLM_SYSTEM = "llm_system"
|
|
17
|
+
MODEL = "model"
|
|
18
|
+
PROMPT = "prompt"
|
|
19
|
+
NEGATIVE_PROMPT = "negative_prompt"
|
|
20
|
+
IMAGE_HEIGHT = "image_height"
|
|
21
|
+
IMAGE_WIDTH = "image_width"
|
|
22
|
+
TOKENS = "tokens"
|
|
23
|
+
CREDITS = "credits"
|
|
24
|
+
COST = "cost"
|
|
25
|
+
STATUS = "status"
|
|
26
|
+
DURATION_MS = "duration_ms"
|
|
27
|
+
ERROR_MESSAGE = "error_message"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class Session:
|
|
31
|
+
"""
|
|
32
|
+
Context manager for tracking observability data for external API calls.
|
|
33
|
+
|
|
34
|
+
Usage:
|
|
35
|
+
with combat.start_session("video_gen_task") as session:
|
|
36
|
+
session.set_prompt("A cat playing piano").set_image_height("1024")
|
|
37
|
+
|
|
38
|
+
# External API call
|
|
39
|
+
result = external_api.generate_video(...)
|
|
40
|
+
|
|
41
|
+
session.set_tokens("20").set_credits("30")
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
def __init__(self, name: str, attributes: Optional[Dict[str, str]] = None, module_name: str = "combat_sdk"):
|
|
45
|
+
self.name = name
|
|
46
|
+
self.attributes = attributes or {}
|
|
47
|
+
self.start_time: Optional[float] = None
|
|
48
|
+
self.end_time: Optional[float] = None
|
|
49
|
+
self.status = "pending"
|
|
50
|
+
self.error_message: Optional[str] = None
|
|
51
|
+
self.module_name = module_name
|
|
52
|
+
|
|
53
|
+
# OpenTelemetry span management
|
|
54
|
+
self.tracer = trace.get_tracer(module_name)
|
|
55
|
+
self.span: Optional[trace.Span] = None
|
|
56
|
+
self.context_token: Optional[Any] = None
|
|
57
|
+
|
|
58
|
+
def __enter__(self) -> "Session":
|
|
59
|
+
"""Start the session, begin time tracking, and create OpenTelemetry span."""
|
|
60
|
+
self.start_time = time.time()
|
|
61
|
+
|
|
62
|
+
# Create OpenTelemetry span
|
|
63
|
+
self.span = self.tracer.start_span(name=self.name, kind=SpanKind.CLIENT, attributes=self.attributes)
|
|
64
|
+
|
|
65
|
+
# Set span in context
|
|
66
|
+
ctx = set_span_in_context(self.span)
|
|
67
|
+
self.context_token = context_api.attach(ctx)
|
|
68
|
+
|
|
69
|
+
logger.info(f"Started session: {self.name}")
|
|
70
|
+
return self
|
|
71
|
+
|
|
72
|
+
def __exit__(self, exc_type: Optional[type], exc_val: Optional[Exception], exc_tb: Any) -> Literal[False]:
|
|
73
|
+
"""End the session, calculate duration, handle errors, and close OpenTelemetry span."""
|
|
74
|
+
self.end_time = time.time()
|
|
75
|
+
duration_ms = (self.end_time - self.start_time) * 1000 if self.start_time is not None else None
|
|
76
|
+
|
|
77
|
+
# Set duration
|
|
78
|
+
if duration_ms is not None:
|
|
79
|
+
self.set_attribute(ATTRIBUTE.DURATION_MS, str(round(duration_ms, 2)))
|
|
80
|
+
|
|
81
|
+
# Handle status and errors
|
|
82
|
+
if exc_type is None and self.status == "pending":
|
|
83
|
+
self.status = "success"
|
|
84
|
+
if self.span:
|
|
85
|
+
self.span.set_status(Status(StatusCode.OK))
|
|
86
|
+
elif exc_type is not None:
|
|
87
|
+
self.status = "error"
|
|
88
|
+
self.error_message = str(exc_val)
|
|
89
|
+
self.set_attribute(ATTRIBUTE.ERROR_MESSAGE, self.error_message)
|
|
90
|
+
if self.span:
|
|
91
|
+
self.span.set_status(Status(StatusCode.ERROR, self.error_message))
|
|
92
|
+
if exc_val is not None:
|
|
93
|
+
self.span.record_exception(exc_val)
|
|
94
|
+
logger.error(f"Session {self.name} failed: {self.error_message}")
|
|
95
|
+
|
|
96
|
+
self.set_attribute(ATTRIBUTE.STATUS, self.status)
|
|
97
|
+
|
|
98
|
+
# Update span attributes with final values
|
|
99
|
+
if self.span:
|
|
100
|
+
for key, value in self.attributes.items():
|
|
101
|
+
self.span.set_attribute(key, value)
|
|
102
|
+
|
|
103
|
+
# End OpenTelemetry span and detach context
|
|
104
|
+
if self.span:
|
|
105
|
+
self.span.end()
|
|
106
|
+
if self.context_token:
|
|
107
|
+
context_api.detach(self.context_token)
|
|
108
|
+
|
|
109
|
+
logger.info(
|
|
110
|
+
f"Ended session: {self.name} (Status: {self.status}, Duration: {duration_ms:.2f}ms)"
|
|
111
|
+
if duration_ms is not None
|
|
112
|
+
else f"Ended session: {self.name} (Status: {self.status})"
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
# Don't suppress exceptions
|
|
116
|
+
return False
|
|
117
|
+
|
|
118
|
+
def set_attribute(self, key: str, value: str) -> "Session":
|
|
119
|
+
"""Set a single attribute and return self for method chaining."""
|
|
120
|
+
self.attributes[key] = value
|
|
121
|
+
# Also set on the span if it exists
|
|
122
|
+
if self.span:
|
|
123
|
+
self.span.set_attribute(key, value)
|
|
124
|
+
return self
|
|
125
|
+
|
|
126
|
+
def set_prompt(self, prompt: str) -> "Session":
|
|
127
|
+
"""Set the input prompt."""
|
|
128
|
+
return self.set_attribute(ATTRIBUTE.PROMPT, prompt)
|
|
129
|
+
|
|
130
|
+
def set_negative_prompt(self, negative_prompt: str) -> "Session":
|
|
131
|
+
"""Set the negative prompt."""
|
|
132
|
+
return self.set_attribute(ATTRIBUTE.NEGATIVE_PROMPT, negative_prompt)
|
|
133
|
+
|
|
134
|
+
def set_image_height(self, height: str) -> "Session":
|
|
135
|
+
"""Set the image height."""
|
|
136
|
+
return self.set_attribute(ATTRIBUTE.IMAGE_HEIGHT, height)
|
|
137
|
+
|
|
138
|
+
def set_image_width(self, width: str) -> "Session":
|
|
139
|
+
"""Set the image width."""
|
|
140
|
+
return self.set_attribute(ATTRIBUTE.IMAGE_WIDTH, width)
|
|
141
|
+
|
|
142
|
+
def set_tokens(self, tokens: str) -> "Session":
|
|
143
|
+
"""Set the number of tokens used."""
|
|
144
|
+
return self.set_attribute(ATTRIBUTE.TOKENS, tokens)
|
|
145
|
+
|
|
146
|
+
def set_credits(self, credits: str) -> "Session":
|
|
147
|
+
"""Set the number of credits used."""
|
|
148
|
+
return self.set_attribute(ATTRIBUTE.CREDITS, credits)
|
|
149
|
+
|
|
150
|
+
def set_cost(self, cost: str) -> "Session":
|
|
151
|
+
"""Set the cost of the operation."""
|
|
152
|
+
return self.set_attribute(ATTRIBUTE.COST, cost)
|
|
153
|
+
|
|
154
|
+
def set_model(self, model: str) -> "Session":
|
|
155
|
+
"""Set the model used."""
|
|
156
|
+
return self.set_attribute(ATTRIBUTE.MODEL, model)
|
|
157
|
+
|
|
158
|
+
def set_llm_system(self, system: str) -> "Session":
|
|
159
|
+
"""Set the LLM system used."""
|
|
160
|
+
return self.set_attribute(ATTRIBUTE.LLM_SYSTEM, system)
|
|
161
|
+
|
|
162
|
+
def set_error(self, error_message: str) -> "Session":
|
|
163
|
+
"""Manually set an error message."""
|
|
164
|
+
self.status = "error"
|
|
165
|
+
self.error_message = error_message
|
|
166
|
+
if self.span:
|
|
167
|
+
self.span.set_status(Status(StatusCode.ERROR, error_message))
|
|
168
|
+
return self.set_attribute(ATTRIBUTE.ERROR_MESSAGE, error_message)
|
|
169
|
+
|
|
170
|
+
def set_success(self) -> "Session":
|
|
171
|
+
"""Manually mark the session as successful."""
|
|
172
|
+
self.status = "success"
|
|
173
|
+
if self.span:
|
|
174
|
+
self.span.set_status(Status(StatusCode.OK))
|
|
175
|
+
return self
|
|
176
|
+
|
|
177
|
+
def add_event(self, name: str, attributes: Optional[Dict[str, str]] = None) -> "Session":
|
|
178
|
+
"""Add an event to the span."""
|
|
179
|
+
if self.span:
|
|
180
|
+
self.span.add_event(name, attributes or {})
|
|
181
|
+
return self
|
|
182
|
+
|
|
183
|
+
def get_current_span(self) -> Optional[trace.Span]:
|
|
184
|
+
"""Get the current OpenTelemetry span."""
|
|
185
|
+
return self.span
|
netra/session_manager.py
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Session management for PromptOps SDK.
|
|
3
|
+
Handles automatic session and user ID management for applications.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import logging
|
|
7
|
+
from datetime import datetime
|
|
8
|
+
from typing import Any, Dict, Optional, Union
|
|
9
|
+
|
|
10
|
+
from opentelemetry import baggage
|
|
11
|
+
from opentelemetry import context as otel_context
|
|
12
|
+
from opentelemetry import trace
|
|
13
|
+
|
|
14
|
+
from .config import Config
|
|
15
|
+
|
|
16
|
+
logger = logging.getLogger(__name__)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class SessionManager:
|
|
20
|
+
"""Manages session and user context for applications."""
|
|
21
|
+
|
|
22
|
+
# Class variable to track the current span
|
|
23
|
+
_current_span: Optional[trace.Span] = None
|
|
24
|
+
|
|
25
|
+
@classmethod
|
|
26
|
+
def set_current_span(cls, span: Optional[trace.Span]) -> None:
|
|
27
|
+
"""
|
|
28
|
+
Set the current span for the session manager.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
span: The current span to store
|
|
32
|
+
"""
|
|
33
|
+
cls._current_span = span
|
|
34
|
+
|
|
35
|
+
@classmethod
|
|
36
|
+
def get_current_span(cls) -> Optional[trace.Span]:
|
|
37
|
+
"""
|
|
38
|
+
Get the current span.
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
The stored current span or None if not set
|
|
42
|
+
"""
|
|
43
|
+
return cls._current_span
|
|
44
|
+
|
|
45
|
+
@staticmethod
|
|
46
|
+
def set_session_context(session_key: str, value: Union[str, Dict[str, str]]) -> None:
|
|
47
|
+
"""
|
|
48
|
+
Set session context attributes in the current OpenTelemetry baggage.
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
session_key: Key to set in baggage (session_id, user_id, tenant_id, or custom_attributes)
|
|
52
|
+
value: Value to set for the key
|
|
53
|
+
"""
|
|
54
|
+
try:
|
|
55
|
+
ctx = otel_context.get_current()
|
|
56
|
+
if isinstance(value, str) and value:
|
|
57
|
+
if session_key == "session_id":
|
|
58
|
+
ctx = baggage.set_baggage("session_id", value, ctx)
|
|
59
|
+
elif session_key == "user_id":
|
|
60
|
+
ctx = baggage.set_baggage("user_id", value, ctx)
|
|
61
|
+
elif session_key == "tenant_id":
|
|
62
|
+
ctx = baggage.set_baggage("tenant_id", value, ctx)
|
|
63
|
+
elif isinstance(value, dict) and value:
|
|
64
|
+
if session_key == "custom_attributes":
|
|
65
|
+
custom_keys = list(value.keys())
|
|
66
|
+
ctx = baggage.set_baggage("custom_keys", ",".join(custom_keys), ctx)
|
|
67
|
+
for key, val in value.items():
|
|
68
|
+
ctx = baggage.set_baggage(f"custom.{key}", str(val), ctx)
|
|
69
|
+
otel_context.attach(ctx)
|
|
70
|
+
except Exception as e:
|
|
71
|
+
logger.exception(f"Failed to set session context for key={session_key}: {e}")
|
|
72
|
+
|
|
73
|
+
@staticmethod
|
|
74
|
+
def set_custom_event(name: str, attributes: Dict[str, Any]) -> None:
|
|
75
|
+
"""
|
|
76
|
+
Add an event to the current span.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
name: Name of the event (e.g., 'pii_detection', 'error', etc.)
|
|
80
|
+
attributes: Dictionary of attributes associated with the event
|
|
81
|
+
"""
|
|
82
|
+
try:
|
|
83
|
+
current_span = SessionManager.get_current_span()
|
|
84
|
+
timestamp_ns = int(datetime.now().timestamp() * 1_000_000_000)
|
|
85
|
+
|
|
86
|
+
if current_span:
|
|
87
|
+
# Set the event in the current span.
|
|
88
|
+
current_span.add_event(name=name, attributes=attributes, timestamp=timestamp_ns)
|
|
89
|
+
else:
|
|
90
|
+
# Fallback to creating a new span.
|
|
91
|
+
ctx = otel_context.get_current()
|
|
92
|
+
tracer = trace.get_tracer(__name__)
|
|
93
|
+
with tracer.start_as_current_span(f"{Config.LIBRARY_NAME}.{name}", context=ctx) as span:
|
|
94
|
+
span.add_event(name=name, attributes=attributes, timestamp=timestamp_ns)
|
|
95
|
+
except Exception as e:
|
|
96
|
+
logger.exception(f"Failed to add custom event: {name} - {e}")
|
netra/tracer.py
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"""Netra OpenTelemetry tracer configuration module.
|
|
2
|
+
|
|
3
|
+
This module handles the initialization and configuration of OpenTelemetry tracing,
|
|
4
|
+
including exporter setup and span processor configuration.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import logging
|
|
8
|
+
from typing import Any, Dict
|
|
9
|
+
|
|
10
|
+
from opentelemetry import trace
|
|
11
|
+
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
|
|
12
|
+
from opentelemetry.sdk.resources import DEPLOYMENT_ENVIRONMENT, SERVICE_NAME, Resource
|
|
13
|
+
from opentelemetry.sdk.trace import TracerProvider
|
|
14
|
+
from opentelemetry.sdk.trace.export import (
|
|
15
|
+
BatchSpanProcessor,
|
|
16
|
+
ConsoleSpanExporter,
|
|
17
|
+
SimpleSpanProcessor,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
from netra.config import Config
|
|
21
|
+
|
|
22
|
+
logger = logging.getLogger(__name__)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class Tracer:
|
|
26
|
+
"""
|
|
27
|
+
Configures Netra's OpenTelemetry tracer with OTLP exporter (or Console exporter as fallback)
|
|
28
|
+
and appropriate span processor.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(self, cfg: Config) -> None:
|
|
32
|
+
"""Initialize the Netra tracer with the provided configuration.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
cfg: Configuration object with tracer settings
|
|
36
|
+
"""
|
|
37
|
+
self.cfg = cfg
|
|
38
|
+
self._setup_tracer()
|
|
39
|
+
|
|
40
|
+
def _setup_tracer(self) -> None:
|
|
41
|
+
"""Set up the OpenTelemetry tracer with appropriate exporters and processors.
|
|
42
|
+
|
|
43
|
+
Creates a resource with service name and custom attributes,
|
|
44
|
+
configures the appropriate exporter (OTLP or Console fallback),
|
|
45
|
+
and sets up either a batch or simple span processor based on configuration.
|
|
46
|
+
"""
|
|
47
|
+
# Create Resource with service.name + custom attributes
|
|
48
|
+
resource_attrs: Dict[str, Any] = {
|
|
49
|
+
SERVICE_NAME: self.cfg.app_name,
|
|
50
|
+
DEPLOYMENT_ENVIRONMENT: self.cfg.environment,
|
|
51
|
+
}
|
|
52
|
+
if self.cfg.resource_attributes:
|
|
53
|
+
resource_attrs.update(self.cfg.resource_attributes)
|
|
54
|
+
resource = Resource(attributes=resource_attrs)
|
|
55
|
+
|
|
56
|
+
# Build TracerProvider
|
|
57
|
+
provider = TracerProvider(resource=resource)
|
|
58
|
+
|
|
59
|
+
# Configure exporter based on configuration
|
|
60
|
+
if not self.cfg.otlp_endpoint:
|
|
61
|
+
logger.warning("OTLP endpoint not provided, falling back to console exporter")
|
|
62
|
+
exporter = ConsoleSpanExporter()
|
|
63
|
+
else:
|
|
64
|
+
exporter = OTLPSpanExporter(
|
|
65
|
+
endpoint=self._format_endpoint(self.cfg.otlp_endpoint),
|
|
66
|
+
headers=self.cfg.headers,
|
|
67
|
+
)
|
|
68
|
+
# Add span processors for session span processing and data aggregation processing
|
|
69
|
+
from netra.processors import SessionSpanProcessor, SpanAggregationProcessor
|
|
70
|
+
|
|
71
|
+
provider.add_span_processor(SessionSpanProcessor())
|
|
72
|
+
provider.add_span_processor(SpanAggregationProcessor())
|
|
73
|
+
|
|
74
|
+
# Install appropriate span processor
|
|
75
|
+
if self.cfg.disable_batch:
|
|
76
|
+
provider.add_span_processor(SimpleSpanProcessor(exporter))
|
|
77
|
+
else:
|
|
78
|
+
provider.add_span_processor(BatchSpanProcessor(exporter))
|
|
79
|
+
|
|
80
|
+
# Set global tracer provider
|
|
81
|
+
trace.set_tracer_provider(provider)
|
|
82
|
+
logger.info(
|
|
83
|
+
"Netra TracerProvider initialized: endpoint=%s, disable_batch=%s",
|
|
84
|
+
self.cfg.otlp_endpoint,
|
|
85
|
+
self.cfg.disable_batch,
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
def _format_endpoint(self, endpoint: str) -> str:
|
|
89
|
+
"""Format the OTLP endpoint URL to ensure it ends with '/v1/traces'.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
endpoint: Base OTLP endpoint URL
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
Properly formatted endpoint URL
|
|
96
|
+
"""
|
|
97
|
+
if not endpoint.endswith("/v1/traces"):
|
|
98
|
+
return endpoint.rstrip("/") + "/v1/traces"
|
|
99
|
+
return endpoint
|
netra/version.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright (c) 2025 KeyValue Software Systems
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|