├── .angular-cli.json
├── .editorconfig
├── .gitignore
├── LICENSE
├── README.md
├── e2e
├── app.e2e-spec.ts
├── app.po.ts
└── tsconfig.e2e.json
├── karma.conf.js
├── package-lock.json
├── package.json
├── protractor.conf.js
├── src
├── app
│ ├── app-routing.module.ts
│ ├── app.component.css
│ ├── app.component.html
│ ├── app.component.spec.ts
│ ├── app.component.ts
│ ├── app.module.ts
│ ├── app.utils.ts
│ ├── dashboard
│ │ ├── application
│ │ │ ├── application.component.css
│ │ │ ├── application.component.html
│ │ │ ├── application.component.spec.ts
│ │ │ └── application.component.ts
│ │ ├── dashboard-routing.module.ts
│ │ ├── dashboard.module.ts
│ │ └── overview
│ │ │ ├── overview.component.css
│ │ │ ├── overview.component.html
│ │ │ ├── overview.component.spec.ts
│ │ │ └── overview.component.ts
│ ├── models
│ │ ├── dependency.viewModel.ts
│ │ ├── page.viewModel.ts
│ │ ├── search.viewModel.ts
│ │ ├── spandetail.viewModel.ts
│ │ ├── trace.viewModel.ts
│ │ └── tracedetail.viewModel.ts
│ ├── services
│ │ ├── trace.service.ts
│ │ └── url.utils.ts
│ └── tracing
│ │ ├── dependency
│ │ ├── dependency.component.css
│ │ ├── dependency.component.html
│ │ ├── dependency.component.spec.ts
│ │ └── dependency.component.ts
│ │ ├── span
│ │ ├── span.component.css
│ │ ├── span.component.html
│ │ ├── span.component.spec.ts
│ │ └── span.component.ts
│ │ ├── trace
│ │ ├── trace.component.css
│ │ ├── trace.component.html
│ │ ├── trace.component.spec.ts
│ │ └── trace.component.ts
│ │ ├── traces
│ │ ├── traces.component.css
│ │ ├── traces.component.html
│ │ ├── traces.component.spec.ts
│ │ └── traces.component.ts
│ │ ├── tracing-routing.module.ts
│ │ └── tracing.module.ts
├── assets
│ └── .gitkeep
├── environments
│ ├── environment.prod.ts
│ └── environment.ts
├── index.html
├── main.ts
├── polyfills.ts
├── styles.css
├── test.ts
├── tsconfig.app.json
├── tsconfig.spec.json
└── typings.d.ts
├── tsconfig.json
└── tslint.json
/.angular-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "project": {
4 | "name": "butterfly-ui"
5 | },
6 | "apps": [
7 | {
8 | "root": "src",
9 | "outDir": "dist",
10 | "assets": [
11 | "assets"
12 | ],
13 | "index": "index.html",
14 | "main": "main.ts",
15 | "polyfills": "polyfills.ts",
16 | "test": "test.ts",
17 | "tsconfig": "tsconfig.app.json",
18 | "testTsconfig": "tsconfig.spec.json",
19 | "prefix": "app",
20 | "styles": [
21 | "styles.css",
22 | "../node_modules/vis/dist/vis-network.min.css"
23 | ],
24 | "scripts": [],
25 | "environmentSource": "environments/environment.ts",
26 | "environments": {
27 | "dev": "environments/environment.ts",
28 | "prod": "environments/environment.prod.ts"
29 | }
30 | }
31 | ],
32 | "e2e": {
33 | "protractor": {
34 | "config": "./protractor.conf.js"
35 | }
36 | },
37 | "lint": [
38 | {
39 | "project": "src/tsconfig.app.json",
40 | "exclude": "**/node_modules/**"
41 | },
42 | {
43 | "project": "src/tsconfig.spec.json",
44 | "exclude": "**/node_modules/**"
45 | },
46 | {
47 | "project": "e2e/tsconfig.e2e.json",
48 | "exclude": "**/node_modules/**"
49 | }
50 | ],
51 | "test": {
52 | "karma": {
53 | "config": "./karma.conf.js"
54 | }
55 | },
56 | "defaults": {
57 | "styleExt": "css",
58 | "component": {}
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist
5 | /tmp
6 | /out-tsc
7 |
8 | # dependencies
9 | /node_modules
10 |
11 | # IDEs and editors
12 | /.idea
13 | .project
14 | .classpath
15 | .c9/
16 | *.launch
17 | .settings/
18 | *.sublime-workspace
19 |
20 | # IDE - VSCode
21 | .vscode/*
22 | !.vscode/settings.json
23 | !.vscode/tasks.json
24 | !.vscode/launch.json
25 | !.vscode/extensions.json
26 |
27 | # misc
28 | /.sass-cache
29 | /connect.lock
30 | /coverage
31 | /libpeerconnection.log
32 | npm-debug.log
33 | testem.log
34 | /typings
35 |
36 | # e2e
37 | /e2e/*.js
38 | /e2e/*.map
39 |
40 | # System Files
41 | .DS_Store
42 | Thumbs.db
43 | package-lock.json
44 |
45 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 ButterflyAPM
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # butterfly-ui
2 | Web UI for Butterfly
3 |
--------------------------------------------------------------------------------
/e2e/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AppPage } from './app.po';
2 |
3 | describe('demo1 App', () => {
4 | let page: AppPage;
5 |
6 | beforeEach(() => {
7 | page = new AppPage();
8 | });
9 |
10 | it('should display welcome message', () => {
11 | page.navigateTo();
12 | expect(page.getParagraphText()).toEqual('Welcome to app!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/e2e/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class AppPage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getParagraphText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/e2e",
5 | "baseUrl": "./",
6 | "module": "commonjs",
7 | "target": "es5",
8 | "types": [
9 | "jasmine",
10 | "jasminewd2",
11 | "node"
12 | ]
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular/cli'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular/cli/plugins/karma')
14 | ],
15 | client:{
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | reports: [ 'html', 'lcovonly' ],
20 | fixWebpackSourcePaths: true
21 | },
22 | angularCli: {
23 | environment: 'dev'
24 | },
25 | reporters: ['progress', 'kjhtml'],
26 | port: 9876,
27 | colors: true,
28 | logLevel: config.LOG_INFO,
29 | autoWatch: true,
30 | browsers: ['Chrome'],
31 | singleRun: false
32 | });
33 | };
34 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "butterfly-ui",
3 | "version": "0.0.1",
4 | "license": "MIT",
5 | "scripts": {
6 | "ng": "ng",
7 | "start": "ng serve",
8 | "build": "ng build --prod",
9 | "test": "ng test",
10 | "lint": "ng lint",
11 | "e2e": "ng e2e"
12 | },
13 | "private": true,
14 | "dependencies": {
15 | "@angular/animations": "^5.0.0",
16 | "@angular/common": "^5.0.0",
17 | "@angular/compiler": "^5.0.0",
18 | "@angular/core": "^5.0.0",
19 | "@angular/forms": "^5.0.0",
20 | "@angular/http": "^5.0.0",
21 | "@angular/platform-browser": "^5.0.0",
22 | "@angular/platform-browser-dynamic": "^5.0.0",
23 | "@angular/router": "^5.0.0",
24 | "@antv/g2": "^3.0.5-beta.1",
25 | "@types/echarts": "0.0.9",
26 | "core-js": "^2.4.1",
27 | "echarts": "^3.8.5",
28 | "ng-zorro-antd": "^0.6.7",
29 | "rxjs": "^5.5.6",
30 | "vis": "^4.21.0",
31 | "zone.js": "^0.8.14"
32 | },
33 | "devDependencies": {
34 | "@angular/cli": "1.6.1",
35 | "@angular/compiler-cli": "^5.0.0",
36 | "@angular/language-service": "^5.0.0",
37 | "@types/jasmine": "~2.5.53",
38 | "@types/jasminewd2": "~2.0.2",
39 | "@types/node": "~6.0.60",
40 | "codelyzer": "^4.0.1",
41 | "jasmine-core": "~2.6.2",
42 | "jasmine-spec-reporter": "~4.1.0",
43 | "karma": "~1.7.0",
44 | "karma-chrome-launcher": "~2.1.1",
45 | "karma-cli": "~1.0.1",
46 | "karma-coverage-istanbul-reporter": "^1.2.1",
47 | "karma-jasmine": "~1.1.0",
48 | "karma-jasmine-html-reporter": "^0.2.2",
49 | "protractor": "~5.1.2",
50 | "ts-node": "~3.2.0",
51 | "tslint": "~5.7.0",
52 | "typescript": "~2.4.2"
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | const { SpecReporter } = require('jasmine-spec-reporter');
5 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './e2e/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | onPrepare() {
23 | require('ts-node').register({
24 | project: 'e2e/tsconfig.e2e.json'
25 | });
26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/src/app/app-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { RouterModule, Routes } from '@angular/router';
3 | import { DashboardModule } from './dashboard/dashboard.module';
4 | import { TracingModule } from './tracing/tracing.module';
5 |
6 | const routes: Routes = [
7 | { path: '', redirectTo: '/tracing/traces', pathMatch: 'full' },
8 | { path: 'dashboard', loadChildren: 'app/dashboard/dashboard.module#DashboardModule'},
9 | { path: 'tracing', loadChildren: 'app/tracing/tracing.module#TracingModule'},
10 | ];
11 |
12 | @NgModule({
13 | imports: [
14 | RouterModule.forRoot(routes),
15 | DashboardModule,
16 | TracingModule
17 | ],
18 | exports: [RouterModule]
19 | })
20 | export class AppRoutingModule { }
--------------------------------------------------------------------------------
/src/app/app.component.css:
--------------------------------------------------------------------------------
1 | :host ::ng-deep .logo {
2 | height: 32px;
3 | border-radius: 6px;
4 | margin: 16px;
5 | }
6 |
7 | :host ::ng-deep .ant-layout-sider-collapsed .nav-text {
8 | display: none;
9 | }
10 |
11 | :host ::ng-deep .ant-layout-sider-collapsed .ant-menu-submenu-title:after {
12 | display: none;
13 | }
14 |
15 | :host ::ng-deep .ant-layout-sider-collapsed .anticon {
16 | font-size: 16px;
17 | margin-left: 8px;
18 | }
19 |
20 | :host ::ng-deep .trigger {
21 | font-size: 18px;
22 | line-height: 64px;
23 | padding: 0 16px;
24 | cursor: pointer;
25 | transition: color .3s;
26 | }
27 |
28 | :host ::ng-deep .trigger:hover {
29 | color: #108ee9;
30 | }
31 |
32 | nz-layout {
33 | height: 100%;
34 | }
35 |
36 | .logo h1 a{
37 | font-size: 16px;
38 | color: #fff;
39 | opacity: 0.8;
40 | line-height: 31px;
41 | margin-left: 10px;
42 | }
43 |
44 | ul li {
45 | outline: none;
46 | }
47 |
--------------------------------------------------------------------------------
/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
19 | -
20 |
21 |
22 | Traces
23 |
24 |
25 | -
26 |
27 |
28 | Dependencies
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | {{nav}}
40 |
41 |
42 |
43 |
44 |
45 | Butterfly APM ©2018
46 |
47 |
--------------------------------------------------------------------------------
/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 | import { AppComponent } from './app.component';
3 | describe('AppComponent', () => {
4 | beforeEach(async(() => {
5 | TestBed.configureTestingModule({
6 | declarations: [
7 | AppComponent
8 | ],
9 | }).compileComponents();
10 | }));
11 | it('should create the app', async(() => {
12 | const fixture = TestBed.createComponent(AppComponent);
13 | const app = fixture.debugElement.componentInstance;
14 | expect(app).toBeTruthy();
15 | }));
16 | it(`should have as title 'app'`, async(() => {
17 | const fixture = TestBed.createComponent(AppComponent);
18 | const app = fixture.debugElement.componentInstance;
19 | expect(app.title).toEqual('app');
20 | }));
21 | it('should render title in a h1 tag', async(() => {
22 | const fixture = TestBed.createComponent(AppComponent);
23 | fixture.detectChanges();
24 | const compiled = fixture.debugElement.nativeElement;
25 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
26 | }));
27 | });
28 |
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { Route, Router, NavigationEnd } from '@angular/router';
3 | import * as G2 from '@antv/g2';
4 |
5 | @Component({
6 | selector: 'app-root',
7 | templateUrl: './app.component.html',
8 | styleUrls: ['./app.component.css']
9 | })
10 |
11 | export class AppComponent implements OnInit {
12 |
13 | isCollapsed = false;
14 | breadcrumbs;
15 |
16 | constructor(private router: Router) {
17 | G2.track(false);
18 | }
19 |
20 | ngOnInit() {
21 | this.router.events.subscribe((event: any) => {
22 | if (event instanceof NavigationEnd) {
23 | this.breadcrumbs = event.urlAfterRedirects.split('/').filter(x => x != "");
24 | this.subNavsQueryString(this.breadcrumbs);
25 | }
26 | });
27 | }
28 |
29 | subNavsQueryString(breadcrumbs: string[]): void {
30 | for (let i = 0; i < breadcrumbs.length; i++) {
31 | const item = breadcrumbs[i];
32 | const indexOf = item.indexOf('?');
33 | if (indexOf !== -1) {
34 | breadcrumbs[i] = item.substring(0, indexOf);
35 | }
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
3 | import { NgModule } from '@angular/core';
4 | import { FormsModule } from '@angular/forms';
5 | import { HttpModule } from '@angular/http';
6 | import { NgZorroAntdModule } from 'ng-zorro-antd';
7 | import { NZ_LOCALE, enUS } from 'ng-zorro-antd';
8 | import { AppComponent } from './app.component';
9 | import { RouterModule } from '@angular/router';
10 | import { AppRoutingModule } from './app-routing.module';
11 | import { DashboardModule } from './dashboard/dashboard.module';
12 | import { HttpClientModule } from '@angular/common/http';
13 | import { TracingModule } from './tracing/tracing.module';
14 | import { TraceService } from './services/trace.service';
15 | import { UrlUtils } from './services/url.utils';
16 | import { SpanComponent } from './tracing/span/span.component';
17 |
18 | @NgModule({
19 | declarations: [
20 | AppComponent
21 | ],
22 | imports: [
23 | BrowserModule,
24 | FormsModule,
25 | HttpModule,
26 | BrowserAnimationsModule,
27 | HttpClientModule,
28 | NgZorroAntdModule.forRoot(),
29 | RouterModule,
30 | AppRoutingModule,
31 | DashboardModule,
32 | TracingModule
33 | ],
34 | bootstrap: [AppComponent],
35 | providers: [
36 | { provide: NZ_LOCALE, useValue: enUS },
37 | TraceService,
38 | UrlUtils
39 | ],
40 | entryComponents: [
41 | SpanComponent
42 | ]
43 | })
44 |
45 | export class AppModule {
46 | }
47 |
--------------------------------------------------------------------------------
/src/app/app.utils.ts:
--------------------------------------------------------------------------------
1 | export const utils = {
2 | toDisplayDuration(duration: number): string {
3 | return duration < 1000 ? duration + ' μs' : (duration / 1000.0).toFixed(2) + ' ms';
4 | }
5 | };
6 |
--------------------------------------------------------------------------------
/src/app/dashboard/application/application.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuhaoyang/butterfly-ui/31e3b51fd8915bd2f8d925d36649d162ec9d37ac/src/app/dashboard/application/application.component.css
--------------------------------------------------------------------------------
/src/app/dashboard/application/application.component.html:
--------------------------------------------------------------------------------
1 |
2 | application works!
3 |
4 |
--------------------------------------------------------------------------------
/src/app/dashboard/application/application.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { ApplicationComponent } from './application.component';
4 |
5 | describe('ApplicationComponent', () => {
6 | let component: ApplicationComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ ApplicationComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(ApplicationComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/dashboard/application/application.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-application',
5 | templateUrl: './application.component.html',
6 | styleUrls: ['./application.component.css']
7 | })
8 | export class ApplicationComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/dashboard/dashboard-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { RouterModule, Routes } from '@angular/router';
3 | import { ApplicationComponent } from './application/application.component';
4 | import { OverviewComponent } from './overview/overview.component';
5 | import { componentFactoryName } from '@angular/compiler';
6 |
7 | const routes: Routes = [
8 | {
9 | path: 'dashboard',
10 | children: [
11 | { path: 'overview', component: OverviewComponent },
12 | { path: 'application', component: ApplicationComponent }
13 | ]
14 | }
15 | ];
16 |
17 | @NgModule({
18 | imports: [RouterModule.forChild(routes)],
19 | exports: [RouterModule]
20 | })
21 | export class DashboardRoutingModule { }
--------------------------------------------------------------------------------
/src/app/dashboard/dashboard.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
3 | import { NgModule } from '@angular/core';
4 | import { FormsModule } from '@angular/forms';
5 | import { HttpModule } from '@angular/http';
6 | import { NgZorroAntdModule } from 'ng-zorro-antd';
7 | import { RouterModule } from '@angular/router';
8 | import { DashboardRoutingModule } from './dashboard-routing.module';
9 | import { ApplicationComponent } from './application/application.component';
10 | import { OverviewComponent } from './overview/overview.component';
11 |
12 | @NgModule({
13 | declarations: [
14 | ApplicationComponent,
15 | OverviewComponent
16 | ],
17 | imports: [
18 | BrowserModule,
19 | FormsModule,
20 | HttpModule,
21 | BrowserAnimationsModule,
22 | NgZorroAntdModule.forRoot(),
23 | RouterModule,
24 | DashboardRoutingModule
25 | ]
26 | })
27 |
28 | export class DashboardModule {
29 | }
30 |
--------------------------------------------------------------------------------
/src/app/dashboard/overview/overview.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuhaoyang/butterfly-ui/31e3b51fd8915bd2f8d925d36649d162ec9d37ac/src/app/dashboard/overview/overview.component.css
--------------------------------------------------------------------------------
/src/app/dashboard/overview/overview.component.html:
--------------------------------------------------------------------------------
1 |
2 | overview works!
3 |
4 |
--------------------------------------------------------------------------------
/src/app/dashboard/overview/overview.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { OverviewComponent } from './overview.component';
4 |
5 | describe('OverviewComponent', () => {
6 | let component: OverviewComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ OverviewComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(OverviewComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/dashboard/overview/overview.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-overview',
5 | templateUrl: './overview.component.html',
6 | styleUrls: ['./overview.component.css']
7 | })
8 | export class OverviewComponent implements OnInit {
9 |
10 | module: string;
11 | constructor() {
12 | this.module ="Dashboard"
13 | }
14 |
15 | ngOnInit() {
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/app/models/dependency.viewModel.ts:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/src/app/models/page.viewModel.ts:
--------------------------------------------------------------------------------
1 | export class PageViewModel {
2 |
3 | totalPageCount: number;
4 |
5 | totalMemberCount: number;
6 |
7 | pageNumber: number = 1;
8 |
9 | pageSize: number = 10;
10 |
11 | data: T[] = [];
12 | }
--------------------------------------------------------------------------------
/src/app/models/search.viewModel.ts:
--------------------------------------------------------------------------------
1 | export class TimestampSearchViewModel {
2 |
3 | startTimestamp: Date;
4 |
5 | finishTimestamp: Date;
6 |
7 | constructor() {
8 | this.finishTimestamp = new Date();
9 | this.startTimestamp = new Date();
10 | this.startTimestamp.setMinutes(this.startTimestamp.getMinutes() - 60);
11 | }
12 | }
--------------------------------------------------------------------------------
/src/app/models/spandetail.viewModel.ts:
--------------------------------------------------------------------------------
1 |
2 | export class SpanDetailViewModel {
3 |
4 | spanId: string;
5 |
6 | sampled: boolean;
7 |
8 | operationName: string;
9 |
10 | serviceName: string;
11 |
12 | duration: number;
13 |
14 | displayDuration: string;
15 |
16 | startTimestamp: Date;
17 |
18 | finishTimestamp: Date;
19 |
20 | tags: KeyValuePair[] = [];
21 |
22 | logs: LogViewModel[] = [];
23 | }
24 |
25 | export class LogViewModel {
26 |
27 | timestamp: Date;
28 |
29 | fields: KeyValuePair[];
30 | }
31 |
32 | export class KeyValuePair {
33 |
34 | key: string;
35 |
36 | value: string;
37 | }
38 |
39 | export class LogFieldViewModel {
40 |
41 | timestamp: Date;
42 |
43 | name: string;
44 |
45 | value: string;
46 |
47 | showTimestamp: boolean;
48 |
49 | constructor(timestamp: Date, name: string, value: string) {
50 | this.timestamp = timestamp;
51 | this.value = value;
52 | this.showTimestamp = false;
53 | this.name = name;
54 | }
55 | }
--------------------------------------------------------------------------------
/src/app/models/trace.viewModel.ts:
--------------------------------------------------------------------------------
1 | export class TraceViewModel {
2 |
3 | traceId: string;
4 |
5 | duration: number;
6 |
7 | startTimestamp: Date;
8 |
9 | finishTimestamp: Date;
10 |
11 | services: TraceServiceViewModel[];
12 |
13 | displayServices: DisplayServiceViewModel[];
14 |
15 | displayDuration: string;
16 |
17 | durationWidth: number;
18 |
19 | }
20 |
21 | export class TraceServiceViewModel {
22 | name: string;
23 | }
24 |
25 | export class DisplayServiceViewModel {
26 |
27 | name: string;
28 | count: number;
29 |
30 | constructor(name: string, count: number) {
31 | this.name = name;
32 | this.count = count;
33 | }
34 | }
35 |
36 | export class SearchTraceViewModel {
37 |
38 | service: string;
39 |
40 | startTimestamp: Date;
41 |
42 | finishTimestamp: Date;
43 |
44 | tags: string;
45 |
46 | limit: number;
47 |
48 | constructor() {
49 | this.limit = 10;
50 | this.finishTimestamp = new Date();
51 | this.startTimestamp = new Date();
52 | this.startTimestamp.setMinutes(this.startTimestamp.getMinutes() - 60);
53 | }
54 | }
55 |
56 | export class TraceHistogramViewModel{
57 | time: string;
58 | count: number;
59 | }
60 |
--------------------------------------------------------------------------------
/src/app/models/tracedetail.viewModel.ts:
--------------------------------------------------------------------------------
1 | export class TraceDetailViewModel {
2 |
3 | traceId: string;
4 |
5 | duration: number;
6 |
7 | startTimestamp: Date;
8 |
9 | finishTimestamp: Date;
10 |
11 | displayDuration: string;
12 |
13 | spans: SpanViewModel[] = [];
14 |
15 | services: number;
16 | }
17 |
18 | export class SpanViewModel {
19 |
20 | spanId: string;
21 |
22 | sampled: boolean;
23 |
24 | operationName: string;
25 |
26 | serviceName: string;
27 |
28 | duration: number;
29 |
30 | offset: number;
31 |
32 | startTimestamp: Date;
33 |
34 | finishTimestamp: Date;
35 |
36 | displayDuration: string;
37 |
38 | displayOffset: number;
39 |
40 | displayWidth: number;
41 |
42 | children: SpanViewModel[];
43 |
44 | parent: SpanViewModel;
45 |
46 | expand: boolean;
47 |
48 | hasChildren: boolean;
49 |
50 | level: number;
51 | }
--------------------------------------------------------------------------------
/src/app/services/trace.service.ts:
--------------------------------------------------------------------------------
1 | import { HttpClient, HttpParams } from '@angular/common/http';
2 | import { Injectable } from '@angular/core';
3 | import { UrlUtils } from './url.utils';
4 | import { PageViewModel } from '../models/page.viewModel';
5 | import { TraceViewModel, TraceServiceViewModel, DisplayServiceViewModel, SearchTraceViewModel } from '../models/trace.viewModel';
6 | import { TraceHistogramViewModel } from '../models/trace.viewModel';
7 | import { forEach } from '@angular/router/src/utils/collection';
8 | import { TraceDetailViewModel, SpanViewModel } from '../models/tracedetail.viewModel';
9 | import { SpanDetailViewModel } from '../models/spandetail.viewModel';
10 | import { TimestampSearchViewModel } from '../models/search.viewModel';
11 | import { utils } from '../app.utils';
12 |
13 | @Injectable()
14 | export class TraceService {
15 |
16 | constructor(private http: HttpClient, private url: UrlUtils) {
17 | }
18 |
19 | async getTraces(search: SearchTraceViewModel): Promise {
20 |
21 | let httpParams = new HttpParams()
22 | .set('limit', search.limit.toString());
23 |
24 | if (search.service != null) {
25 | httpParams = httpParams.set('service', search.service);
26 | }
27 |
28 | if (search.tags != null) {
29 | httpParams = httpParams.set('tags', search.tags);
30 | }
31 |
32 | if (search.startTimestamp != null) {
33 | httpParams = httpParams.set('startTimestamp', search.startTimestamp.valueOf().toString());
34 | }
35 |
36 | if (search.finishTimestamp != null) {
37 | httpParams = httpParams.set('finishTimestamp', search.finishTimestamp.valueOf().toString());
38 | }
39 |
40 | const result = await this.http.get(this.url.getTrace, { params: httpParams }).toPromise();
41 |
42 | if (result.length === 0) {
43 | return result;
44 | }
45 |
46 | const maxDuration = this.max(result, x => x.duration);
47 |
48 | for (const item of result) {
49 | const traceServiceMap = new Map();
50 | for (const service of item.services) {
51 | if (traceServiceMap.has(service.name)) {
52 | traceServiceMap.get(service.name).push(service);
53 | }
54 | else {
55 | traceServiceMap.set(service.name, [service]);
56 | }
57 | }
58 | const displayServices = [];
59 | // todo
60 | traceServiceMap.forEach((v, k) => {
61 | displayServices.push(new DisplayServiceViewModel(k, v.length));
62 | });
63 | item.displayServices = displayServices;
64 | item.displayDuration = utils.toDisplayDuration(item.duration);
65 | item.durationWidth = item.duration / maxDuration * 100;
66 | if (item.durationWidth < 4) {
67 | item.durationWidth = 4;
68 | }
69 | }
70 |
71 | return result;
72 | }
73 |
74 | async getServices(): Promise {
75 | return await this.http.get(this.url.getService).toPromise();
76 | }
77 |
78 | async getTraceDetail(traceId: string): Promise {
79 | const trace = await this.http.get(this.url.getTraceDetail + traceId).toPromise();
80 | trace.displayDuration = utils.toDisplayDuration(trace.duration);
81 | const spans = this.expandTree(trace.spans, null, 0);
82 | const services = new Map();
83 | const traceDuration = trace.duration;
84 | const start = trace.startTimestamp;
85 | for (const span of spans) {
86 | span.displayDuration = utils.toDisplayDuration(span.duration);
87 | span.displayWidth = span.duration / traceDuration * 100;
88 | span.displayOffset = span.offset / traceDuration * 100;
89 | if (!services.has(span.serviceName)) {
90 | services.set(span.serviceName, span.serviceName);
91 | }
92 | }
93 | trace.services = services.size;
94 | trace.spans = spans;
95 | return trace;
96 | }
97 |
98 | private expandTree(childern: SpanViewModel[], parent: SpanViewModel, level: number): SpanViewModel[] {
99 | let spans = [];
100 | for (let span of childern) {
101 | span.level = level;
102 | span.parent = parent;
103 | span.hasChildren = span.children && span.children.length > 0;
104 | spans.push(span);
105 | if (span.hasChildren) {
106 | let childs = this.expandTree(span.children, span, level + 1);
107 | for (let child of childs) {
108 | spans.push(child);
109 | }
110 | }
111 | }
112 | return spans;
113 | }
114 |
115 | async getSpanDetail(spanId: string): Promise {
116 | var span = await this.http.get(this.url.getSpanDetail + spanId).toPromise();
117 | span.displayDuration = utils.toDisplayDuration(span.duration);
118 | return span;
119 | }
120 |
121 | // todo use viewModel
122 | // todo symbolSize
123 | async getDependencies(search: TimestampSearchViewModel): Promise {
124 | let httpParams = new HttpParams();
125 |
126 | if (search.startTimestamp != null) {
127 | httpParams = httpParams.set('startTimestamp', search.startTimestamp.valueOf().toString());
128 | }
129 |
130 | if (search.finishTimestamp != null) {
131 | httpParams = httpParams.set('finishTimestamp', search.finishTimestamp.valueOf().toString());
132 | }
133 |
134 | return this.http.get(this.url.getDependencies, { params: httpParams }).toPromise();
135 | }
136 |
137 | async getTraceHistogram(search: SearchTraceViewModel): Promise {
138 |
139 | let httpParams = new HttpParams()
140 | .set('limit', search.limit.toString());
141 |
142 | if (search.service != null) {
143 | httpParams = httpParams.set('service', search.service);
144 | }
145 |
146 | if (search.tags != null) {
147 | httpParams = httpParams.set('tags', search.tags);
148 | }
149 |
150 | if (search.startTimestamp != null) {
151 | httpParams = httpParams.set('startTimestamp', search.startTimestamp.valueOf().toString());
152 | }
153 |
154 | if (search.finishTimestamp != null) {
155 | httpParams = httpParams.set('finishTimestamp', search.finishTimestamp.valueOf().toString());
156 | }
157 |
158 | const result = await this.http.get(this.url.getTraceHistogram, { params: httpParams }).toPromise();
159 | return result;
160 | }
161 |
162 |
163 | private max(data: T[], predicate: (x: T) => number): number {
164 | let max = 0;
165 | for (let item of data) {
166 | let itemValue = predicate(item);
167 | if (itemValue > max) {
168 | max = itemValue;
169 | }
170 | }
171 | return max;
172 | }
173 | }
174 |
--------------------------------------------------------------------------------
/src/app/services/url.utils.ts:
--------------------------------------------------------------------------------
1 | import { environment } from '../../environments/environment'
2 | import { Injectable } from '@angular/core';
3 |
4 | @Injectable()
5 | export class UrlUtils {
6 |
7 | getTrace: string;
8 | getService: string;
9 | getTraceDetail: string;
10 | getSpanDetail: string;
11 | getDependencies: string;
12 | getTraceHistogram: string;
13 |
14 | constructor() {
15 | this.getTrace = environment.collectorapi + 'trace';
16 | this.getService = environment.collectorapi + 'service';
17 | this.getTraceDetail = environment.collectorapi + 'tracedetail/';
18 | this.getSpanDetail = environment.collectorapi + 'spandetail/';
19 | this.getDependencies = environment.collectorapi + 'dependency';
20 | this.getTraceHistogram = environment.collectorapi + 'trace/histogram';
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/app/tracing/dependency/dependency.component.css:
--------------------------------------------------------------------------------
1 | .graph {
2 | text-align: center;
3 | width: 100%;
4 | height: 100%;
5 | background: rgba(0, 0, 0, .05);
6 | border-radius: 4px;
7 | margin: 5px 0;
8 | }
9 |
10 | .trace-search {
11 | width: 200px;
12 | margin-right: 10px;
13 | }
14 |
15 | .vis-item {
16 | z-index: 1;
17 | }
18 |
--------------------------------------------------------------------------------
/src/app/tracing/dependency/dependency.component.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/app/tracing/dependency/dependency.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DependencyComponent } from './dependency.component';
4 |
5 | describe('DependencyComponent', () => {
6 | let component: DependencyComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ DependencyComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DependencyComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/tracing/dependency/dependency.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, AfterViewInit } from '@angular/core';
2 | import { NzMessageService } from 'ng-zorro-antd';
3 | import { TraceService } from '../../services/trace.service';
4 | import { TimestampSearchViewModel } from '../../models/search.viewModel';
5 | import * as vis from 'vis';
6 |
7 | @Component({
8 | selector: 'app-dependency',
9 | templateUrl: './dependency.component.html',
10 | styleUrls: ['./dependency.component.css']
11 | })
12 | export class DependencyComponent implements OnInit, AfterViewInit {
13 |
14 | searchViewModel: TimestampSearchViewModel;
15 | chartHeight: string;
16 | nodeSet: vis.DataSet;
17 | edgeSet: vis.DataSet;
18 | loading: boolean;
19 |
20 | constructor(private traceService: TraceService, private message: NzMessageService) {
21 | this.searchViewModel = new TimestampSearchViewModel();
22 | this.chartHeight = 0 + 'px';
23 | }
24 |
25 | ngOnInit() {
26 | }
27 |
28 | ngAfterViewInit() {
29 | const height = document.body.clientHeight * 0.7;
30 | this.chartHeight = height + 'px';
31 | const divElement = document.getElementById('chart');
32 | divElement.style.height = this.chartHeight;
33 | this.nodeSet = new vis.DataSet();
34 | this.edgeSet = new vis.DataSet();
35 | const data = { nodes: this.nodeSet, edges: this.edgeSet };
36 | const network = new vis.Network(divElement, data, this.initOptions());
37 | this.refreshData();
38 | }
39 |
40 | async refreshData() {
41 | this.loading = true;
42 | const data = await this.traceService.getDependencies(this.searchViewModel);
43 | this.bindNode(data.nodes);
44 | this.bindEdges(data.edges);
45 | this.loading = false;
46 | }
47 |
48 | bindNode(nodeData: Array) {
49 | const nodeSet = this.nodeSet;
50 | const nodes = new Array();
51 | nodeData.forEach(item => {
52 | nodes.push({ id: item.name, label: item.name, title: item.name + ' ' + item.value });
53 | });
54 | nodeSet.clear();
55 | nodeSet.add(nodes);
56 | }
57 |
58 | bindEdges(edgeData: Array) {
59 | const edgeSet = this.edgeSet;
60 | const edges = new Array();
61 | edgeData.forEach(item => {
62 | edges.push({ from: item.source, to: item.target, title: item.source + '->' + item.target + ' ' + item.value });
63 | });
64 | edgeSet.clear();
65 | edgeSet.add(edges);
66 | }
67 |
68 | initOptions() {
69 | const options = {
70 | nodes: {
71 | shape: 'dot',
72 | size: 18,
73 | font: {
74 | size: 13
75 | },
76 | shadow: true,
77 | color: {
78 | background: '#97C2FC'
79 | }
80 | },
81 | edges: {
82 | width: 1,
83 | shadow: true,
84 | arrows: {
85 | to: {
86 | enabled: true,
87 | scaleFactor: 0.5
88 | }
89 | }
90 | },
91 | layout: {
92 | randomSeed: 1,
93 | hierarchical: {
94 | direction: 'LR',
95 | levelSeparation: 160,
96 | sortMethod: 'directed'
97 | }
98 | },
99 | interaction: {
100 | hover: true
101 | }
102 | };
103 | return options;
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/src/app/tracing/span/span.component.css:
--------------------------------------------------------------------------------
1 | :host ::ng-deep .customize-footer {
2 | border-top: 1px solid #e9e9e9;
3 | padding: 10px 18px 0 10px;
4 | text-align: right;
5 | border-radius: 0 0 0px 0px;
6 | margin: 15px -16px -5px -16px;
7 | }
8 |
9 | .tabSet{
10 | margin: 30px 0;
11 | }
12 |
13 | .table {
14 | margin: 30px 0;
15 | }
16 |
17 | .content {
18 | overflow: hidden;
19 | overflow-y: scroll;
20 | }
21 |
22 | ::-webkit-scrollbar {
23 | width: 5px;
24 | height: 1px;
25 | }
26 | ::-webkit-scrollbar-thumb {
27 | border-radius: 10px;
28 | box-shadow: inset 0 0 5px rgba(0,0,0,0.1);
29 | background: rgba(206, 199, 199, 0.2)
30 | }
31 | ::-webkit-scrollbar-track {
32 | box-shadow: inset 0 0 5px rgba(0,0,0,0.1);
33 | border-radius: 10px;
34 | background: rgb(238, 237, 237,0.5);
35 | }
--------------------------------------------------------------------------------
/src/app/tracing/span/span.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ data.serviceName }}
4 | {{ data.displayDuration }}
5 |
6 |
7 |
8 |
9 |
10 |
11 | {{ log.timestamp | date: 'yyyy-MM-dd HH:mm:ss.SSS' }}
12 |
13 |
14 |
{{ field.key }}
15 |
{{ field.value }}
16 |
17 |
18 |
19 |
20 |
21 |
49 |
50 |
51 |
52 |
53 |
54 | Tag Key
55 | |
56 |
57 | Value
58 | |
59 |
60 |
61 |
62 |
63 | {{ tag.key }} |
64 | {{ tag.value }} |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/src/app/tracing/span/span.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { SpanComponent } from './span.component';
4 |
5 | describe('SpanComponent', () => {
6 | let component: SpanComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ SpanComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(SpanComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/tracing/span/span.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, Input, OnInit } from '@angular/core';
2 | import { NzModalSubject } from 'ng-zorro-antd';
3 | import { TraceService } from '../../services/trace.service';
4 | import { SpanDetailViewModel, LogFieldViewModel, LogViewModel } from '../../models/spandetail.viewModel';
5 |
6 | @Component({
7 | selector: 'app-span',
8 | templateUrl: './span.component.html',
9 | styleUrls: ['./span.component.css']
10 | })
11 |
12 | export class SpanComponent implements OnInit {
13 |
14 | spanId: string;
15 | data: SpanDetailViewModel;
16 | logs: LogFieldViewModel[] = [];
17 | height: string;
18 | tabPosition: String;
19 |
20 | constructor(private traceService: TraceService, private subject: NzModalSubject) {
21 | this.data = new SpanDetailViewModel();
22 | }
23 |
24 | async ngOnInit() {
25 | this.tabPosition = 'left';
26 | let height = document.body.clientHeight * 0.7;
27 | this.height = height + 'px';
28 | this.data = await this.traceService.getSpanDetail(this.spanId);
29 | let logViewModels = [];
30 | for (let log of this.data.logs) {
31 | log.fields.forEach((field, index) => {
32 | let logViewModel = new LogFieldViewModel(log.timestamp, field.key, field.value);
33 | if (index == 0) {
34 | logViewModel.showTimestamp = true;
35 | }
36 | logViewModels.push(logViewModel);
37 | });
38 | }
39 | this.logs = logViewModels;
40 | }
41 |
42 | @Input()
43 | set SpanId(value: string) {
44 | this.spanId = value;
45 | }
46 | }
--------------------------------------------------------------------------------
/src/app/tracing/trace/trace.component.css:
--------------------------------------------------------------------------------
1 | .title{
2 | font-size: 13px;
3 | margin-right: 10px;
4 | font-weight: 500;
5 | }
6 |
7 | .traceDetail-data {
8 | margin-top: 20px;
9 | }
10 |
11 | .span-service {
12 | font-size: 13px;
13 | margin-right: 5px;
14 | /* font-weight: bold; */
15 | }
16 |
17 | .span-name {
18 | font-style: italic;
19 | }
20 |
21 | .span-time{
22 | text-align: right;
23 | font-weight: 500;
24 | }
25 |
26 | .timeline-header{
27 | text-align: right;
28 | }
29 |
30 | .timeline-mark {
31 | color: rgba(0, 0, 0, 0.6);
32 | font-size: 10px;
33 | }
34 |
35 | .timelin-timespan {
36 | border-right: 1px solid #dbd9d9;
37 | padding-right: 10px;
38 | }
39 |
40 | .timeline-duration {
41 | background-color: #5caddf;
42 | padding-left: 5px;
43 | padding-top: 1px;
44 | line-height: 16px;
45 | height: 20px;
46 | border-radius: 3px;
47 | font-size: 13px;
48 | transition: all 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
49 | cursor: pointer;
50 | white-space: nowrap;
51 | color: #fff;
52 | }
53 |
54 | .timeline-container{
55 | background: rgba(0, 0, 0, .04);
56 | }
57 |
58 | tr th{
59 | border-right: 1px solid #e9e9e9;
60 | }
61 |
62 | tr td{
63 | border-bottom: none;
64 | border-right: 1px solid #e9e9e9;
65 | }
66 |
--------------------------------------------------------------------------------
/src/app/tracing/trace/trace.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Duration:
4 | {{ detailViewModel.displayDuration }}
5 |
6 | Services:
7 | {{ detailViewModel.services }}
8 |
9 | Spans:
10 | {{ detailViewModel.spans.length }}
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/app/tracing/trace/trace.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { TraceComponent } from './trace.component';
4 |
5 | describe('TraceComponent', () => {
6 | let component: TraceComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ TraceComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(TraceComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/tracing/trace/trace.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { ActivatedRoute, ParamMap } from '@angular/router';
3 | import { TraceService } from '../../services/trace.service';
4 | import { TraceDetailViewModel, SpanViewModel } from '../../models/tracedetail.viewModel';
5 | import 'rxjs/add/operator/switchMap';
6 | import { utils } from "../../app.utils";
7 | import { fadeAnimation } from 'ng-zorro-antd/src/core/animation/fade-animations';
8 | import { NzModalService } from 'ng-zorro-antd';
9 | import { SpanComponent } from '../span/span.component'
10 |
11 | @Component({
12 | selector: 'app-trace',
13 | templateUrl: './trace.component.html',
14 | styleUrls: ['./trace.component.css']
15 | })
16 | export class TraceComponent implements OnInit {
17 |
18 | loading: boolean = false;
19 | detailViewModel: TraceDetailViewModel;
20 | timelines: string[] = [];
21 |
22 | constructor(private traceService: TraceService, private route: ActivatedRoute, private modalService: NzModalService) {
23 | this.detailViewModel = new TraceDetailViewModel();
24 | }
25 |
26 | ngOnInit() {
27 | this.route.paramMap
28 | .switchMap((params: ParamMap) =>
29 | this.traceService.getTraceDetail(params.get('id')))
30 | .subscribe((result: TraceDetailViewModel) => {
31 | this.detailViewModel = result;
32 | this.bindTineLine(result.duration);
33 | });
34 | }
35 |
36 | bindTineLine(duration: number) {
37 | for (let i = 2; i <= 8; i++) {
38 | this.timelines.push(utils.toDisplayDuration(duration * i / 8));
39 | }
40 | }
41 |
42 | collapse(span: SpanViewModel, expand: boolean) {
43 | if (expand) {
44 | return;
45 | }
46 | if (span.hasChildren) {
47 | for (let child of span.children) {
48 | child.expand = expand;
49 | this.collapse(child, expand);
50 | }
51 | }
52 | }
53 |
54 | showSpanDetail(span: SpanViewModel) {
55 | const subscription = this.modalService.open({
56 | title: span.operationName,
57 | content: SpanComponent,
58 | //width: document.body.clientWidth * 0.5,
59 | width: 540,
60 | footer: false,
61 | componentParams: {
62 | SpanId: span.spanId
63 | }
64 | });
65 | }
66 | }
--------------------------------------------------------------------------------
/src/app/tracing/traces/traces.component.css:
--------------------------------------------------------------------------------
1 | .trace-duration-timeline {
2 | background-color: #5caddf;
3 | color: #fff;
4 | padding-left: 10px;
5 | line-height: 24px;
6 | height: 26px;
7 | border-radius: 4px;
8 | font-size: 12px;
9 | transition: all 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
10 | opacity: 1;
11 | cursor: pointer;
12 | white-space: nowrap;
13 | }
14 |
15 | .trace-data {
16 | margin-top: -10px;
17 | }
18 |
19 | .trace-search {
20 | width: 160px;
21 | margin: 5px 2px;
22 | }
23 |
24 | .trace-limit{
25 | width: 50px;
26 | margin: 5px;
27 | }
28 |
29 | .trace-item{
30 | padding: 5px;
31 | color: (0, 0, 0, 0.75);
32 | }
33 |
34 | .trace-duration{
35 | background: rgba(0, 0, 0, .04);
36 | }
37 |
38 | .trace-router{
39 | text-align: center;
40 | line-height:26px;
41 | }
42 |
43 | .trace-Timestamp{
44 | text-align: left;
45 | line-height:26px;
46 | float: left;
47 | margin-left: 2px;
48 | margin-right: 10px;
49 | }
50 |
51 | .trace-description{
52 | padding: 10px 5px 5px 0;
53 | font-size: 13px;
54 | }
55 |
56 | .trace-chart{
57 | margin-top: 30px;
58 | height: 300px;
59 | }
--------------------------------------------------------------------------------
/src/app/tracing/traces/traces.component.html:
--------------------------------------------------------------------------------
1 |
2 | Service
3 |
5 |
6 |
7 |
8 | Tags
9 |
10 | Start
11 |
13 | Finish
14 |
16 | Limit
17 |
18 |
19 |
20 |
21 |
25 |
26 |
27 |
31 |
32 |
33 |
34 |
35 |
36 |
{{ data.displayDuration }}
37 |
38 |
41 |
42 |
43 |
44 |
45 | {{ service.name }} x {{ service.count }}
46 |
47 |
48 |
49 | {{ data.startTimestamp | date: 'yyyy/MM/dd HH:mm:ss.SSS'}}
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/src/app/tracing/traces/traces.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { TracesComponent } from './traces.component';
4 |
5 | describe('FindTracesComponent', () => {
6 | let component: TracesComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ TracesComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(TracesComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/tracing/traces/traces.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { TraceService } from '../../services/trace.service';
3 | import { TraceViewModel, SearchTraceViewModel, TraceHistogramViewModel } from '../../models/trace.viewModel';
4 | import { PageViewModel } from '../../models/page.viewModel';
5 | import G2 from '@antv/g2';
6 |
7 | @Component({
8 | selector: 'app-find-traces',
9 | templateUrl: './traces.component.html',
10 | styleUrls: ['./traces.component.css']
11 | })
12 |
13 | export class TracesComponent implements OnInit {
14 |
15 | loading: boolean;
16 | selectorOpen = false;
17 | traceViewModel: TraceViewModel[] = [];
18 | searchViewModel: SearchTraceViewModel;
19 | services: string[] = [];
20 | limits: number[] = [10, 20, 50];
21 | chart: any;
22 | data: TraceHistogramViewModel[] = [];
23 |
24 | constructor(private traceService: TraceService) {
25 | this.searchViewModel = new SearchTraceViewModel();
26 | }
27 |
28 | async ngOnInit() {
29 | this.chart = this.initCharts();
30 | this.refreshData();
31 | }
32 |
33 | async refreshData() {
34 | this.loading = true;
35 | this.traceViewModel = await this.traceService.getTraces(this.searchViewModel);
36 | this.data = await this.traceService.getTraceHistogram(this.searchViewModel);
37 | if (this.data.length === 0) {
38 | this.chart.changeVisible(false);
39 | } else {
40 | this.chart.changeVisible(true);
41 | this.chart.changeData(this.data);
42 | }
43 |
44 | this.loading = false;
45 | }
46 |
47 | async serviceSelectorOpen() {
48 | if (!this.selectorOpen) {
49 | this.selectorOpen = true;
50 | this.services = await this.traceService.getServices();
51 | } else {
52 | this.selectorOpen = false;
53 | }
54 | }
55 |
56 | initCharts(): any {
57 | const chart = new G2.Chart({
58 | container: 'chart',
59 | forceFit: true,
60 | height: 300
61 | });
62 | chart.scale({
63 | time: {
64 | type: 'time',
65 | mask: 'YYYY-MM-DD HH:mm'
66 | },
67 | count: {
68 | }
69 | });
70 | chart.axis('time', {
71 | grid: {
72 | type: 'time',
73 | lineStyle: {
74 | stroke: '#d9d9d9',
75 | lineWidth: 1,
76 | lineDash: [4, 4]
77 | }
78 | }
79 | });
80 | chart.axis('count', {
81 | label: {
82 | autoRotate: true,
83 | formatter: val => {
84 | if (val < 1000) {
85 | return val;
86 | }
87 | return (val / 1000).toFixed(1) + 'k';
88 | }
89 | },
90 | line: {
91 | lineWidth: 1,
92 | stroke: '#c5c2c2',
93 | }
94 | });
95 | chart.area().position('time*count');
96 | chart.line().position('time*count').size(0.5);
97 | chart.render();
98 | chart.changeVisible(false);
99 | return chart;
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/app/tracing/tracing-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { RouterModule, Routes } from '@angular/router';
3 | import { componentFactoryName } from '@angular/compiler';
4 | import { TracesComponent } from './traces/traces.component';
5 | import { TraceComponent } from './trace/trace.component';
6 | import { DependencyComponent } from './dependency/dependency.component';
7 |
8 | const routes: Routes = [
9 | {
10 | path: 'tracing',
11 | children: [
12 | { path: 'traces', component: TracesComponent },
13 | { path: 'trace/:id', component: TraceComponent },
14 | { path: 'dependencies', component: DependencyComponent }
15 | ]
16 | }
17 | ];
18 |
19 | @NgModule({
20 | imports: [RouterModule.forChild(routes)],
21 | exports: [RouterModule]
22 | })
23 | export class TracingRoutingModule { }
--------------------------------------------------------------------------------
/src/app/tracing/tracing.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
3 | import { NgModule } from '@angular/core';
4 | import { FormsModule } from '@angular/forms';
5 | import { HttpModule } from '@angular/http';
6 | import { NgZorroAntdModule } from 'ng-zorro-antd';
7 | import { RouterModule } from '@angular/router';
8 | import { TracingRoutingModule } from './tracing-routing.module';
9 | import { TracesComponent } from './traces/traces.component';
10 | import { TraceComponent } from './trace/trace.component';
11 | import { SpanComponent } from './span/span.component';
12 | import { DependencyComponent } from './dependency/dependency.component';
13 |
14 | @NgModule({
15 | declarations: [
16 | TracesComponent,
17 | TraceComponent,
18 | SpanComponent,
19 | DependencyComponent
20 | ],
21 | imports: [
22 | BrowserModule,
23 | FormsModule,
24 | HttpModule,
25 | BrowserAnimationsModule,
26 | NgZorroAntdModule.forRoot(),
27 | RouterModule,
28 | TracingRoutingModule
29 | ]
30 | })
31 |
32 | export class TracingModule {
33 | }
34 |
--------------------------------------------------------------------------------
/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liuhaoyang/butterfly-ui/31e3b51fd8915bd2f8d925d36649d162ec9d37ac/src/assets/.gitkeep
--------------------------------------------------------------------------------
/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true,
3 | collectorapi: "/api/"
4 | };
5 |
--------------------------------------------------------------------------------
/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // The file contents for the current environment will overwrite these during build.
2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do
3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead.
4 | // The list of which env maps to which file can be found in `.angular-cli.json`.
5 |
6 | export const environment = {
7 | production: false,
8 | collectorapi: "http://localhost:9618/api/"
9 | };
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Butterfly APM
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | enableProdMode();
8 |
9 | platformBrowserDynamic().bootstrapModule(AppModule)
10 | .catch(err => console.log(err));
11 |
--------------------------------------------------------------------------------
/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/
22 | // import 'core-js/es6/symbol';
23 | // import 'core-js/es6/object';
24 | // import 'core-js/es6/function';
25 | // import 'core-js/es6/parse-int';
26 | // import 'core-js/es6/parse-float';
27 | // import 'core-js/es6/number';
28 | // import 'core-js/es6/math';
29 | // import 'core-js/es6/string';
30 | // import 'core-js/es6/date';
31 | // import 'core-js/es6/array';
32 | // import 'core-js/es6/regexp';
33 | // import 'core-js/es6/map';
34 | // import 'core-js/es6/weak-map';
35 | // import 'core-js/es6/set';
36 |
37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
38 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
39 |
40 | /** IE10 and IE11 requires the following for the Reflect API. */
41 | // import 'core-js/es6/reflect';
42 |
43 |
44 | /** Evergreen browsers require these. **/
45 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
46 | import 'core-js/es7/reflect';
47 |
48 |
49 | /**
50 | * Required to support Web Animations `@angular/platform-browser/animations`.
51 | * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
52 | **/
53 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
54 |
55 |
56 |
57 | /***************************************************************************************************
58 | * Zone JS is required by default for Angular itself.
59 | */
60 | import 'zone.js/dist/zone'; // Included with Angular CLI.
61 |
62 |
63 |
64 | /***************************************************************************************************
65 | * APPLICATION IMPORTS
66 | */
67 |
--------------------------------------------------------------------------------
/src/styles.css:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 | table tr {
3 | outline: none;
4 | }
--------------------------------------------------------------------------------
/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/long-stack-trace-zone';
4 | import 'zone.js/dist/proxy.js';
5 | import 'zone.js/dist/sync-test';
6 | import 'zone.js/dist/jasmine-patch';
7 | import 'zone.js/dist/async-test';
8 | import 'zone.js/dist/fake-async-test';
9 | import { getTestBed } from '@angular/core/testing';
10 | import {
11 | BrowserDynamicTestingModule,
12 | platformBrowserDynamicTesting
13 | } from '@angular/platform-browser-dynamic/testing';
14 |
15 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
16 | declare const __karma__: any;
17 | declare const require: any;
18 |
19 | // Prevent Karma from running prematurely.
20 | __karma__.loaded = function () {};
21 |
22 | // First, initialize the Angular testing environment.
23 | getTestBed().initTestEnvironment(
24 | BrowserDynamicTestingModule,
25 | platformBrowserDynamicTesting()
26 | );
27 | // Then we find all the tests.
28 | const context = require.context('./', true, /\.spec\.ts$/);
29 | // And load the modules.
30 | context.keys().map(context);
31 | // Finally, start Karma to run the tests.
32 | __karma__.start();
33 |
--------------------------------------------------------------------------------
/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "baseUrl": "./",
6 | "module": "es2015",
7 | "types": []
8 | },
9 | "exclude": [
10 | "test.ts",
11 | "**/*.spec.ts"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "baseUrl": "./",
6 | "module": "commonjs",
7 | "target": "es5",
8 | "types": [
9 | "jasmine",
10 | "node"
11 | ]
12 | },
13 | "files": [
14 | "test.ts"
15 | ],
16 | "include": [
17 | "**/*.spec.ts",
18 | "**/*.d.ts"
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/src/typings.d.ts:
--------------------------------------------------------------------------------
1 | /* SystemJS module definition */
2 | declare var module: NodeModule;
3 | interface NodeModule {
4 | id: string;
5 | }
6 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "outDir": "./dist/out-tsc",
5 | "sourceMap": true,
6 | "declaration": false,
7 | "moduleResolution": "node",
8 | "emitDecoratorMetadata": true,
9 | "experimentalDecorators": true,
10 | "target": "es5",
11 | "typeRoots": [
12 | "node_modules/@types"
13 | ],
14 | "lib": [
15 | "es2017",
16 | "dom"
17 | ]
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rulesDirectory": [
3 | "node_modules/codelyzer"
4 | ],
5 | "rules": {
6 | "arrow-return-shorthand": true,
7 | "callable-types": true,
8 | "class-name": true,
9 | "comment-format": [
10 | true,
11 | "check-space"
12 | ],
13 | "curly": true,
14 | "deprecation": {
15 | "severity": "warn"
16 | },
17 | "eofline": true,
18 | "forin": true,
19 | "import-blacklist": [
20 | true,
21 | "rxjs",
22 | "rxjs/Rx"
23 | ],
24 | "import-spacing": true,
25 | "indent": [
26 | true,
27 | "spaces"
28 | ],
29 | "interface-over-type-literal": true,
30 | "label-position": true,
31 | "max-line-length": [
32 | true,
33 | 140
34 | ],
35 | "member-access": false,
36 | "member-ordering": [
37 | true,
38 | {
39 | "order": [
40 | "static-field",
41 | "instance-field",
42 | "static-method",
43 | "instance-method"
44 | ]
45 | }
46 | ],
47 | "no-arg": true,
48 | "no-bitwise": true,
49 | "no-console": [
50 | true,
51 | "debug",
52 | "info",
53 | "time",
54 | "timeEnd",
55 | "trace"
56 | ],
57 | "no-construct": true,
58 | "no-debugger": true,
59 | "no-duplicate-super": true,
60 | "no-empty": false,
61 | "no-empty-interface": true,
62 | "no-eval": true,
63 | "no-inferrable-types": [
64 | true,
65 | "ignore-params"
66 | ],
67 | "no-misused-new": true,
68 | "no-non-null-assertion": true,
69 | "no-shadowed-variable": true,
70 | "no-string-literal": false,
71 | "no-string-throw": true,
72 | "no-switch-case-fall-through": true,
73 | "no-trailing-whitespace": true,
74 | "no-unnecessary-initializer": true,
75 | "no-unused-expression": true,
76 | "no-use-before-declare": true,
77 | "no-var-keyword": true,
78 | "object-literal-sort-keys": false,
79 | "one-line": [
80 | true,
81 | "check-open-brace",
82 | "check-catch",
83 | "check-else",
84 | "check-whitespace"
85 | ],
86 | "prefer-const": true,
87 | "quotemark": [
88 | true,
89 | "single"
90 | ],
91 | "radix": true,
92 | "semicolon": [
93 | true,
94 | "always"
95 | ],
96 | "triple-equals": [
97 | true,
98 | "allow-null-check"
99 | ],
100 | "typedef-whitespace": [
101 | true,
102 | {
103 | "call-signature": "nospace",
104 | "index-signature": "nospace",
105 | "parameter": "nospace",
106 | "property-declaration": "nospace",
107 | "variable-declaration": "nospace"
108 | }
109 | ],
110 | "typeof-compare": true,
111 | "unified-signatures": true,
112 | "variable-name": false,
113 | "whitespace": [
114 | true,
115 | "check-branch",
116 | "check-decl",
117 | "check-operator",
118 | "check-separator",
119 | "check-type"
120 | ],
121 | "directive-selector": [
122 | true,
123 | "attribute",
124 | "app",
125 | "camelCase"
126 | ],
127 | "component-selector": [
128 | true,
129 | "element",
130 | "app",
131 | "kebab-case"
132 | ],
133 | "no-output-on-prefix": true,
134 | "use-input-property-decorator": true,
135 | "use-output-property-decorator": true,
136 | "use-host-property-decorator": true,
137 | "no-input-rename": true,
138 | "no-output-rename": true,
139 | "use-life-cycle-interface": true,
140 | "use-pipe-transform-interface": true,
141 | "component-class-suffix": true,
142 | "directive-class-suffix": true
143 | }
144 | }
145 |
--------------------------------------------------------------------------------