Giter VIP home page Giter VIP logo

sls-aliyun's Introduction

阿里云SLS日志服务接入DEMO

演示如何使用github.com/toniz/otel把Go程序的日志上传到Aliyun的SLS服务。

目录说明

  • server HTTP服务编写举例
  • client 客户端Go程序编写举例
  • pack1 pack2 演示HTTP服务调用外部包如何传递调用关系。

使用

  • 参考aliyun的SLS服务手册创建project和service.
  • 填写server和client的trace_config.json文件。
  • 编译和运行

其它模块加入trace调用

redis模块:

  1. 头文件添加:
import redis "github.com/go-redis/redis/v8"
import "github.com/go-redis/redis/extra/redisotel/v8"
  1. redis初始化:
rc = redis.NewClient(&redis.Options{
    Addr:     "127.0.0.1:6379",
    Password: "",
    DB:       0,
})
  1. 给redis实例加上钩子
rc.AddHook(redisotel.NewTracingHook())
  1. 正常使用redis各种指令就都会记录到trace.

结果演示:

调用结果在阿里云的SLS服务里面查看: result1

result2

result3

etc..

sls-aliyun's People

Contributors

toniz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.