Library Search
结果页

Python OpenTelemetry 链路追踪实战

在 技术栈 中找到 8 个匹配结果。

返回文档库
技术栈

技术栈

8 个
查看全部
Jaeger ## 目标 在 Python Flask 微服务中使用 OpenTelemetry SDK 自动采集 Trace,上报到 Jaeger,可视化请求链路和耗时分布。 ## 完整代码 ### 架构 ``` Client → ServiceA(:5000) → ServiceB(:5001) ↓ OTLP ↓ OTLP Jaeger… 3% Redis ## 第三步:缓存加速效果对比 ```python import timeit def without_cache(): time.sleep(0.05) # 模拟每次 DB 查询 return {"data": "result"} def with_cache(): cached = r.get("expensive_data") if cached:… 2% PyTorch (TensorFlow 1.x):** 先定义完整图 → 编译 → 运行 ```python # TF 1.x 风格(不再推荐) x = tf.placeholder(tf.float32, shape=[None, 784]) W = tf.Variable(tf.zeros([784, 10])) y = tf.matmul(x, W) # 这时还没执行,只是在建图 # ... sessio… 2% LangChain ```python from langchain.memory import ConversationSummaryMemory memory = ConversationSummaryMemory(llm=llm, return_messages=True) # 第一个对话 memory.save_context({"input": "我叫小明"}, {"output": "你好小明!"})… 2% Keras ```python class MyModel(keras.Model): def __init__(self): super().__init__() self.dense1 = layers.Dense(64, activation='relu') self.dense2 = layers.Dense(10, activation='so… 2% Scrapy e.close() ``` 在 `settings.py` 中启用: ```python ITEM_PIPELINES = { "bookscraper.pipelines.PriceCleanPipeline": 300, "bookscraper.pipelines.JsonWriterPipeline": 800, } ``` --- ## 第 3 章:中间件 — 反… 2% gRPC ```go // 服务端一元拦截器 func loggingInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { start := time.Now() resp, err… 2% Python # Python 安装指南 ## 1. 环境准备 ### 操作系统支持 - **Windows**:Windows 10/11(x86-64 / ARM64) - **macOS**:macOS 11 Big Sur 及以上(Intel / Apple Silicon) - **Linux**:主流发行版(Ubuntu 20.04+/Debian 11+/CentOS 8+/Fedora 36… 2%