Skip to content

Commit

Permalink
Add some docs and rename mode to exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
Wh1isper committed Oct 18, 2023
1 parent 06a1625 commit e726f24
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 18 deletions.
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,18 @@ Join our [slack channel](https://join.slack.com/t/hitsz-ids/shared_invite/zt-239
- `Tracer` Support
- [X] eBPF-based tracer
- [X] Shell command tracer
- [ ] Subprocess tracer
- [X] Subprocess tracer
- `Filter` Support
- [X] Pattern matching, based on regular expressions
- `Collector` and `Analyzer` Support
- [X] SQL database
- [ ] OpenTelemetry
- Analyzer Support
- [X] SQL database
- [ ] OpenTelemetry
- Data Collection and Analysis
- [X] `Analyzer` Support SQL database
- [X] `Collector` Support SQL database and *OpenTelemetry(Experimental)*
- User Interface
- [X] CLI Tools
- [X] PIP Service
- [ ] Control Panel
- Enhancements
- [ ] Runc containers identification
- [ ] `RunC` containers identification

The eBPF program requires kernel support, see [Kernel Support](./docs/kernel_config.md)

Expand Down
10 changes: 6 additions & 4 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,18 @@ duetector🔍是一个基于可扩展的的数据使用探测器,它可以在L
- `Tracer`支持
- [X] 基于eBPF的tracer
- [X] 基于shell命令的tracer
- [ ] 基于子进程的tracer
- [X] 基于子进程的tracer
- `Filter`支持
- [X] 支持正则的模式匹配
- `Collector``Analyzer`支持
- [X] SQL数据库
- [ ] Opentelemetry
- 遥测数据传输与分析
- [X] `Analyzer`支持SQL数据库
- [X] `Collector`支持SQL数据库和*Opentelemetry(实验性)*
- 用户接口
- [X] 命令行工具
- [X] PIP服务
- [ ] 控制平面
- 增强功能
- [ ] `RunC`容器云原生支持

eBPF程序需要内核支持,详见[内核支持](./docs/kernel_config.md)

Expand Down
51 changes: 47 additions & 4 deletions duetector/collectors/otel.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,37 @@


class OTelInitiator:
"""
Host the OpenTelemetry SDK and initialize the provider and exporter.
Avaliable exporters:
- ``console``
- ``otlp-grpc``
- ``otlp-http``
- ``jaeger-thrift``
- ``jaeger-grpc``
- ``zipkin-http``
- ``zipkin-json``
- ``prometheus``
Example:
.. code-block:: python
otel = OTelInitiator()
trace = otel.initialize(
service_name="duetector",
exporter="console",
)
from opentelemetry import trace
tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span("test") as span:
span.set_attribute("test", "test")
otel.shutdown()
"""

exporter_cls = {
"console": ConsoleSpanExporter,
"otlp-grpc": GRPCOTLPSpanExporter,
Expand Down Expand Up @@ -76,16 +107,28 @@ def shutdown(self):


class OTelCollector(Collector):
"""
A collector using OpenTelemetry SDK.
Config:
- ``exporter``: One of ``console``, ``otlp-grpc``, ``otlp-http``, ``jaeger-thrift``, ``jaeger-grpc``, ``zipkin-http``, ``zipkin-json``, see :class:`OTelInitiator` for more details
- ``exporter_kwargs``: A dict of kwargs for exporter
Note:
Since v1.35, the Jaeger supports OTLP natively. Please use the OTLP exporter instead. Support for this exporter will end July 2023.
"""

default_config = {
**Collector.default_config,
"disabled": True,
"mode": "console",
"exporter": "console",
"exporter_kwargs": {},
}

@property
def mode(self) -> str:
return self.config.mode
def exporter(self) -> str:
return self.config.exporter

@property
def endpoint(self) -> Optional[str]:
Expand All @@ -100,7 +143,7 @@ def __init__(self, config: Optional[Dict[str, Any]] = None, *args, **kwargs):
self.otel = OTelInitiator()
self.otel.initialize(
service_name="duetector",
exporter=self.mode,
exporter=self.exporter,
exporter_kwargs=self.exporter_kwargs,
)

Expand Down
2 changes: 1 addition & 1 deletion duetector/static/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ include_extension = true
[collector.otelcollector]
disabled = true
statis_id = ""
mode = "console"
exporter = "console"

[collector.otelcollector.backend_args]
max_workers = 10
Expand Down
2 changes: 1 addition & 1 deletion tests/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ include_extension = true
[collector.otelcollector]
disabled = false
statis_id = ""
mode = "console"
exporter = "console"

[collector.otelcollector.backend_args]
max_workers = 10
Expand Down

0 comments on commit e726f24

Please sign in to comment.