alytricality 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.
- alytricality/__init__.py +15 -0
- alytricality/_init.py +207 -0
- alytricality/_instrument.py +70 -0
- alytricality/_propagation.py +56 -0
- alytricality/_traced.py +81 -0
- alytricality/attributes.py +24 -0
- alytricality/detectors/__init__.py +55 -0
- alytricality/detectors/gcp_batch.py +25 -0
- alytricality/detectors/gcp_cloud_run_jobs.py +29 -0
- alytricality/py.typed +0 -0
- alytricality-0.1.0.dist-info/METADATA +110 -0
- alytricality-0.1.0.dist-info/RECORD +14 -0
- alytricality-0.1.0.dist-info/WHEEL +4 -0
- alytricality-0.1.0.dist-info/licenses/LICENSE +202 -0
alytricality/__init__.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""Public API: @traced and init(). Everything else is native opentelemetry-api."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from importlib.metadata import PackageNotFoundError
|
|
6
|
+
from importlib.metadata import version as _version
|
|
7
|
+
|
|
8
|
+
from ._init import init
|
|
9
|
+
from ._traced import traced
|
|
10
|
+
|
|
11
|
+
__all__ = ["init", "traced"]
|
|
12
|
+
try:
|
|
13
|
+
__version__ = _version("alytricality")
|
|
14
|
+
except PackageNotFoundError: # vendored/copied tree, not pip-installed
|
|
15
|
+
__version__ = "0.0.0"
|
alytricality/_init.py
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"""Lazy one-shot SDK assembly (SIMP §5, §7)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import atexit
|
|
6
|
+
import logging
|
|
7
|
+
import os
|
|
8
|
+
import threading
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
from typing import TYPE_CHECKING
|
|
11
|
+
from urllib.parse import urlparse
|
|
12
|
+
|
|
13
|
+
from . import _instrument
|
|
14
|
+
from ._instrument import InstrumentResult
|
|
15
|
+
|
|
16
|
+
if TYPE_CHECKING:
|
|
17
|
+
from collections.abc import Iterable
|
|
18
|
+
|
|
19
|
+
from opentelemetry.sdk.trace import TracerProvider
|
|
20
|
+
from opentelemetry.sdk.trace.export import SpanExporter
|
|
21
|
+
from opentelemetry.trace import Tracer
|
|
22
|
+
|
|
23
|
+
log = logging.getLogger("alytricality")
|
|
24
|
+
|
|
25
|
+
FLUSH_TIMEOUT_MS = 10_000 # every root-span exit flushes with this bound (SIMP §10)
|
|
26
|
+
|
|
27
|
+
_lock = threading.Lock()
|
|
28
|
+
_runtime: Runtime | None = None
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclass(frozen=True)
|
|
32
|
+
class Runtime:
|
|
33
|
+
"""Process-wide record of what init() produced. Never rebuilt (SIMP §5)."""
|
|
34
|
+
|
|
35
|
+
mode: str # "active" | "deferred" | "disabled"
|
|
36
|
+
provider: TracerProvider | None = None
|
|
37
|
+
tracer: Tracer | None = None
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def runtime() -> Runtime | None:
|
|
41
|
+
return _runtime
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def init() -> Runtime:
|
|
45
|
+
"""Assemble the SDK once; every later call returns the same Runtime."""
|
|
46
|
+
global _runtime
|
|
47
|
+
if _runtime is not None:
|
|
48
|
+
return _runtime
|
|
49
|
+
with _lock:
|
|
50
|
+
if _runtime is not None:
|
|
51
|
+
return _runtime
|
|
52
|
+
try:
|
|
53
|
+
_runtime = _assemble()
|
|
54
|
+
except Exception:
|
|
55
|
+
log.exception("tracing init failed; continuing untraced")
|
|
56
|
+
_runtime = Runtime(mode="disabled")
|
|
57
|
+
return _runtime
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def flush(provider: TracerProvider) -> bool:
|
|
61
|
+
"""Bounded force_flush; warns on timeout/failure, never raises."""
|
|
62
|
+
try:
|
|
63
|
+
ok = provider.force_flush(timeout_millis=FLUSH_TIMEOUT_MS)
|
|
64
|
+
except Exception:
|
|
65
|
+
log.warning("force_flush failed; spans may be dropped", exc_info=True)
|
|
66
|
+
return False
|
|
67
|
+
if not ok:
|
|
68
|
+
log.warning("force_flush timed out; spans may be dropped")
|
|
69
|
+
return bool(ok)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _sdk_disabled() -> bool:
|
|
73
|
+
return os.environ.get("OTEL_SDK_DISABLED", "").strip().lower() == "true"
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _assemble() -> Runtime:
|
|
77
|
+
if _sdk_disabled():
|
|
78
|
+
return Runtime(mode="disabled")
|
|
79
|
+
|
|
80
|
+
from opentelemetry import trace
|
|
81
|
+
|
|
82
|
+
existing = type(trace.get_tracer_provider()).__name__
|
|
83
|
+
if "Proxy" not in existing:
|
|
84
|
+
log.info("existing TracerProvider %s; deferring", existing)
|
|
85
|
+
_sanity_line("deferred", "-", InstrumentResult(), [])
|
|
86
|
+
return Runtime(mode="deferred")
|
|
87
|
+
|
|
88
|
+
resource = _build_resource()
|
|
89
|
+
exporter, exporter_desc = _build_exporter()
|
|
90
|
+
for gap in _config_gaps(resource, exporter_desc):
|
|
91
|
+
log.warning("config gap: %s", gap)
|
|
92
|
+
|
|
93
|
+
from opentelemetry.sdk.trace import TracerProvider
|
|
94
|
+
from opentelemetry.sdk.trace.export import BatchSpanProcessor
|
|
95
|
+
|
|
96
|
+
provider = TracerProvider(resource=resource)
|
|
97
|
+
provider.add_span_processor(BatchSpanProcessor(exporter))
|
|
98
|
+
trace.set_tracer_provider(provider)
|
|
99
|
+
|
|
100
|
+
result = _instrument.apply(provider)
|
|
101
|
+
atexit.register(provider.shutdown)
|
|
102
|
+
_sanity_line("active", exporter_desc, result, resource.attributes.keys())
|
|
103
|
+
return Runtime(mode="active", provider=provider, tracer=trace.get_tracer("alytricality"))
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def _build_exporter() -> tuple[SpanExporter, str]:
|
|
107
|
+
"""OTLP, opinionated: HTTP unless the standard protocol env says grpc."""
|
|
108
|
+
protocol = (
|
|
109
|
+
os.environ.get("OTEL_EXPORTER_OTLP_TRACES_PROTOCOL")
|
|
110
|
+
or os.environ.get("OTEL_EXPORTER_OTLP_PROTOCOL")
|
|
111
|
+
or "http/protobuf"
|
|
112
|
+
).lower()
|
|
113
|
+
if protocol.startswith("grpc"):
|
|
114
|
+
try:
|
|
115
|
+
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (
|
|
116
|
+
OTLPSpanExporter as GrpcExporter,
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
return GrpcExporter(), "otlp/grpc"
|
|
120
|
+
except ImportError:
|
|
121
|
+
log.warning(
|
|
122
|
+
"grpc protocol requested but exporter not installed; "
|
|
123
|
+
"install alytricality[grpc]; falling back to http"
|
|
124
|
+
)
|
|
125
|
+
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
|
|
126
|
+
|
|
127
|
+
return OTLPSpanExporter(), "otlp/http"
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _otlp_endpoint_configured() -> bool:
|
|
131
|
+
return bool(
|
|
132
|
+
os.environ.get("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT")
|
|
133
|
+
or os.environ.get("OTEL_EXPORTER_OTLP_ENDPOINT")
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def _build_resource():
|
|
138
|
+
from opentelemetry.sdk.resources import (
|
|
139
|
+
OTELResourceDetector,
|
|
140
|
+
Resource,
|
|
141
|
+
get_aggregated_resources,
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
from . import __version__
|
|
145
|
+
from .detectors import self_gated
|
|
146
|
+
|
|
147
|
+
dets = self_gated()
|
|
148
|
+
dets.append(OTELResourceDetector()) # last: env retains override priority
|
|
149
|
+
resource = get_aggregated_resources(dets, initial_resource=Resource.create({}))
|
|
150
|
+
return resource.merge(
|
|
151
|
+
Resource(
|
|
152
|
+
{
|
|
153
|
+
"telemetry.distro.name": "alytricality",
|
|
154
|
+
"telemetry.distro.version": __version__,
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def _config_gaps(resource, exporter_desc: str) -> list[str]:
|
|
161
|
+
from . import attributes as attrs
|
|
162
|
+
|
|
163
|
+
gaps = []
|
|
164
|
+
attrs_ = resource.attributes
|
|
165
|
+
if not attrs_.get(attrs.ORG_ID):
|
|
166
|
+
gaps.append(
|
|
167
|
+
f"resource attr {attrs.ORG_ID} missing — set "
|
|
168
|
+
f"OTEL_RESOURCE_ATTRIBUTES={attrs.ORG_ID}=<id> "
|
|
169
|
+
"(collector drops spans without it)"
|
|
170
|
+
)
|
|
171
|
+
service = str(attrs_.get("service.name", ""))
|
|
172
|
+
if not service or service.startswith("unknown_service"):
|
|
173
|
+
gaps.append("service.name unset — set OTEL_SERVICE_NAME")
|
|
174
|
+
if exporter_desc.startswith("otlp") and not _otlp_endpoint_configured():
|
|
175
|
+
gaps.append(
|
|
176
|
+
"no OTLP endpoint — set OTEL_EXPORTER_OTLP_ENDPOINT or "
|
|
177
|
+
"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT (SDK default localhost:4318 "
|
|
178
|
+
"exports nowhere)"
|
|
179
|
+
)
|
|
180
|
+
return gaps
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def _endpoint_host() -> str:
|
|
184
|
+
raw = os.environ.get("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT") or os.environ.get(
|
|
185
|
+
"OTEL_EXPORTER_OTLP_ENDPOINT"
|
|
186
|
+
)
|
|
187
|
+
if not raw:
|
|
188
|
+
return "-"
|
|
189
|
+
return urlparse(raw).netloc or raw
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def _sanity_line(
|
|
193
|
+
mode: str, exporter_desc: str, result: InstrumentResult, resource_keys: Iterable[str]
|
|
194
|
+
) -> None:
|
|
195
|
+
log.info(
|
|
196
|
+
"init mode=%s exporter=%s endpoint_host=%s "
|
|
197
|
+
"instrumentors_loaded=%s instrumentors_disabled=%s "
|
|
198
|
+
"instrumentors_skipped=%s instrumentors_failed=%s resource_keys=%s",
|
|
199
|
+
mode,
|
|
200
|
+
exporter_desc,
|
|
201
|
+
_endpoint_host(),
|
|
202
|
+
sorted(result.loaded),
|
|
203
|
+
sorted(result.disabled),
|
|
204
|
+
sorted(result.skipped),
|
|
205
|
+
sorted(result.failed),
|
|
206
|
+
sorted(resource_keys),
|
|
207
|
+
)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""Instrumentor discovery with per-instrumentor failure isolation (SPEC §5.6)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
import os
|
|
7
|
+
from dataclasses import dataclass, field
|
|
8
|
+
from typing import TYPE_CHECKING
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from opentelemetry.sdk.trace import TracerProvider
|
|
12
|
+
|
|
13
|
+
log = logging.getLogger("alytricality")
|
|
14
|
+
|
|
15
|
+
# IMDS + cloud auth-plane hosts (SIMP §12). Host-specific on purpose:
|
|
16
|
+
# do NOT broaden to googleapis\.com or data-plane spans get dropped too.
|
|
17
|
+
EXCLUDED_URL_PATTERNS: tuple[str, ...] = (
|
|
18
|
+
r"metadata\.google\.internal", # GCP metadata server (DNS)
|
|
19
|
+
r"169\.254\.169\.254", # GCP/AWS/Azure IMDS (link-local IPv4)
|
|
20
|
+
r"\[fd00:ec2::254\]", # AWS IMDSv2 (link-local IPv6)
|
|
21
|
+
r"iamcredentials\.googleapis\.com", # SA impersonation / signBlob
|
|
22
|
+
r"oauth2\.googleapis\.com", # OAuth2 token endpoint
|
|
23
|
+
r"sts\.googleapis\.com", # workload-identity exchange
|
|
24
|
+
r"accounts\.google\.com", # user OAuth
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
# These instrumentors accept excluded_urls= as a comma-separated string.
|
|
28
|
+
_EXCLUDED_URL_INSTRUMENTORS = frozenset({"requests", "urllib3", "urllib", "httpx"})
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclass
|
|
32
|
+
class InstrumentResult:
|
|
33
|
+
loaded: list[str] = field(default_factory=list)
|
|
34
|
+
disabled: list[str] = field(default_factory=list)
|
|
35
|
+
skipped: list[str] = field(default_factory=list) # target library absent
|
|
36
|
+
failed: list[str] = field(default_factory=list)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _entry_points():
|
|
40
|
+
from importlib.metadata import entry_points
|
|
41
|
+
|
|
42
|
+
return sorted(entry_points(group="opentelemetry_instrumentor"), key=lambda ep: ep.name)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def apply(provider: TracerProvider) -> InstrumentResult:
|
|
46
|
+
disabled = {
|
|
47
|
+
t.strip()
|
|
48
|
+
for t in os.environ.get("OTEL_PYTHON_DISABLED_INSTRUMENTATIONS", "").split(",")
|
|
49
|
+
if t.strip()
|
|
50
|
+
}
|
|
51
|
+
result = InstrumentResult()
|
|
52
|
+
for ep in _entry_points():
|
|
53
|
+
if ep.name in disabled:
|
|
54
|
+
result.disabled.append(ep.name)
|
|
55
|
+
continue
|
|
56
|
+
kwargs: dict = {"tracer_provider": provider}
|
|
57
|
+
if ep.name in _EXCLUDED_URL_INSTRUMENTORS:
|
|
58
|
+
kwargs["excluded_urls"] = ",".join(EXCLUDED_URL_PATTERNS)
|
|
59
|
+
try:
|
|
60
|
+
ep.load()().instrument(**kwargs)
|
|
61
|
+
result.loaded.append(ep.name)
|
|
62
|
+
except ModuleNotFoundError as e:
|
|
63
|
+
# Bundled instrumentors whose target library isn't installed are
|
|
64
|
+
# the expected case (psycopg2/grpc on most machines), not noise.
|
|
65
|
+
log.debug("instrumentor %s target not importable (%s); skipping", ep.name, e)
|
|
66
|
+
result.skipped.append(ep.name)
|
|
67
|
+
except Exception:
|
|
68
|
+
log.warning("instrumentor %s failed; skipping", ep.name, exc_info=True)
|
|
69
|
+
result.failed.append(ep.name)
|
|
70
|
+
return result
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""Carriers and links (SPEC §4 doctrine 3: links, not remote parents)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
from collections.abc import Mapping
|
|
7
|
+
|
|
8
|
+
from opentelemetry import propagate, trace
|
|
9
|
+
|
|
10
|
+
from . import attributes as attrs
|
|
11
|
+
|
|
12
|
+
log = logging.getLogger("alytricality")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def link_from_carrier(carrier: Mapping | None, source: str) -> trace.Link | None:
|
|
16
|
+
try:
|
|
17
|
+
if not carrier:
|
|
18
|
+
return None
|
|
19
|
+
ctx = propagate.extract(dict(carrier))
|
|
20
|
+
sc = trace.get_current_span(ctx).get_span_context()
|
|
21
|
+
if sc is None or not sc.is_valid:
|
|
22
|
+
return None
|
|
23
|
+
return trace.Link(sc, attributes={attrs.TRACE_SOURCE: source})
|
|
24
|
+
except Exception:
|
|
25
|
+
return None
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _carrier_from(src: Mapping) -> dict[str, str]:
|
|
29
|
+
lower = {str(k).lower(): v for k, v in src.items()}
|
|
30
|
+
tp = lower.get("traceparent") or lower.get("googclient_traceparent")
|
|
31
|
+
if not tp:
|
|
32
|
+
return {}
|
|
33
|
+
carrier = {"traceparent": tp}
|
|
34
|
+
ts = lower.get("tracestate") or lower.get("googclient_tracestate")
|
|
35
|
+
if ts:
|
|
36
|
+
carrier["tracestate"] = ts
|
|
37
|
+
return carrier
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def inbound_links(args: tuple) -> list[trace.Link]:
|
|
41
|
+
"""Sniff the decorated function's first argument for a trace carrier.
|
|
42
|
+
|
|
43
|
+
Flask-served runtimes get context propagation from the flask
|
|
44
|
+
instrumentor instead (no longer force-disabled) — SIMP §9.
|
|
45
|
+
"""
|
|
46
|
+
if not args:
|
|
47
|
+
return []
|
|
48
|
+
try:
|
|
49
|
+
src = dict(args[0])
|
|
50
|
+
carrier = _carrier_from(src)
|
|
51
|
+
except Exception:
|
|
52
|
+
return []
|
|
53
|
+
if not carrier:
|
|
54
|
+
return []
|
|
55
|
+
link = link_from_carrier(carrier, attrs.TRACE_SOURCE_INBOUND_TRIGGER)
|
|
56
|
+
return [link] if link else []
|
alytricality/_traced.py
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""The public decorator (SPEC §5.2). Root span per process entry point."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import functools
|
|
6
|
+
import inspect
|
|
7
|
+
import logging
|
|
8
|
+
from collections.abc import Callable
|
|
9
|
+
from typing import ParamSpec, TypeVar
|
|
10
|
+
|
|
11
|
+
log = logging.getLogger("alytricality")
|
|
12
|
+
|
|
13
|
+
_MARKER = "__alytricality_traced__"
|
|
14
|
+
|
|
15
|
+
P = ParamSpec("P")
|
|
16
|
+
R = TypeVar("R")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def traced(fn: Callable[P, R]) -> Callable[P, R]:
|
|
20
|
+
if not callable(fn):
|
|
21
|
+
raise TypeError("@traced takes no arguments; apply it bare: @traced")
|
|
22
|
+
if (
|
|
23
|
+
inspect.iscoroutinefunction(fn)
|
|
24
|
+
or inspect.isgeneratorfunction(fn)
|
|
25
|
+
or inspect.isasyncgenfunction(fn)
|
|
26
|
+
):
|
|
27
|
+
raise TypeError(
|
|
28
|
+
"@traced supports plain sync functions only; async/generator "
|
|
29
|
+
"support is added when a call site needs it (SPEC §2)"
|
|
30
|
+
)
|
|
31
|
+
if getattr(fn, _MARKER, False):
|
|
32
|
+
# SIMP §6: additional decorators are dropped, not nested
|
|
33
|
+
log.debug("@traced already applied to %s; dropping", fn.__name__)
|
|
34
|
+
return fn
|
|
35
|
+
|
|
36
|
+
from . import _init
|
|
37
|
+
|
|
38
|
+
_init.init() # never raises
|
|
39
|
+
|
|
40
|
+
from opentelemetry import trace as otel_trace
|
|
41
|
+
|
|
42
|
+
from . import _propagation
|
|
43
|
+
|
|
44
|
+
@functools.wraps(fn)
|
|
45
|
+
def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
|
|
46
|
+
# Read runtime()/flush as _init attributes at call time: late binding is
|
|
47
|
+
# what lets tests patch them, and it keeps flush off a None provider.
|
|
48
|
+
rt = _init.runtime()
|
|
49
|
+
if rt is None or rt.mode != "active":
|
|
50
|
+
return fn(*args, **kwargs)
|
|
51
|
+
try:
|
|
52
|
+
links = _propagation.inbound_links(args)
|
|
53
|
+
with rt.tracer.start_as_current_span(
|
|
54
|
+
fn.__name__,
|
|
55
|
+
kind=otel_trace.SpanKind.SERVER,
|
|
56
|
+
links=links,
|
|
57
|
+
record_exception=False,
|
|
58
|
+
set_status_on_exception=False,
|
|
59
|
+
) as span:
|
|
60
|
+
try:
|
|
61
|
+
return fn(*args, **kwargs)
|
|
62
|
+
except BaseException as e:
|
|
63
|
+
_record_failure(span, e, fn.__name__)
|
|
64
|
+
raise
|
|
65
|
+
finally:
|
|
66
|
+
_init.flush(rt.provider)
|
|
67
|
+
|
|
68
|
+
setattr(wrapper, _MARKER, True)
|
|
69
|
+
return wrapper
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _record_failure(span, e, name):
|
|
73
|
+
try:
|
|
74
|
+
from opentelemetry.trace import Status, StatusCode
|
|
75
|
+
|
|
76
|
+
span.set_status(Status(StatusCode.ERROR, str(e)))
|
|
77
|
+
span.set_attribute("exception.type", f"{type(e).__module__}.{type(e).__name__}")
|
|
78
|
+
span.record_exception(e, escaped=True)
|
|
79
|
+
log.error("traced function %s failed", name, exc_info=e)
|
|
80
|
+
except Exception:
|
|
81
|
+
log.warning("failed to record exception on span", exc_info=True)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Every unblessed attribute name, in one module (SPEC §7: the semconv rename point)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
TRACE_SOURCE = "trace.source"
|
|
6
|
+
TRACE_SOURCE_DAG_RUN_CONF = "dag_run.conf"
|
|
7
|
+
TRACE_SOURCE_INBOUND_TRIGGER = "inbound_trigger"
|
|
8
|
+
|
|
9
|
+
ORG_ID = "pandabase.org_id" # collector-owned name; renames ride a collector change
|
|
10
|
+
|
|
11
|
+
CLOUD_PROVIDER_GCP = "gcp"
|
|
12
|
+
|
|
13
|
+
CLOUD_PLATFORM_GCP_BATCH = "gcp_batch"
|
|
14
|
+
GCP_BATCH_JOB_UID = "gcp.batch.job.uid"
|
|
15
|
+
GCP_BATCH_TASK_INDEX = "gcp.batch.task.index"
|
|
16
|
+
GCP_BATCH_TASK_COUNT = "gcp.batch.task.count"
|
|
17
|
+
GCP_BATCH_TASK_RETRY_ATTEMPT = "gcp.batch.task.retry_attempt"
|
|
18
|
+
|
|
19
|
+
CLOUD_PLATFORM_GCP_CLOUD_RUN_JOB = "gcp_cloud_run_job"
|
|
20
|
+
GCP_CLOUD_RUN_JOB_NAME = "gcp.cloud_run.job.name"
|
|
21
|
+
GCP_CLOUD_RUN_JOB_EXECUTION = "gcp.cloud_run.job.execution"
|
|
22
|
+
GCP_CLOUD_RUN_JOB_TASK_INDEX = "gcp.cloud_run.job.task_index"
|
|
23
|
+
GCP_CLOUD_RUN_JOB_TASK_ATTEMPT = "gcp.cloud_run.job.task_attempt"
|
|
24
|
+
GCP_CLOUD_RUN_JOB_TASK_COUNT = "gcp.cloud_run.job.task_count"
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""Self-gated detector list (SIMP §11). Replaces the profile registry."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
import os
|
|
7
|
+
from typing import TYPE_CHECKING
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from opentelemetry.sdk.resources import ResourceDetector
|
|
11
|
+
|
|
12
|
+
log = logging.getLogger("alytricality")
|
|
13
|
+
|
|
14
|
+
# Presence of any of these means "some GCP (or k8s) runtime": worth one
|
|
15
|
+
# bounded metadata probe. Absence means laptop/notebook: probe-free cold start.
|
|
16
|
+
_GCP_ENV_MARKERS = (
|
|
17
|
+
"BATCH_TASK_INDEX",
|
|
18
|
+
"CLOUD_RUN_JOB",
|
|
19
|
+
"K_SERVICE",
|
|
20
|
+
"FUNCTION_TARGET",
|
|
21
|
+
"GOOGLE_CLOUD_PROJECT",
|
|
22
|
+
"GCE_METADATA_HOST",
|
|
23
|
+
"KUBERNETES_SERVICE_HOST",
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _gcp_detector() -> ResourceDetector | None:
|
|
28
|
+
"""GoogleCloudResourceDetector, or None when the [gcp] extra is absent."""
|
|
29
|
+
try:
|
|
30
|
+
from opentelemetry.resourcedetector.gcp_resource_detector import (
|
|
31
|
+
GoogleCloudResourceDetector,
|
|
32
|
+
)
|
|
33
|
+
except ImportError:
|
|
34
|
+
log.info(
|
|
35
|
+
"opentelemetry-resourcedetector-gcp not installed; "
|
|
36
|
+
"install alytricality[gcp] for GCP resource attributes"
|
|
37
|
+
)
|
|
38
|
+
return None
|
|
39
|
+
return GoogleCloudResourceDetector(raise_on_error=False)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def self_gated() -> list[ResourceDetector]:
|
|
43
|
+
"""Detector chain, platform detectors last so they win merge conflicts
|
|
44
|
+
(gcp_batch over gcp_compute_engine — DESIGN's normative order)."""
|
|
45
|
+
from .gcp_batch import BatchResourceDetector
|
|
46
|
+
from .gcp_cloud_run_jobs import CloudRunJobsResourceDetector
|
|
47
|
+
|
|
48
|
+
dets: list[ResourceDetector] = []
|
|
49
|
+
if any(m in os.environ for m in _GCP_ENV_MARKERS):
|
|
50
|
+
gcp = _gcp_detector()
|
|
51
|
+
if gcp is not None:
|
|
52
|
+
dets.append(gcp)
|
|
53
|
+
dets.append(BatchResourceDetector())
|
|
54
|
+
dets.append(CloudRunJobsResourceDetector())
|
|
55
|
+
return dets
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""cloud.* + gcp.batch.* from Batch's env vars. Fires iff BATCH_TASK_INDEX set."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
from opentelemetry.sdk.resources import Resource, ResourceDetector
|
|
8
|
+
|
|
9
|
+
from .. import attributes as attrs
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class BatchResourceDetector(ResourceDetector):
|
|
13
|
+
def detect(self) -> Resource:
|
|
14
|
+
task_index = os.environ.get("BATCH_TASK_INDEX")
|
|
15
|
+
if task_index is None:
|
|
16
|
+
return Resource.get_empty()
|
|
17
|
+
out = {
|
|
18
|
+
"cloud.provider": attrs.CLOUD_PROVIDER_GCP,
|
|
19
|
+
"cloud.platform": attrs.CLOUD_PLATFORM_GCP_BATCH,
|
|
20
|
+
attrs.GCP_BATCH_JOB_UID: os.environ.get("BATCH_JOB_UID", ""),
|
|
21
|
+
attrs.GCP_BATCH_TASK_INDEX: task_index,
|
|
22
|
+
attrs.GCP_BATCH_TASK_COUNT: os.environ.get("BATCH_TASK_COUNT", ""),
|
|
23
|
+
attrs.GCP_BATCH_TASK_RETRY_ATTEMPT: os.environ.get("BATCH_TASK_RETRY_ATTEMPT", ""),
|
|
24
|
+
}
|
|
25
|
+
return Resource({k: v for k, v in out.items() if v})
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""cloud.* + gcp.cloud_run.job.* from Cloud Run Jobs env vars. Fires iff CLOUD_RUN_JOB set."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
from opentelemetry.sdk.resources import Resource, ResourceDetector
|
|
8
|
+
|
|
9
|
+
from .. import attributes as attrs
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class CloudRunJobsResourceDetector(ResourceDetector):
|
|
13
|
+
def detect(self) -> Resource:
|
|
14
|
+
job = os.environ.get("CLOUD_RUN_JOB")
|
|
15
|
+
if not job:
|
|
16
|
+
return Resource.get_empty()
|
|
17
|
+
out = {
|
|
18
|
+
"cloud.provider": attrs.CLOUD_PROVIDER_GCP,
|
|
19
|
+
"cloud.platform": attrs.CLOUD_PLATFORM_GCP_CLOUD_RUN_JOB,
|
|
20
|
+
# Default service.name to the job name; OTEL_SERVICE_NAME still
|
|
21
|
+
# wins because OTELResourceDetector aggregates last (DESIGN §4.2).
|
|
22
|
+
"service.name": job,
|
|
23
|
+
attrs.GCP_CLOUD_RUN_JOB_NAME: job,
|
|
24
|
+
attrs.GCP_CLOUD_RUN_JOB_EXECUTION: os.environ.get("CLOUD_RUN_EXECUTION", ""),
|
|
25
|
+
attrs.GCP_CLOUD_RUN_JOB_TASK_INDEX: os.environ.get("CLOUD_RUN_TASK_INDEX", "0"),
|
|
26
|
+
attrs.GCP_CLOUD_RUN_JOB_TASK_ATTEMPT: os.environ.get("CLOUD_RUN_TASK_ATTEMPT", ""),
|
|
27
|
+
attrs.GCP_CLOUD_RUN_JOB_TASK_COUNT: os.environ.get("CLOUD_RUN_TASK_COUNT", ""),
|
|
28
|
+
}
|
|
29
|
+
return Resource({k: v for k, v in out.items() if v})
|
alytricality/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: alytricality
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Opinionated OpenTelemetry tracing distro for data pipelines
|
|
5
|
+
Project-URL: Repository, https://github.com/seismiq-ai/alytricality
|
|
6
|
+
Project-URL: Issues, https://github.com/seismiq-ai/alytricality/issues
|
|
7
|
+
Author: Seismiq AI
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: System :: Monitoring
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: opentelemetry-api<2,>=1.27
|
|
22
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-http<2,>=1.27
|
|
23
|
+
Requires-Dist: opentelemetry-instrumentation-grpc<0.66b0,>=0.48b0
|
|
24
|
+
Requires-Dist: opentelemetry-instrumentation-psycopg2<0.66b0,>=0.48b0
|
|
25
|
+
Requires-Dist: opentelemetry-instrumentation-requests<0.66b0,>=0.48b0
|
|
26
|
+
Requires-Dist: opentelemetry-instrumentation-urllib3<0.66b0,>=0.48b0
|
|
27
|
+
Requires-Dist: opentelemetry-sdk<2,>=1.27
|
|
28
|
+
Provides-Extra: all
|
|
29
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc<2,>=1.27; extra == 'all'
|
|
30
|
+
Requires-Dist: opentelemetry-resourcedetector-gcp>=1.6; extra == 'all'
|
|
31
|
+
Provides-Extra: gcp
|
|
32
|
+
Requires-Dist: opentelemetry-resourcedetector-gcp>=1.6; extra == 'gcp'
|
|
33
|
+
Provides-Extra: grpc
|
|
34
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc<2,>=1.27; extra == 'grpc'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# alytricality
|
|
38
|
+
|
|
39
|
+
An opinionated OpenTelemetry tracing distro for data pipelines. One decorator
|
|
40
|
+
assembles the whole SDK — resource detection, OTLP export, bundled
|
|
41
|
+
instrumentors, W3C context propagation, bounded flush on exit — from standard
|
|
42
|
+
`OTEL_*` environment variables, and never breaks the workload: any telemetry
|
|
43
|
+
failure degrades to no telemetry, loudly logged, never raised.
|
|
44
|
+
|
|
45
|
+
> **Pre-launch naming.** `alytricality` is a placeholder distribution name.
|
|
46
|
+
> The project will be republished under its real brand at launch; the import
|
|
47
|
+
> package, entry points, and `telemetry.distro.name` all change with it.
|
|
48
|
+
|
|
49
|
+
## Install
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
pip install alytricality
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Extras: `alytricality[gcp]` adds the official GCP resource detector,
|
|
56
|
+
`alytricality[grpc]` the OTLP/gRPC exporter, `alytricality[all]` both.
|
|
57
|
+
|
|
58
|
+
## Use
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from alytricality import traced
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@traced
|
|
65
|
+
def handler(event): ...
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
`@traced` marks the **process entry point** and always produces a SERVER root
|
|
69
|
+
span named after the function: it records exceptions, links any inbound trace
|
|
70
|
+
context found in the first argument, and performs a bounded `force_flush` on
|
|
71
|
+
exit. Applying it a second time to the same function is a no-op, so root spans
|
|
72
|
+
never stack. For notebooks, REPLs, and scripts with no function to decorate,
|
|
73
|
+
call `init()` instead — the same idempotent assembly, which returns the process
|
|
74
|
+
runtime and never raises.
|
|
75
|
+
|
|
76
|
+
Everything you do *inside* a trace is native `opentelemetry-api`:
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from opentelemetry import trace
|
|
80
|
+
|
|
81
|
+
trace.get_current_span().set_attribute("rows.loaded", 1042)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Configuration
|
|
85
|
+
|
|
86
|
+
Standard OTel environment variables only — there are no config kwargs and no
|
|
87
|
+
package-specific vars, and the package never writes to the environment.
|
|
88
|
+
|
|
89
|
+
| Variable | Role |
|
|
90
|
+
| --- | --- |
|
|
91
|
+
| `OTEL_EXPORTER_OTLP_ENDPOINT` | Required; there is no baked-in default |
|
|
92
|
+
| `OTEL_SERVICE_NAME` | Service identity |
|
|
93
|
+
| `OTEL_RESOURCE_ATTRIBUTES` | Extra resource attributes |
|
|
94
|
+
| `OTEL_EXPORTER_OTLP_PROTOCOL` | `grpc` selects the gRPC exporter; otherwise HTTP/protobuf |
|
|
95
|
+
| `OTEL_PYTHON_DISABLED_INSTRUMENTATIONS` | Opt out of bundled instrumentors |
|
|
96
|
+
| `OTEL_SDK_DISABLED` | `true` turns everything into a no-op |
|
|
97
|
+
|
|
98
|
+
Export is always OTLP. `requests`, `urllib3`, `psycopg2`, and `grpc`
|
|
99
|
+
instrumentation is bundled and applied automatically; an instrumentor whose
|
|
100
|
+
target library isn't installed is skipped quietly.
|
|
101
|
+
|
|
102
|
+
## Supported window
|
|
103
|
+
|
|
104
|
+
Python 3.10–3.13, OpenTelemetry SDK 1.27–1.44 (min and max both tested in CI).
|
|
105
|
+
`opentelemetry-instrumentation-*` releases are pinned to the matched set for
|
|
106
|
+
each SDK window, so consumers don't hand-curate OTel version lines.
|
|
107
|
+
|
|
108
|
+
## License
|
|
109
|
+
|
|
110
|
+
Apache-2.0.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
alytricality/__init__.py,sha256=E22vRqybcLSwvUUzZECc4OlwWb1H9EC6tzo8VIw6tog,452
|
|
2
|
+
alytricality/_init.py,sha256=raz_dVKvB1Ev1qAl9v9H4Nju_ScId1UmdpD0He6IJgo,6453
|
|
3
|
+
alytricality/_instrument.py,sha256=rnKeYTWMBg4lDBgTq2cP_l2UbZvyIC5bNYZW8zOhKu8,2680
|
|
4
|
+
alytricality/_propagation.py,sha256=QSeNb4zyWD-E2mbweYBKy0lAjLbO4bur1xqPFE2rqYw,1658
|
|
5
|
+
alytricality/_traced.py,sha256=fdIvI0K8ZLoTjfgiBU8bn_9kpntmskXzV-v9zYop5VM,2615
|
|
6
|
+
alytricality/attributes.py,sha256=3zZnU8rNN7i1DotoT4ApijmKbz8Xah6yfL4QUmQfiCY,953
|
|
7
|
+
alytricality/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
alytricality/detectors/__init__.py,sha256=pOsCRtEH1qrEvc3lkbPwO7VpANhDIt_oDWTW424rQ3o,1760
|
|
9
|
+
alytricality/detectors/gcp_batch.py,sha256=a5vu2CeUBepuA3Hlq2EWb-gi8pWwOIUKH1Av4gbcMgg,951
|
|
10
|
+
alytricality/detectors/gcp_cloud_run_jobs.py,sha256=xIahLqsEolWXpV1wAPOYhHMdz1pBzbEjRzmqolmXlz8,1262
|
|
11
|
+
alytricality-0.1.0.dist-info/METADATA,sha256=XwUB0MXPypNTkjB2RRLJ3S-02BcdsM_1bhHYO8cBHsY,4292
|
|
12
|
+
alytricality-0.1.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
13
|
+
alytricality-0.1.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
14
|
+
alytricality-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|