Springboot 整合 skywalking

1. skywalking

官网:https://skywalking.apache.org/

特点:

1.SkyWalking: 一个开源的可观测平台, 用于从服务和云原生基础设施收集, 分析, 聚合及可视化数据。
2.SkyWalking 更是一个现代化的应用程序性能监控(Application Performance Monitoring)系统, 尤其专为云原生、基于容器的分布式系统设计.

2.架构

在这里插入图片描述

2.1 架构组件简介

1. 上部分Agent: 负责从应用中,收集链路信息,发给Skywalking  oap 服务器.
2. 下部分Skywalking oap: 负责接收到Agent 发送的Tracing 的数据信息,然后进行分析(Analysis platform) ,存储到外部存储器最终提供query  查询功能.
3.左边Storage: Tracing数据存储,目前支持ES、MySQL、Sharding Sphere、TiDB、H2多种存储器,目前采用较多的是ES,主要考虑是SkyWalking开发团队自己的生产环境采用ES为主.
4.右边UI:负责提供控制台,查看链路等等;

###2.2 目录简介
在这里插入图片描述

3. 启动skywalking 默认的配置服务

[root@basenode bin]# ./startup.sh 
SkyWalking OAP started successfully!
SkyWalking Web Application started successfully!
[root@basenode bin]# pwd
/opt/module/skywalking-apm-bin-es7/bin
[root@basenode bin]# 

4. 页面访问地址

http://192.168.1.180:8080/
在这里插入图片描述

4.1 有时候8080 的端口被占用后, 我们可以修改端口

直接修改8080 端口

[root@basenode webapp]# pwd
/opt/module/skywalking-apm-bin-es7/webapp
[root@basenode skywalking-apm-bin-es7]# cd webapp/
[root@basenode webapp]# ll
总用量 35360
-rw-r--r-- 1 1001 1002 36201156 730 21:36 skywalking-webapp.jar
-rw-r--r-- 1 1001 1002     1346 730 20:32 webapp.yml
[root@basenode webapp]# vi  webapp.yml 

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

server:
  port: 8080

spring:
  cloud:
    gateway:
      routes:
        - id: oap-route
          uri: lb://oap-service
          predicates:
            - Path=/graphql/**

5. 找一个spring boot 项目 运行

命令:

java -javaagent:/opt/module/skywalking-apm-bin-es7/agent/skywalking-agent.jar -jar /opt/module/demo/user-center-0.0.1-SNAPSHOT.jar

5.1 然后访问自己的spring boot 项目

在这里插入图片描述

6. 然后看Syywalking

在这里插入图片描述
在这里插入图片描述

7. 或者写一个脚本

[root@basenode demo]# vi startup.sh 

#!/bin/sh
# SkyWalking Agent配置
export SW_AGENT_NAME=springboot-skywalking-wudl #Agent名字,一般使用`spring.application.name`
export SW_AGENT_COLLECTOR_BACKEND_SERVICES=192.168.1.180:11800 #配置 Collector 地址。
export SW_AGENT_SPAN_LIMIT=2000 #配置链路的最大Span数量,默认为 300。
export JAVA_AGENT=-javaagent:/opt/module/skywalking-apm-bin-es7/agent/skywalking-agent.jar
java $JAVA_AGENT -jar /opt/module/demo/user-center-0.0.1-SNAPSHOT.jar #jar启动

7.1 运行 : sh startup.sh

[root@basenode demo]# sh startup.sh 
DEBUG 2021-09-12 18:01:30:050 main AgentPackagePath : The beacon class location is jar:file:/opt/module/skywalking-apm-bin-es7/agent/skywalking-agent.jar!/org/apache/skywalking/apm/agent/core/boot/AgentPackagePath.class. 
INFO 2021-09-12 18:01:30:051 main SnifferConfigInitializer : Config file found in /opt/module/skywalking-apm-bin-es7/agent/config/agent.config. 

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.2.RELEASE)

2021-09-12 18:01:39.170  INFO 5590 --- [           main] c.wudl.usercenter.UserCenterApplication  : Starting UserCenterApplication v0.0.1-SNAPSHOT on basenode with PID 5590 (/opt/module/demo/user-center-0.0.1-SNAPSHOT.jar started by root in /opt/module/demo)
2021-09-12 18:01:39.177  INFO 5590 --- [           main] c.wudl.usercenter.UserCenterApplication  : The following profiles are active: dev
2021-09-12 18:01:43.948  INFO 5590 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 9909 (http)
2021-09-12 18:01:44.050  INFO 5590 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-09-12 18:01:44.050  INFO 5590 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.29]
2021-09-12 18:01:44.196  INFO 5590 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-09-12 18:01:44.197  INFO 5590 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 4819 ms
2021-09-12 18:01:47.260  INFO 5590 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-09-12 18:01:47.956  INFO 5590 --- [           main] t.m.m.autoconfigure.MapperCacheDisabler  : Clear tk.mybatis.mapper.util.MsUtil CLASS_CACHE cache.
2021-09-12 18:01:47.956  INFO 5590 --- [           main] t.m.m.autoconfigure.MapperCacheDisabler  : Clear tk.mybatis.mapper.genid.GenIdUtil CACHE cache.
2021-09-12 18:01:47.957  INFO 5590 --- [           main] t.m.m.autoconfigure.MapperCacheDisabler  : Clear tk.mybatis.mapper.version.VersionUtil CACHE cache.
2021-09-12 18:01:47.957  INFO 5590 --- [           main] t.m.m.autoconfigure.MapperCacheDisabler  : Clear EntityHelper entityTableMap cache.
2021-09-12 18:01:48.365  INFO 5590 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 9909 (http) with context path ''
2021-09-12 18:01:48.370  INFO 5590 --- [           main] c.wudl.usercenter.UserCenterApplication  : Started UserCenterApplication in 11.576 seconds (JVM running for 18.419)

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你好!关于Spring Boot与SkyWalking整合,你可以按照以下步骤进行操作: 1. 添加SkyWalking依赖:在你的Spring Boot项目的pom.xml文件中,添加SkyWalking的依赖项。你可以根据你使用的SkyWalking版本选择相应的依赖。例如,对于SkyWalking 8.x版本,你可以添加以下依赖: ```xml <dependency> <groupId>org.apache.skywalking</groupId> <artifactId>apm-toolkit-logback-1.x</artifactId> <version>${skywalking.version}</version> </dependency> ``` 2. 配置SkyWalking代理:SkyWalking需要一个代理来收集应用程序的跟踪数据。你可以通过以下方式进行配置: - 在启动脚本中设置JVM参数:在你运行Spring Boot应用程序的启动脚本中,添加以下JVM参数: ``` -javaagent:/path/to/skywalking-agent.jar ``` 请将`/path/to/skywalking-agent.jar`替换为你的SkyWalking代理的路径和文件名。 - 或者,使用SkyWalking提供的插件将代理添加到构建工具中,例如Maven或Gradle。 3. 配置SkyWalking服务器地址:在你的Spring Boot项目的配置文件(application.properties或application.yml)中,添加以下配置项: ```properties skywalking.agent.service_name=your_application_name skywalking.collector.backend_service=your_skywalking_collector_address ``` 将`your_application_name`替换为你的应用程序名称,`your_skywalking_collector_address`替换为你的SkyWalking服务器地址。 4. 启动应用程序:现在,你可以启动你的Spring Boot应用程序,并让它与SkyWalking代理一起运行。应用程序的跟踪数据将发送到SkyWalking服务器并进行分析。 请注意,以上步骤只是简单介绍了Spring Boot与SkyWalking的基本整合方法。根据你的具体需求和SkyWalking的版本,你可能需要进行更多的配置和调整。你可以参考SkyWalking官方文档以获取更详细的信息和指导。希望能对你有所帮助!如果还有其他问题,请随时提问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值